aboutsummaryrefslogtreecommitdiffstats
path: root/wsl/README.md
blob: f45695c710059fbc5fb086b267d1269f11394f5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
## Force DNS Usage inside VPN

### Bash script
Save file into /bin/vpn-dns swith 755 permissions

```bash
#!/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
[Unit]
Description=VPN DNS Configuration

[Service]
Type=oneshot
ExecStart=/bin/vpn-dns
Environment=TERM=xterm

[Install]
WantedBy=multi-user.target
```

Enable service

```console
systemctl enable vpn-dns
```

#### OpenRC

Save file into /etc/init.d/vpn-dns with 755 permissions

```bash
#!/sbin/openrc-run
# Distributed under the terms of the GNU General Public License v3 or later
name="vpn-dns"
description="VPN DNS Configuration"
command="/bin/vpn-dns"

depend() {
    use net
}

start() {
  ebegin "Starting VPN DNS Configuration"
  "${command}"
  eend $? "Failed to start VPN DNS Configuration"
}
```

Enable service

```console
rc-update add vpn-dns boot
```

### Show Networks

c/> Get-NetAdapter