diff options
author | Astound <kirito@disroot.org> | 2023-12-24 17:24:08 -0500 |
---|---|---|
committer | Astound <kirito@disroot.org> | 2023-12-24 17:24:08 -0500 |
commit | 7d41f0ad816010a32b698ea6d5a348d100d5f127 (patch) | |
tree | 1cfa72c5417745ed9a217a7084d1b42f1c2b2bb6 | |
parent | 043f92654161b4ec1533f11c0f9f165921844842 (diff) | |
download | book-7d41f0ad816010a32b698ea6d5a348d100d5f127.tar.lz book-7d41f0ad816010a32b698ea6d5a348d100d5f127.tar.xz book-7d41f0ad816010a32b698ea6d5a348d100d5f127.zip |
wsl: update
-rw-r--r-- | wsl/README.md | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/wsl/README.md b/wsl/README.md index e639153..c957f6b 100644 --- a/wsl/README.md +++ b/wsl/README.md @@ -1,8 +1,30 @@ ## Force DNS Usage inside VPN -### SystemD +### Bash script + +```bash +$ cat /bin/vpn-dns +#!/bin/bash + +echo "Getting current DNS servers, this takes a couple of seconds" + +/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command ' +$ErrorActionPreference="SilentlyContinue" +Get-NetAdapter -InterfaceDescription "WireGuard Tunnel*" | Get-DnsClientServerAddress | Select -ExpandProperty ServerAddresses +Get-NetAdapter | ?{-not ($_.InterfaceDescription -like "WireGuard Tunnel*") } | Get-DnsClientServerAddress | Select -ExpandProperty ServerAddresses +' | \ + awk 'BEGIN { print "# Generated by vpn fix func on", strftime("%c"); print } { print "nameserver", $1 }' | \ + tr -d '\r' > /etc/resolv.conf +clear +``` + +### Configure Init + +#### SystemD + +Save file into /etc/systemd/system/vpn-dns.service with 755 permissions + ```bash -$ cat /etc/systemd/system/vpn-dns.service [Unit] Description=VPN DNS Configuration @@ -15,7 +37,9 @@ Environment=TERM=xterm WantedBy=multi-user.target ``` -### OpenRC +#### OpenRC + +Save file into /etc/init.d/vpn-dn swith 755 permissions ```bash #!/sbin/openrc-run @@ -48,21 +72,6 @@ stop() { } ``` -```bash -$ cat /bin/vpn-dns -#!/bin/bash - -echo "Getting current DNS servers, this takes a couple of seconds" - -/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command ' -$ErrorActionPreference="SilentlyContinue" -Get-NetAdapter -InterfaceDescription "WireGuard Tunnel*" | Get-DnsClientServerAddress | Select -ExpandProperty ServerAddresses -Get-NetAdapter | ?{-not ($_.InterfaceDescription -like "WireGuard Tunnel*") } | Get-DnsClientServerAddress | Select -ExpandProperty ServerAddresses -' | \ - awk 'BEGIN { print "# Generated by vpn fix func on", strftime("%c"); print } { print "nameserver", $1 }' | \ - tr -d '\r' > /etc/resolv.conf -clear -``` ### Show Networks c/> Get-NetAdapter |