Ricbot network issues

From Rsewiki

Back to Ricbot

Network Manager

Just a summary of some items found on the internet.

Set Wi-Fi as default route

On robots with a cabled local network without internet access, it is annoying that the wifi connection is not the default route for, e.g., updating the operating system.

See the default connection, like:

ip route
default via 192.168.7.6 dev eth0 proto dhcp src 192.168.7.22 metric 52 
default via 10.197.208.1 dev wlan0 proto dhcp src 10.197.215.135 metric 600 
10.197.208.0/21 dev wlan0 proto kernel scope link src 10.197.215.135 metric 600 
192.168.7.0/24 dev eth0 proto kernel scope link src 192.168.7.22 metric 52 

Here, the default is 192.168.7.6, the wired connection without internet access.

Solution

This can be fixed by using connection metrics. A low metric is the preferred connection.

Need a package:

sudo apt install ifmetric

Get the connection names

nmcli c
NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  80468912-0922-305a-b845-e038e6a97530  ethernet  eth0   
DTUdevice           40daedca-0933-4103-87b9-e481d6db6fa4  wifi      wlan0  
lo                  8de6fa00-08f6-4e2d-8251-9db7c4107077  loopback  lo     
mje6                3469ffdb-50a9-4af4-ac8d-2dd6bf1680ab  wifi      --    

The first column is the name. Remember to escape any spaces.

Then change the metric for the cabled network - with a high metric

sudo nmcli c mod Wired\ connection\ 1 ipv4.route-metric 52

And the same for the Wi-Fi network - with a lower metric

sudo nmcli c mod DTUdevice ipv4.route-metric 22
sudo nmcli c mod mje6 ipv4.route-metric 23

Restart NetworkManager

sudo systemctl restart NetworkManager.service

Check default connection with

ip route
default via 10.197.208.1 dev wlan0 proto dhcp src 10.197.215.135 metric 24 
10.197.208.0/21 dev wlan0 proto kernel scope link src 10.197.215.135 metric 24 
192.168.7.0/24 dev eth0 proto kernel scope link src 192.168.7.4 metric 56 

Now the default is wlan0, with the best metric.