wsl-vpnkit icon indicating copy to clipboard operation
wsl-vpnkit copied to clipboard

No more internet connection during minutes and then, the magic happens

Open cavo789 opened this issue 2 years ago • 8 comments

Hello

Thanks for your work, really! Without it, it would be just impossible to work from home since I need to first start my corporate VPN then, all the day, I'm working in WSL2. I can't live without wsl-vpnkit since, it means working back on MS DOS; damned! ;-)

One question please: just after having fired wsl.exe -d wsl-vpnkit service wsl-vpnkit start on my WSL2, I've no more internet connection during a very long time (perhaps two minutes or more) then the magic happens.

Did you have any idea why there is something like ... a bottleneck somewhere ... I just need to wait and it works but would be wonderful if this can works directly.

A concrete example : I've a corporate repository on my disk, I jump into the folder and run git fetch --all. Didn't work. Then I start wsl.exe -d wsl-vpnkit service wsl-vpnkit start and wait a long time then, from time to time, I run git fetch --all one more; still NOK until the time it's OK.

Note: I'm not behind any firewall; just using a corporate VPN and WSL2.

Many, many thanks.

cavo789 avatar Sep 13 '22 13:09 cavo789

Can you try tailing the logs and see if it pauses at any point?

wsl.exe -d wsl-vpnkit tail -f /var/log/wsl-vpnkit.log

You should see check: ✔️ wget success for https://example.com when it's all connected.

sakai135 avatar Sep 13 '22 13:09 sakai135

Thanks for your answer.

I've reboot my computer and remove/reinstall wsl-vpnkit and, right now, I've a working environment.

Here is the requested output:

❯ wsl.exe -d wsl-vpnkit tail -f /var/log/wsl-vpnkit.log
check: ✔️ nslookup success for example.com A using 172.18.16.1
check: ✔️ nslookup success for example.com A using 1.1.1.1
check: ✔️ ping success to IPv4 external host (example.com)
check: ✔️ nslookup success for example.com AAAA using 192.168.67.1
check: ✔️ nslookup success for example.com AAAA using 192.168.67.1
check: ✔️ nslookup success for example.com AAAA using 172.18.16.1
check: ✔️ nslookup success 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 https://example.com

I already fired this command one hour ago and the output was longer. If I work from home tomorrow, I'll run first wsl.exe -d wsl-vpnkit service wsl-vpnkit start then wsl.exe -d wsl-vpnkit tail -f /var/log/wsl-vpnkit.log and let you know.

Thanks

cavo789 avatar Sep 13 '22 14:09 cavo789

I've reboot my computer once more, just to check.

Just after the reboot and before starting the VPN, I've started a WSL2 session (i.e. a Ubuntu console) and fired ping -c1 www.google.com: it works, I've immediately the answer.

Then, I've started the VPN and the ping didn't work anymore (ping: www.google.com: Temporary failure in name resolution).

I run wsl.exe -d wsl-vpnkit service wsl-vpnkit start, still in my opened Ubuntu console and then wsl.exe -d wsl-vpnkit tail -f /var/log/wsl-vpnkit.log.

Here is the log:

❯ wsl.exe -d wsl-vpnkit tail -f /var/log/wsl-vpnkit.log
ping: bad address 'example.com'
check: ➖ ping fail to IPv6 external host (example.com)
check: ✔️ wget success for https://example.com
time="2022-09-13T14:35:32Z" level=fatal msg="cannot read size from socket: EOF"
cleaning up iptables...
iptables cleanup done
restoring WSL 2 ip route...
ip: RTNETLINK answers: File exists
restored WSL 2 ip route
stopped wsl-vpnkit

I press CTRL+C to quit and return to the console.

From time to time, I've start wsl.exe -d wsl-vpnkit tail -f /var/log/wsl-vpnkit.log again (without doing anything else); same result as here above.

