Random debugging: can’t connect to host on the same VPN

In order to be able to access my home network from outside, I have this setting:

  • I have a VPS, which runs the OpenVPN service (and the IP address is 10.8.0.1)
  • A Raspberry Pi at home, that always connect to the VPN (and it has IP address 10.8.0.22)
  • And when I need to access my home network, I’ll connect my laptop to the same VPN, then either ssh or VNC into the Pi, and do things.

This morning, I was staying at the local library. After I connected to the VPN, I couldn’t access my Pi at all, the attempt to connect simply timed out. And:

  • I could access the VPS using 10.8.0.1
  • From the VPS, I could access my Pi using 10.8.0.22
  • On the Pi, everything seemed to work OK, e.g., curl ifconfig.io would show the public IP of my VPS.
  • And I could access other websites fine.

(I wasted some time here, as the WiFi wasn’t stable at some spots, I tried moving around and disconnecting/reconnecting multiple times, until I realized it’s time to open the tools to investigate.)

First, I opened Wireshark, and selected the interface for the VPN. If I tried to access some (http) website, the packets were captured and displayed properly. However, the attempt to connect to Pi didn’t go through this interface at all. Instead, it went through the WiFi interface.

So it’s a routing issue. ipconfig gave:

Maybe the 255.255.255.252 mask was the culprit? A quick search said no.

The I checked route print, and:

So the 3rd line was the problem. The system thought my Pi was on the WLAN, not the VPN.

The fix was easy, just need to manually change the Netmask to 255.255.0.0.

Extra: port forwarding issue

My router at home allows port forwarding. It stopped working for my Pi. After some digging with tcpdump and port scanner, I found:

  • The wlan0 would get 179.10.75.34.bc.googleusercontent.com.44726 > 192.168.1.5.8083: Flags [S]
  • But the response was attempted through tun0: 192.168.1.5.8083 > 179.10.75.34.bc.googleusercontent.com.44726: Flags [S.]

So again problem with route table:

For now, I’m happy with the finding, will leave it to another day for an actual solution.

Leave a comment

Your email address will not be published. Required fields are marked *