wsl: update

This commit is contained in:
Jesus 2023-12-25 05:24:17 +08:00
parent a1db584b8f
commit 32190623ef
No known key found for this signature in database
GPG Key ID: E607CE7149F4D71C

View File

@ -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
$ cat /bin/vpn-dns.sh
#!/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
#!/bin/bash
echo "Getting current DNS servers, this takes a couple of seconds"