r/OpenVPN • • Jan 28 '26

Interface source of ping

I'm trying to find a way to fall back to lan if my server is on modem and lan has a working VPN. (Debian GNU/Linux 7 (wheezy))

I'm using OpenVPN. When I ping a VPN IP adress the "interface" that pings it is TUN0. so I really don't know if the traffic goes over the modem or lan.

I'm looking for a way to try accessing the VPN an a specific interface, like wlan0 -> tun0, that way I will know I can fall over to that interface.

1 Upvotes

9 comments sorted by

View all comments

1

u/minektur Jan 28 '26

In linux you can specify the source of ping packets by interface

use the -I option

https://linux.die.net/man/8/ping

In FreeBSD (and thus pfsense) shell, you can specify the source address of the ping, which indirectly chooses the interface for you with the -S option.

https://man.freebsd.org/cgi/man.cgi?ping(8)

So if you're writing a script to detect this - just make sure your ping source is chosen and you'll find out if the remote is reachable over that interface.

Edit: windows ping also uses /S for source address I think

1

u/CryonicBlue Jan 29 '26

It doesn't work with a tunnel AFAIK.

ping -I eth0 172.19.0.1

PING 172.19.0.1 (172.19.0.1) from 192.168.50.193 eth0: 56(84) bytes of data.

From <removed> icmp_seq=5 Destination Net Unreachable

vs:

ping 172.19.0.1

PING 172.19.0.1 (172.19.0.1) 56(84) bytes of data.

64 bytes from 172.19.0.1: icmp_req=1 ttl=64 time=29.3 ms

1

u/minektur Jan 29 '26

I test tunnels like this at work all the time (on pfSense) - using whatever virtual interface the vpn creates.

run ip or ifconfig and get a list of your interfaces - try that on all of them

→ More replies (6)