(In a second session, ping google still doesn't work)

Ok probably should I start wsl.exe again...

I run wsl.exe -d wsl-vpnkit service wsl-vpnkit start a second time followed by wsl.exe -d wsl-vpnkit tail -f /var/log/wsl-vpnkit.log.

Here is the new log:

❯ wsl.exe -d wsl-vpnkit tail -f /var/log/wsl-vpnkit.log
starting gvproxy at /mnt/c/Users/Christophe/wsl-vpnkit/wsl-gvproxy.exe...
started gvproxy
waiting for dhcp...
time="2022-09-13T14:47:38Z" level=info msg="waiting for packets..."
udhcpc: started, v1.35.0
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc failed to get a DHCP lease
time="2022-09-13T16:48:01+02:00" level=info msg="new connection from remote to 8832"
udhcpc: broadcasting discover
udhcpc: broadcasting select for 192.168.67.3, server 192.168.67.1
udhcpc: lease of 192.168.67.3 obtained from 192.168.67.1, lease time 3600
default via 192.168.67.1 dev eth1  metric 206
dhcp completed
removing WSL 2 ip route...
removed WSL 2 ip route
adding rules to iptables...
iptables done
check: ✔️ ping success to IPv4 WSL 2 gateway / Windows host (172.28.16.1)
check: ✔️ ping success to IPv4 Windows host (192.168.67.2)
check: ✔️ ping success to IPv4 gateway (192.168.67.1)
check: ✔️ nslookup success for example.com A using 192.168.67.1
check: ✔️ nslookup success for example.com A using 192.168.67.1
check: ✔️ nslookup success for example.com A using 172.28.16.1
check: ✔️ nslookup success for example.com A using 1.1.1.1
check: ✔️ ping success to IPv4 external host (example.com)
check: ✔️ nslookup success for example.com AAAA using 192.168.67.1
check: ✔️ nslookup success for example.com AAAA using 192.168.67.1
check: ✔️ nslookup success for example.com AAAA using 172.28.16.1
check: ✔️ nslookup success 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 https://example.com

and finally the ping google (in my second console) is now working.

Is this something I can do to speed up the process?

For info, re-running wsl.exe -d wsl-vpnkit tail -f /var/log/wsl-vpnkit.log now gives:

check: ✔️ nslookup success for example.com A using 172.28.16.1
check: ✔️ nslookup success for example.com A using 1.1.1.1
check: ✔️ ping success to IPv4 external host (example.com)
check: ✔️ nslookup success for example.com AAAA using 192.168.67.1
check: ✔️ nslookup success for example.com AAAA using 192.168.67.1
check: ✔️ nslookup success for example.com AAAA using 172.28.16.1
check: ✔️ nslookup success 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 https://example.com

Many thanks

cavo789 avatar Sep 13 '22 14:09 cavo789

Is it hanging at the udhcpc: broadcasting discover part?

sakai135 avatar Sep 13 '22 15:09 sakai135

Difficult to say... If this is important how can I confirm this ?

cavo789 avatar Sep 13 '22 15:09 cavo789

Multiple lines of udhcpc: broadcasting discover and the time difference (minute/seconds part) between waiting for packets... and new connection from remote to 8832 seem to indicate that there's something related to that DHCP causing the delay.

I'll make a build that manually configures the network interface instead of using DHCP.

For now, could you try using a v0.2 release and see if that works better for you?

sakai135 avatar Sep 13 '22 16:09 sakai135

For the next coming days I'll work at the office (no more vpn). I'll check next week, as from monday. Thanks for the support !

cavo789 avatar Sep 13 '22 17:09 cavo789

Hello Keiichi

I've removed v3 and just install v0.2.5.

In my Ubuntu shell, I've started wsl.exe -d wsl-vpnkit service wsl-vpnkit start followed, a few seconds after, with wsl.exe -d wsl-vpnkit tail -f /var/log/wsl-vpnkit.log

copied npiperelay.exe to /mnt/c/Users/christophe/wsl-vpnkit/npiperelay.exe
created symbolic link at /files/npiperelay/npiperelay.exe-ln
waiting for /var/run/wsl-vpnkit.sock ...
starting socat-npiperelay...
using /files/npiperelay/npiperelay.exe-ln for npiperelay.exe
found /var/run/wsl-vpnkit.sock
starting vpnkit-tap-vsockd...
starting vpnkit...
successfully created TAP device eth1
starting in connect mode with path=/var/run/wsl-vpnkit.sock and tap=eth1
2022/09/20 11:37:44 open //./pipe/wsl-vpnkit: The system cannot find the file specified.
EOF reading from socket: closing

Failed to read hello from client
Failed to negotiate vmnet connection
wsl-vpnkit.exe: [INFO] Setting handler to ignore all SIGPIPE signals
wsl-vpnkit.exe: [INFO] Version is 6ef760094979188296cec0d5732610c021f8d3d3
wsl-vpnkit.exe: [INFO] System SOMAXCONN is 2147483647
wsl-vpnkit.exe: [INFO] Will use a listen backlog of 2147483647
wsl-vpnkit.exe: [INFO] No periodic Gc.compact enabled
wsl-vpnkit.exe: [WARNING] There is no database: using hardcoded network configuration values
wsl-vpnkit.exe: [INFO] DNS server configured with no builtin DNS names; everything will be forwarded
wsl-vpnkit.exe: [INFO] 2 upstream DNS servers are configured
wsl-vpnkit.exe: [INFO] Disabling transparent HTTP redirection
wsl-vpnkit.exe: [INFO] Updating resolvers to use host resolver
wsl-vpnkit.exe: [INFO] Secure random number generator is available
wsl-vpnkit.exe: [INFO] Add(3): DNS configuration changed to: use host resolver
wsl-vpnkit.exe: [INFO] DNS server configured with builtin DNS names [ gateway.internal -> 192.168.67.1, host.internal -> 192.168.67.2, vm.internal -> 192.168.67.3 ]
wsl-vpnkit.exe: [INFO] Will use the host's DNS resolver
wsl-vpnkit.exe: [INFO] New Gateway forward configuration: []
wsl-vpnkit.exe: [INFO] Configuration server_macaddr = f6:16:36:bc:f9:c6; max_connection = None; dns_path = None; dns = ; resolver = Host; domain = None; allowed_bind_addresses = 0.0.0.0; gateway_ip = 192.168.67.1; host_ip = 192.168.67.2; lowest_ip = 192.168.67.3; highest_ip = 192.168.67.14; dhcp_json_path = None; dhcp_configuration = None; mtu = 1500; http_intercept = None; http_intercept_path = None; port_max_idle_time = 300; host_names = host.internal; gateway_names = gateway.internal; vm_names = vm.internal; udpv4_forwards = []; tcpv4_forwards = []; gateway_forwards_path = None; pcap_snaplen = 128
wsl-vpnkit.exe: [ERROR] While watching /etc/resolv.conf: ENOENT
wsl-vpnkit.exe: [ERROR] Failed to parse address '' from hosts file
wsl-vpnkit.exe: [INFO] C:\Windows\System32\drivers\etc\hosts file has bindings for adminer.local evaluation_backend.local evaluation.local fdm.local happ.local infocenter.local limesurvey.local nova.local pgadmin.local portainer.local redis.local host.docker.internal gateway.docker.internal kubernetes.docker.internal
wsl-vpnkit.exe: [INFO] Vmnet.Server.negotiate: received { magic = VMN3T; version = 22; commit =  }
Server reports version 22, commit 0123456789012345678901234567890123456789
wsl-vpnkit.exe: [INFO] Generated UUID on behalf of client: 5e46abf2-760d-44c5-9a62-e3b4a086fd92
wsl-vpnkit.exe: [INFO] Vmnet.Server.negotiate: received Ethernet 5e46abf2-760d-44c5-9a62-e3b4a086fd92
wsl-vpnkit.exe: [INFO] Vmnet.Server.negotiate: sending { mtu = 1500; max_packet_size = 1550; client_macaddr = 02:50:00:00:00:01 }
wsl-vpnkit.exe: [INFO] Vmnet.Server.listen: rebinding the primary listen callback
wsl-vpnkit.exe: [INFO] Vmnet.Server.listen: starting event loop
wsl-vpnkit.exe: [INFO] Connected Ethernet interface f6:16:36:bc:f9:c6
VMNET VIF has MAC 02:50:00:00:00:01
wsl-vpnkit.exe: [INFO] Client mac: 02:50:00:00:00:01 server mac: f6:16:36:bc:f9:c6
wsl-vpnkit.exe: [INFO] TCP/IP ready
wsl-vpnkit.exe: [INFO] TCP/IP stack connected
started vpnkit-tap-vsockd
configuring ip...
ip config done
adding rules to iptables...
iptables done
wsl-vpnkit.exe: [INFO] Connected Ethernet interface f6:16:36:bc:f9:c6
wsl-vpnkit.exe: [INFO] UDP interface connected on 192.168.67.2
check: ✔️ ping success to IPv4 WSL 2 gateway / Windows host (172.27.64.1)
check: ✔️ ping success to IPv4 VPNKit Windows host (192.168.67.2)
wsl-vpnkit.exe: [INFO] Connected Ethernet interface f6:16:36:bc:f9:c6
wsl-vpnkit.exe: [INFO] UDP interface connected on 192.168.67.1
check: ✔️ ping success to IPv4 VPNKit gateway (192.168.67.1)
check: ✔️ nslookup success for example.com A using 192.168.67.1
check: ✔️ nslookup success for example.com A using 192.168.67.1
check: ✔️ nslookup success for example.com A using 172.27.64.1
wsl-vpnkit.exe: [INFO] Connected Ethernet interface f6:16:36:bc:f9:c6
wsl-vpnkit.exe: [INFO] UDP interface connected on 1.1.1.1
check: ✔️ nslookup success for example.com A using 1.1.1.1
wsl-vpnkit.exe: [INFO] Connected Ethernet interface f6:16:36:bc:f9:c6
wsl-vpnkit.exe: [INFO] UDP interface connected on 93.184.216.34
check: ✔️ ping success to IPv4 external host (example.com)
check: ✔️ nslookup success for example.com AAAA using 192.168.67.1
check: ✔️ nslookup success for example.com AAAA using 192.168.67.1
check: ✔️ nslookup success for example.com AAAA using 172.27.64.1
check: ✔️ nslookup success for example.com AAAA using 1.1.1.1
ping: sendto: Network unreachable
check: ➖ ping fail to IPv6 external host (example.com)
check: ✔️ wget success for https://example.com
wsl-vpnkit.exe: [INFO] Connected Ethernet interface f6:16:36:bc:f9:c6
wsl-vpnkit.exe: [INFO] UDP interface connected on 85.91.170.4

We can see check: ✔️ wget success for https://example.com but surfing on internet is, right now, impossible. My Windows is saying "No internet connection".

Back in an Ubuntu shell, I've fired "git pull" in an existing folder on my disk, he's still running (nothing happens). In another session, I've type "git clone xxx" (one of my repo) and nothing happens.

Back to an existing session, I run once more wsl.exe -d wsl-vpnkit tail -f /var/log/wsl-vpnkit.log and the output is the next one (I don't know if he's still busy on doing something, I keep the command running)

check: ✔️ nslookup success for example.com AAAA using 192.168.67.1
check: ✔️ nslookup success for example.com AAAA using 192.168.67.1
check: ✔️ nslookup success for example.com AAAA using 172.27.64.1
check: ✔️ nslookup success for example.com AAAA using 1.1.1.1
ping: sendto: Network unreachable
check: ➖ ping fail to IPv6 external host (example.com)
check: ✔️ wget success for https://example.com
wsl-vpnkit.exe: [INFO] Connected Ethernet interface f6:16:36:bc:f9:c6
wsl-vpnkit.exe: [INFO] UDP interface connected on 85.91.170.4
wsl-vpnkit.exe: [INFO] Hostnet_icmp 192.168.67.3 id=111 -> 93.184.216.34 id=0: expiring ICMP NAT rule`
```

Back again to my git clone session and now, I get "remote: the project you were looking for could not be found." (and this is not correct, the provided URL exists; no doubt).

My Windows is still saying "No internet connection" (and this is confirmed by Microsoft Teams running in background; I don't have internet, can't discuss with colleagues).

... and now without doing something, just wait a given time period (three minutes) ... it's works i.e. internet is back, Microsoft Teams is happy and my git clone is finally done with success.

I don't know if this can help to debug something but, thus, v2 didn't change something for me. Same behavior (I think) than with v3.

Have a nice day.

cavo789 avatar Sep 20 '22 09:09 cavo789

Closing due to inactivity.

sakai135 avatar Mar 18 '23 20:03 sakai135