1

I'm using the commands found in one of the answers to this question : How can I make changes to the network routing metric permanently

Before, I change the metric of the PPP0 device (3G UBlox modem) :

:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.137.1   0.0.0.0         UG    100    0        0 enxd037458b96e3
default         192.168.30.102  0.0.0.0         UG    101    0        0 eth0
default         10.64.243.222   0.0.0.0         UG    700    0        0 ppp0
10.64.243.222   0.0.0.0         255.255.255.255 UH    700    0        0 ppp0
83.173.68.204   192.168.137.1   255.255.255.255 UGH   0      0        0 enxd037458b96e3
192.168.30.0    0.0.0.0         255.255.255.0   U     101    0        0 eth0
192.168.137.0   0.0.0.0         255.255.255.0   U     100    0        0 enxd037458b96e3

Then I change the metric :

sudo nmcli connection modify '3G Mobile Connection' ipv4.route-metric 50
sudo nmcli connection up '3G Mobile Connection'

I print the routing table :

~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.137.1   0.0.0.0         UG    100    0        0 enxd037458b96e3
default         192.168.30.102  0.0.0.0         UG    101    0        0 eth0
default         10.64.73.112    0.0.0.0         UG    700    0        0 ppp0
10.50.0.1       0.0.0.0         255.255.255.255 UH    0      0        0 ppp1
10.64.73.112    0.0.0.0         255.255.255.255 UH    50     0        0 ppp0
83.173.68.204   192.168.137.1   255.255.255.255 UGH   0      0        0 enxd037458b96e3
192.168.30.0    0.0.0.0         255.255.255.0   U     101    0        0 eth0
192.168.137.0   0.0.0.0         255.255.255.0   U     100    0        0 enxd037458b96e3

As you can see, the default gateway metric associated to the PPP0 Iface is still at 700

I need to relaunch the up command :

sudo nmcli connection up '3G Mobile Connection'

So that the metric of the default route matches the one of the interface :

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.174.42.214   0.0.0.0         UG    50     0        0 ppp0
default         192.168.137.1   0.0.0.0         UG    100    0        0 enxd037458b96e3
default         192.168.30.102  0.0.0.0         UG    101    0        0 eth0
10.50.0.1       0.0.0.0         255.255.255.255 UH    0      0        0 ppp1
10.174.42.214   0.0.0.0         255.255.255.255 UH    50     0        0 ppp0
83.173.68.204   192.168.137.1   255.255.255.255 UGH   0      0        0 enxd037458b96e3
192.168.30.0    0.0.0.0         255.255.255.0   U     101    0        0 eth0
192.168.137.0   0.0.0.0         255.255.255.0   U     100    0        0 enxd037458b96e3

I tried to down/up the connection, but I still need to up it a second time. Restarting the Network Manager will make the PPP0 interface disappears, restarting the Modem Manager didn't fix it, only rebooting the system will put things back in order.

Why I want to do that ? I've already posted a question here https://serverfault.com/questions/1046629/how-to-find-the-route-that-has-internet-connection-and-set-it-as-default-lowest and here Use the internet access of another network interface when the main one is down related to keeping the system connected to internet. Network Manager will keep my system connected only if the cable of the ethernet interface (the one that has no more access to internet but still has the lowest metric) is unplugged, so NetworkManager will delete the default gateway associated to the NIC interface. In my case I can't unplug the cable, the embedded system in enclosed in a cabinet.

Interface bonding seems to be the ideal solution, but I don't have the kernel object "for now". UPDATE: no it doesn't support 3G modem devices, it works only with Ethernet stuff.

So, is it normal that I need to up the interface twice so the default route gets updated ?

1 Answer 1

2

I just tried that on my Linux Mint.

Metric by default: 100.

I used nmcli to change it to 50, then I disconnected, so the default route is removed. Then I reconnected, and I could see that the default route has now a metric of 50.

nmcli doesn't change the metric 'live', but only the property of the connection.

Also, once this property is defined in the connection, it will be applied the next times.

1
  • 1
    How to change it "live" then ?
    – Aminos
    Commented Sep 1, 2021 at 7:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .