My pi is connected to my home router using wlan0, and have access to internet successfully
When I plug my pi with an Ethernet cable, connected to other router, not connected to internet, I cant ping anymore with answer "Destination Net Unreachable"
pi@bar:~ $ sudo ping -c 1 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.100.1 icmp_seq=1 Destination Net Unreachable
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
If I ping using wlan0 it succeed:
pi@bar:~ $ sudo ping -c 1 -I wlan0 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 192.168.1.151 wlan0: 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=40 time=83.7 ms
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 83.748/83.748/83.748/0.000 ms
My routing table:
pi@bar:~ $ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.100.1 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
So obviously eth0 is prioritize over wlan0, and with no internet access it cannot find 8.8.8.8.
How can I solve this problem? I want that any app (ping, curl whatever) will be able to reach internet, even if one of the interfaces (wlan0, eth0 or any other) is connected to a router with dead end?
cheers, Bar
route -n
you will see ametric
. This is the priority. You can specify parameters likepriority=1
inetc/wpa_supplicant/wpa_supplicant.conf
to specify priority between WiFi networks. You can also influence metrics, but I do not recall how.