Test connectivity of a Interface

ethernetnetworking

I have a raspberry Pi with three interfaces eth0 (Ethernet), wlan0 (WiFi), and wwan0 (via a GSM modem)

How can I test if an Internet connection is available via a certain interface? e.g. is my GSM(wwan0) modem connected to the Internet?

If I attempt to run ping www.google.com – How do I know what interface is being used?

How can I force connectivity via a certain interface if more than one exist?

Best Answer

How can I test if an Internet connection is available via a certain interface? e.g. is my GSM(wwan0) modem connected to the Internet? If I attempt to run ping www.google.com - How do I know what interface is being used?

You could specify the interface.

ping -I $INTERFACE $DOMAIN_OR_IP_ADDRESS

e.g:

ping -I wwan0 8.8.4.4

Using a known IP address will eliminate any potential DNS issues while troubleshooting.

How can I force connectivity via a certain interface if more than one exist?

You can set the default route. Static addressing with Debian, right? Open /etc/network/interfaces with a text editor. Find the desired network interface and add the option gateway x.x.x.x, where x.x.x.x is the gateway. Save and restart networking:

/etc/init.d/networking restart

Otherwise, I believe one would need to use more advanced policy-based routing for this.

Related Question