Score:0

Set default interface for Internet Access

cg flag

I have 4 Huawei USB modems one ethernet interface. ethernet port has internet access and the modem is only used for its SIM. This created problems while accessing the internet. ubuntu is trying to access the internet using USB modems instead of ethernet ports.

What I tried before

bridging connection using bridge-utils

manually setting metrics to interface

route del default gw route add default gw

None of the above worked. I am using ubuntu 20 cli.

IP Addr

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 18:03:73:b6:f1:9e brd ff:ff:ff:ff:ff:ff
    altname enp0s25
    inet 192.168.1.201/24 brd 192.168.1.255 scope global dynamic noprefixroute eno1
       valid_lft 449sec preferred_lft 449sec
    inet6 fe80::a0b1:e67f:5aad:4306/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: enx582c80139263: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
    link/ether 58:2c:80:13:92:63 brd ff:ff:ff:ff:ff:ff
    inet 192.168.9.100/24 brd 192.168.9.255 scope global dynamic noprefixroute enx582c80139263
       valid_lft 84765sec preferred_lft 84765sec
    inet6 fe80::5154:9077:c55:80e8/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
4: enx52bcf381a41c: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:bc:f3:81:a4:1c brd ff:ff:ff:ff:ff:ff
    inet 192.168.5.100/24 brd 192.168.5.255 scope global dynamic noprefixroute enx52bcf381a41c
       valid_lft 84802sec preferred_lft 84802sec
    inet6 fe80::39a6:f0ea:f120:d4a0/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
7: enx9ac29bee4cd9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 9a:c2:9b:ee:4c:d9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.7.100/24 brd 192.168.7.255 scope global dynamic noprefixroute enx9ac29bee4cd9
       valid_lft 84739sec preferred_lft 84739sec
    inet6 fe80::2530:a4db:74d1:9739/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
8: br0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether c2:a3:67:53:c4:56 brd ff:ff:ff:ff:ff:ff
9: enxc271b7f9e4f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether c2:71:b7:f9:e4:f6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.6.100/24 brd 192.168.6.255 scope global dynamic noprefixroute enxc271b7f9e4f6
       valid_lft 84704sec preferred_lft 84704sec
    inet6 fe80::fd92:2ab6:f154:c755/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
10: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
    link/ether 58:2c:80:13:92:63 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.100/24 brd 192.168.10.255 scope global dynamic noprefixroute eth0
       valid_lft 81427sec preferred_lft 81427sec
    inet6 fe80::29d:8f26:1370:75b7/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

Ip route

default via 192.168.1.1 dev eno1 
default via 192.168.1.1 dev eno1 proto dhcp metric 50 
169.254.0.0/16 dev eno1 scope link metric 50 
192.168.1.0/24 dev eno1 proto kernel scope link src 192.168.1.201 metric 50 
192.168.1.0/24 dev eno1 proto kernel scope link src 192.168.1.201 metric 104 
192.168.5.0/24 dev enx52bcf381a41c proto kernel scope link src 192.168.5.100 metric 109 
192.168.6.0/24 dev enxc271b7f9e4f6 proto kernel scope link src 192.168.6.100 metric 106 
192.168.7.0/24 dev enx9ac29bee4cd9 proto kernel scope link src 192.168.7.100 metric 107 
192.168.9.0/24 dev enx582c80139263 proto kernel scope link src 192.168.9.100 metric 108 
192.168.10.0/24 dev eth0 proto kernel scope link src 192.168.10.100 metric 105

IP neigh

1.1.1.1 dev eno1  FAILED
192.168.1.1 dev eno1 lladdr 48:8f:5a:a4:5d:db REACHABLE
192.168.1.243 dev eno1 lladdr f4:8e:38:91:d6:b4 STALE
192.168.5.1 dev enx52bcf381a41c lladdr 00:0d:87:8e:4b:ac REACHABLE
192.168.7.1 dev enx9ac29bee4cd9 lladdr 00:0d:87:8e:4b:ac REACHABLE
192.168.10.1 dev eth0 lladdr 58:2c:80:13:92:08 REACHABLE
192.168.6.1 dev enxc271b7f9e4f6 lladdr 00:0d:87:8e:4b:ac STALE
192.168.9.1 dev enx582c80139263 lladdr 58:2c:80:13:92:08 REACHABLE
192.168.1.200 dev eno1 lladdr 98:90:96:a7:61:45 STALE
8.8.8.8 dev eno1  FAILED
uz flag
Jos
Turn off the DHCP servers on the routers.
Omeed Totakhel avatar
cg flag
@Jos USB modems do not take IP from DHCP and they reset themself whenever the PC restarts
netbat avatar
br flag
Do you have 4 USB modems connected simultaneously to Ubuntu PC and one Ethernet interface with cable connection to Internet? For what networks or addresses do you use the modems? Please, paste here at end of your question the output of these commands: `ip route` and `ip addr` and `ip neigh`. It looks like a routing priority/metric problem or a multiple default route collision.
Omeed Totakhel avatar
cg flag
@netbat Yes all 4 USB modems are connected simultaneously. I am accessing Sim's card through the modem.
netbat avatar
br flag
Please, check the settings by my last recommendations. I found some issues in your network.
Score:0
br flag

There are some issues in your network:

Issue #1

Some routes are duplicated/doubled with different metrics:

default via 192.168.1.1 dev eno1 
default via 192.168.1.1 dev eno1 proto dhcp metric 50 

192.168.1.0/24 dev eno1 proto kernel scope link src 192.168.1.201 metric 50 
192.168.1.0/24 dev eno1 proto kernel scope link src 192.168.1.201 metric 104 

There is an issue concerning doubled or overlapped network setting in your PC. It seems you have two settings of the eno interface. I suppose that the first route is assigned by a configuration file in your PC and the second route is assigned dynamically by a DHCP server. Check the situation and either set address manually and ensure the eno will NOT ask the DHCP server for address (e.g. Dhcp4: no in netplan setting) or remove manual address setting and use the dynamic assignment provided by the DHCP server.

For sure search in your configuration files which are concerned eno1 and its address 192.168.1.1. Remove duplicate parts in configuration if you find it. Check you are successful and that the duplicate routes disappear after you restart your computer.

You can use following commands for searching of critical configuration files (step by step, not all at once):

sudo grep -Rl "eno1"      /etc
sudo grep -R  "eno1"      /etc
sudo grep -Rl "192.168.1" /etc
sudo grep -R  "192.168.1" /etc
  • -Rl option will list file names
  • -R option will show lines containing searched text strings

Issue #2

What interface do you want to use as the main gateway to the Internet? The eno or eth0?

If the eth0 should be main GW then the setting is wrong. In that case you must delete the default GW from the eno and set the new one to eth0.

You cannot use both the eno and the eth0 as a gateway to Internet simultaneously (excluding very special setting which uses multiple routing tables configured using iproute2).

Issue #3

Your current default GW is reachable, but it does not seem to be a real gateway. The IP address 192.168.1.1 is available on the network via the eno interface (see the REACHABLE tag in your ip neigh output). However, if a packet destined for the IP address 8.8.8.8 is sent via the default GW, the device with the address 192.168.1.1 will not forward the packet outside as a router. Instead, it answers 'Address 8.8.8.8 is not mine.' A real router must not do that.

Verify that the device having the 192.168.1.1 address is router and it is capable to forward packets outside to WAN network. Or remove default route pointing to the 192.168.1.1 device and set new one as recommended above in Issue #2.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.