From 32190623efdae071410a7375058234dfad45d2ee Mon Sep 17 00:00:00 2001 From: Jesus Date: Mon, 25 Dec 2023 05:24:17 +0800 Subject: wsl: update --- wsl/README.md | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/wsl/README.md b/wsl/README.md index 424d5e5..e1dfe1e 100644 --- a/wsl/README.md +++ b/wsl/README.md @@ -1,5 +1,6 @@ ## Force DNS Usage inside VPN +### SystemD ```bash $ cat /etc/systemd/system/vpn-dns.service [Unit] @@ -7,15 +8,48 @@ Description=VPN DNS Configuration [Service] Type=oneshot -ExecStart=/bin/vpn-dns.sh +ExecStart=/bin/vpn-dns Environment=TERM=xterm [Install] WantedBy=multi-user.target ``` +### OpenRC + +```bash +#!/sbin/openrc-run +# Distributed under the terms of the GNU General Public License v3 or later +name="vpn-dns" +description="VPN DNS Configuration" +pidfile="/var/run/vpn-dns.pid" +command="/bin/vpn-dns" + +depend() { + use net +} + +start() { + ebegin "Starting ${name}" + start-stop-daemon --start --exec "${command}" --pidfile "${pidfile}" + eend $? +} + +reload() { + ebegin "Reloading ${name}" + start-stop-daemon --signal HUP --pidfile "${pidfile}" + eend $? +}+ + +stop() { + ebegin "Stopping ${name}" + start-stop-daemon --quiet --stop --exec "${command}" --pidfile "${pidfile}" + eend $? +} +``` + ```bash -$ cat /bin/vpn-dns.sh +$ cat /bin/vpn-dns #!/bin/bash echo "Getting current DNS servers, this takes a couple of seconds" -- cgit v1.2.3