0

I have two interfaces with me as eth0 and wwan0. My both the interfaces have internet connectivity. But in my use case, I can plug and unplug any interface from my system. Ideally as soon I plug it again, if I add the gateway to route, my internet connection will resume.

The problem here is that I always get information about default gateway only.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.2.1     0.0.0.0         UG    0      0        0 eth0
8.8.8.8         192.168.2.1     255.255.255.255 UGH   0      0        0 eth0
10.177.88.96    *               255.255.255.240 U     0      0        0 wwan0
59.144.127.17   192.168.2.1     255.255.255.255 UGH   0      0        0 eth0
192.168.0.0     *               255.255.252.0   U     0      0        0 eth0
192.168.2.1     *               255.255.255.255 UH    0      0        0 eth0 

Here, I have the gateway for eth0 but gateway information for wwan0 is 0.0.0.0.

Setup: I am having two interfaces as eth0 and wwan0. Both are having internet connectivity.

Problem: Out of these two interfaces, I can ping only via one interface. I can ping only through the interface which is by default. Now to ping through another interface, I try to add the gateway to route and it works fine with this command

route add default gw " + GW + wwan0/eth0 --> Depeneds on which one is not pinging
In my route table for the interface which is not pinging, gateway information is 0.0.0.0. I am getting gateway information to add manually from dhcp.lease file but I need gateway information on fly so that via some script, I can achieve the same.

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.2.1     0.0.0.0         UG    0      0        0 eth0
8.8.8.8         192.168.2.1     255.255.255.255 UGH   0      0        0 eth0
10.177.88.96    *               255.255.255.240 U     0      0        0 wwan0
59.144.127.17   192.168.2.1     255.255.255.255 UGH   0      0        0 eth0
192.168.0.0     *               255.255.252.0   U     0      0        0 eth0
192.168.2.1     *               255.255.255.255 UH    0      0        0 eth0
192.168.42.0    *               255.255.255.0   U     0      0        0 wlan0

ip route

default via 192.168.2.1 dev eth0
8.8.8.8 via 192.168.2.1 dev eth0
10.177.88.96/28 dev wwan0  proto kernel  scope link  src 10.177.88.104
59.144.127.17 via 192.168.2.1 dev eth0
192.168.0.0/22 dev eth0  proto kernel  scope link  src 192.168.2.166
192.168.2.1 dev eth0  scope link
192.168.42.0/24 dev wlan0  proto kernel  scope link  src 192.168.42.1

Ifconfig -a

eth0      Link encap:Ethernet  HWaddr 70:B3:D5:9A:EF:FC
          inet addr:192.168.2.166  Bcast:192.168.3.255  Mask:255.255.252.0
          inet6 addr: fe80::72b3:d5ff:fe9a:effc%1995519696/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15380 errors:0 dropped:0 overruns:0 frame:0
          TX packets:269 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1866379 (1.7 MiB)  TX bytes:27888 (27.2 KiB)

wwan0     Link encap:Ethernet  HWaddr 00:1E:10:1F:00:00
          inet addr:10.177.88.104  Bcast:10.177.88.111  Mask:255.255.255.240
          inet6 addr: fe80::21e:10ff:fe1f:0%1995519696/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:38 errors:0 dropped:0 overruns:0 frame:0
          TX packets:156 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6682 (6.5 KiB)  TX bytes:16247 (15.8 KiB)
  • You can't have a default gateway for two interfaces. You can split your traffic between both interfaces using various criteria, but in general, it's not possible to use two (or more) connections to the internet at the same time. (This is a FAQ, and has already been asked often). – dirkt Mar 30 '18 at 16:50
  • But how can I priority always Ethernet connection over Cellular, when both are up? Updating matric doesn't work in my system. I am using Yocto base with Kernel version 4.9 – Ashish Apr 4 '18 at 9:26
  • You need to set your default gateway when the state of the interfaces change. In particular as probably both will get information via DHCP, which will set the gateway (and probably not the way you want). – dirkt Apr 4 '18 at 15:17
  • Here user will get connectivity either from Ethernet or cellular but my problem is that, if I try to ping from ethernet interface and if that's successful I can not ping through cellular. If as a developer I can ping both of them with -I option, I can do some kind of calculation to always give priority to ethernet. – Ashish Apr 5 '18 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.