Sample Header Ad - 728x90

How to get gateway information for both interface as gateway information shows as 0.0.0.0

0 votes
0 answers
785 views
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)
Asked by Ashish (1 rep)
Mar 30, 2018, 10:09 AM