I am trying to run wsl-vpnkit as a service using the separate distro method. I can run it directly from PowerShell and as a standalone script and networking and DNS work fine. However when trying to run via systemctl it fails to start correctly. I see the following when running standalone:
/app# wsl-vpnkit
- VPNKIT_GATEWAY_IP=192.168.127.1
- VPNKIT_HOST_IP=192.168.127.254
- VPNKIT_LOCAL_IP=192.168.127.2
- TAP_MAC_ADDR=5a:94:ef:e4:0c:ee
- VMEXEC_PATH=/app/wsl-vm
- GVPROXY_PATH=/app/wsl-gvproxy.exe
- TAP_NAME=wsltap
- CHECK_HOST=example.com
- CHECK_DNS=1.1.1.1
- DEBUG=0
- set +x
- WSL2_TAP_NAME=eth0
- WSL2_GATEWAY_IP=172.22.32.1
- '[' 0 -eq 0 ]
- set +x
starting vm and gvproxy...
INFO[0000] waiting for packets...
time="2023-11-16T09:54:27-06:00" level=info msg="waiting for clients..."
time="2023-11-16T09:54:27-06:00" level=info msg="new connection from remote to 14348"
started vm and gvproxy
check: ✔️ ping success to IPv4 WSL 2 gateway / Windows host (172.22.32.1)
check: ✔️ ping success to IPv4 Windows host (192.168.127.254)
check: ✔️ ping success to IPv4 gateway (192.168.127.1)
check: ✔️ nslookup success for example.com A using 192.168.127.1
check: ✔️ nslookup success for example.com A using 172.22.32.1
check: ❌ nslookup fail for example.com A using 1.1.1.1
check: ✔️ ping success to IPv4 external host domain (example.com)
check: ✔️ ping success to IPv4 external host IP (1.1.1.1)
check: ✔️ nslookup success for example.com AAAA using 192.168.127.1
check: ✔️ nslookup success for example.com AAAA using 172.22.32.1
check: ❌ nslookup fail for example.com AAAA using 1.1.1.1
ping: bad address 'example.com'
check: ➖ ping fail to IPv6 external host (example.com)
check: ✔️ wget success for http://example.com
485B4BFD6D7F0000:error:0A000086:SSL routines:tls_post_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1889:
ssl_client: SSL_connect
wget: error getting response: Connection reset by peer
check: ❌ wget fail for https://example.com
W1116 09:54:29.088278 14348 gonet.go:457] ep.GetRemoteAddress() failed: endpoint not connected
When running as a service:
systemctl status wsl-vpnkit
× wsl-vpnkit.service - wsl-vpnkit
Loaded: loaded (/etc/systemd/system/wsl-vpnkit.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2023-11-16 10:17:09 CST; 6s ago
Process: 905 ExecStart=/mnt/c/Windows/system32/wsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit (code=exited, status=1/FA>
Main PID: 905 (code=exited, status=1/FAILURE)
Nov 16 10:17:09 systemd[1]: wsl-vpnkit.service: Scheduled restart job, restart counter is at 5.
Nov 16 10:17:09 systemd[1]: Stopped wsl-vpnkit.
Nov 16 10:17:09 systemd[1]: wsl-vpnkit.service: Start request repeated too quickly.
Nov 16 10:17:09 systemd[1]: wsl-vpnkit.service: Failed with result 'exit-code'.
Nov 16 10:17:09 systemd[1]: Failed to start wsl-vpnkit.
Running "/mnt/c/Windows/system32/wsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit" from the service info above gives me:
$ /mnt/c/Windows/system32/wsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit
- VPNKIT_GATEWAY_IP=192.168.127.1
- VPNKIT_HOST_IP=192.168.127.254
- VPNKIT_LOCAL_IP=192.168.127.2
- TAP_MAC_ADDR=5a:94:ef:e4:0c:ee
- VMEXEC_PATH=/app/wsl-vm
- GVPROXY_PATH=/app/wsl-gvproxy.exe
- TAP_NAME=wsltap
- CHECK_HOST=example.com
- CHECK_DNS=1.1.1.1
- DEBUG=0
- set +x
- WSL2_TAP_NAME=eth0
- WSL2_GATEWAY_IP=172.22.32.1
- '[' 0 -eq 0 ]
- set +x
starting vm and gvproxy...
INFO[0000] waiting for packets...
time="2023-11-16T10:20:03-06:00" level=info msg="waiting for clients..."
time="2023-11-16T10:20:03-06:00" level=info msg="new connection from remote to 7364"
time="2023-11-16T10:20:03-06:00" level=error msg="r.CreateEndpoint() = no route to host"
time="2023-11-16T10:20:03-06:00" level=error msg="r.CreateEndpoint() = no route to host"
time="2023-11-16T10:20:03-06:00" level=error msg="r.CreateEndpoint() = no route to host"
time="2023-11-16T10:20:03-06:00" level=error msg="r.CreateEndpoint() = no route to host"
started vm and gvproxy
check: ✔️ ping success to IPv4 WSL 2 gateway / Windows host (172.22.32.1)
check: ✔️ ping success to IPv4 Windows host (192.168.127.254)
check: ✔️ ping success to IPv4 gateway (192.168.127.1)
check: ✔️ nslookup success for example.com A using 192.168.127.1
check: ✔️ nslookup success for example.com A using 172.22.32.1
check: ❌ nslookup fail for example.com A using 1.1.1.1
check: ✔️ ping success to IPv4 external host domain (example.com)
check: ✔️ ping success to IPv4 external host IP (1.1.1.1)
check: ✔️ nslookup success for example.com AAAA using 192.168.127.1
check: ✔️ nslookup success for example.com AAAA using 172.22.32.1
check: ❌ nslookup fail for example.com AAAA using 1.1.1.1
ping: bad address 'example.com'
check: ➖ ping fail to IPv6 external host (example.com)
check: ✔️ wget success for http://example.com
489B9D6FBA7F0000:error:0A000086:SSL routines:tls_post_process_server_certificate:certificate verify failed:ssl/statem/st
atem_clnt.c:1889:
ssl_client: SSL_connect
wget: error getting response: Connection reset by peer
check: ❌ wget fail for https://example.com
W1116 10:20:04.280806 7364 gonet.go:457] ep.GetRemoteAddress() failed: endpoint not connected
Regardless of how I directly run it, networking works and I can resolve stuff. Just starting as a service fails.
I've found that while name resolution works fine using local name servers, I am not allowed to use 1.1.1.1 or 8.8.8.8. I am guessing at this point that the systemctl service is seeing these failures and saying that it can't start. Any help you can provide would be greatly appreciated.
I am trying to run wsl-vpnkit as a service using the separate distro method. I can run it directly from PowerShell and as a standalone script and networking and DNS work fine. However when trying to run via systemctl it fails to start correctly. I see the following when running standalone:
/app# wsl-vpnkit
starting vm and gvproxy...
INFO[0000] waiting for packets...
time="2023-11-16T09:54:27-06:00" level=info msg="waiting for clients..."
time="2023-11-16T09:54:27-06:00" level=info msg="new connection from remote to 14348"
started vm and gvproxy
check: ✔️ ping success to IPv4 WSL 2 gateway / Windows host (172.22.32.1)
check: ✔️ ping success to IPv4 Windows host (192.168.127.254)
check: ✔️ ping success to IPv4 gateway (192.168.127.1)
check: ✔️ nslookup success for example.com A using 192.168.127.1
check: ✔️ nslookup success for example.com A using 172.22.32.1
check: ❌ nslookup fail for example.com A using 1.1.1.1
check: ✔️ ping success to IPv4 external host domain (example.com)
check: ✔️ ping success to IPv4 external host IP (1.1.1.1)
check: ✔️ nslookup success for example.com AAAA using 192.168.127.1
check: ✔️ nslookup success for example.com AAAA using 172.22.32.1
check: ❌ nslookup fail for example.com AAAA using 1.1.1.1
ping: bad address 'example.com'
check: ➖ ping fail to IPv6 external host (example.com)
check: ✔️ wget success for http://example.com
485B4BFD6D7F0000:error:0A000086:SSL routines:tls_post_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1889:
ssl_client: SSL_connect
wget: error getting response: Connection reset by peer
check: ❌ wget fail for https://example.com
W1116 09:54:29.088278 14348 gonet.go:457] ep.GetRemoteAddress() failed: endpoint not connected
When running as a service:
systemctl status wsl-vpnkit
× wsl-vpnkit.service - wsl-vpnkit
Loaded: loaded (/etc/systemd/system/wsl-vpnkit.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2023-11-16 10:17:09 CST; 6s ago
Process: 905 ExecStart=/mnt/c/Windows/system32/wsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit (code=exited, status=1/FA>
Main PID: 905 (code=exited, status=1/FAILURE)
Nov 16 10:17:09 systemd[1]: wsl-vpnkit.service: Scheduled restart job, restart counter is at 5.
Nov 16 10:17:09 systemd[1]: Stopped wsl-vpnkit.
Nov 16 10:17:09 systemd[1]: wsl-vpnkit.service: Start request repeated too quickly.
Nov 16 10:17:09 systemd[1]: wsl-vpnkit.service: Failed with result 'exit-code'.
Nov 16 10:17:09 systemd[1]: Failed to start wsl-vpnkit.
Running "/mnt/c/Windows/system32/wsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit" from the service info above gives me:
$ /mnt/c/Windows/system32/wsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit
starting vm and gvproxy...
INFO[0000] waiting for packets...
time="2023-11-16T10:20:03-06:00" level=info msg="waiting for clients..."
time="2023-11-16T10:20:03-06:00" level=info msg="new connection from remote to 7364"
time="2023-11-16T10:20:03-06:00" level=error msg="r.CreateEndpoint() = no route to host"
time="2023-11-16T10:20:03-06:00" level=error msg="r.CreateEndpoint() = no route to host"
time="2023-11-16T10:20:03-06:00" level=error msg="r.CreateEndpoint() = no route to host"
time="2023-11-16T10:20:03-06:00" level=error msg="r.CreateEndpoint() = no route to host"
started vm and gvproxy
check: ✔️ ping success to IPv4 WSL 2 gateway / Windows host (172.22.32.1)
check: ✔️ ping success to IPv4 Windows host (192.168.127.254)
check: ✔️ ping success to IPv4 gateway (192.168.127.1)
check: ✔️ nslookup success for example.com A using 192.168.127.1
check: ✔️ nslookup success for example.com A using 172.22.32.1
check: ❌ nslookup fail for example.com A using 1.1.1.1
check: ✔️ ping success to IPv4 external host domain (example.com)
check: ✔️ ping success to IPv4 external host IP (1.1.1.1)
check: ✔️ nslookup success for example.com AAAA using 192.168.127.1
check: ✔️ nslookup success for example.com AAAA using 172.22.32.1
check: ❌ nslookup fail for example.com AAAA using 1.1.1.1
ping: bad address 'example.com'
check: ➖ ping fail to IPv6 external host (example.com)
check: ✔️ wget success for http://example.com
489B9D6FBA7F0000:error:0A000086:SSL routines:tls_post_process_server_certificate:certificate verify failed:ssl/statem/st
atem_clnt.c:1889:
ssl_client: SSL_connect
wget: error getting response: Connection reset by peer
check: ❌ wget fail for https://example.com
W1116 10:20:04.280806 7364 gonet.go:457] ep.GetRemoteAddress() failed: endpoint not connected
Regardless of how I directly run it, networking works and I can resolve stuff. Just starting as a service fails.
I've found that while name resolution works fine using local name servers, I am not allowed to use 1.1.1.1 or 8.8.8.8. I am guessing at this point that the systemctl service is seeing these failures and saying that it can't start. Any help you can provide would be greatly appreciated.