aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesus <heckyel@riseup.net>2023-12-01 07:33:47 +0800
committerJesus <heckyel@riseup.net>2023-12-01 07:33:47 +0800
commita1db584b8fe66c00e1b9ead5a98cc7ad833dd15a (patch)
tree77aed0fa06e04ecc3f678d3b22eacfd1f9baf95a
parentbed0810a72f67e0648caf8288f0a5f661b4282be (diff)
downloadbook-a1db584b8fe66c00e1b9ead5a98cc7ad833dd15a.tar.lz
book-a1db584b8fe66c00e1b9ead5a98cc7ad833dd15a.tar.xz
book-a1db584b8fe66c00e1b9ead5a98cc7ad833dd15a.zip
Add WSL doc
-rw-r--r--wsl/README.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/wsl/README.md b/wsl/README.md
new file mode 100644
index 0000000..424d5e5
--- /dev/null
+++ b/wsl/README.md
@@ -0,0 +1,34 @@
+## Force DNS Usage inside VPN
+
+```bash
+$ cat /etc/systemd/system/vpn-dns.service
+[Unit]
+Description=VPN DNS Configuration
+
+[Service]
+Type=oneshot
+ExecStart=/bin/vpn-dns.sh
+Environment=TERM=xterm
+
+[Install]
+WantedBy=multi-user.target
+```
+
+```bash
+$ cat /bin/vpn-dns.sh
+#!/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