0

I have a Raspberry Pi 4 running bookworm.

It has a cellular modem attached via USB (interface usb0)and a Wireless connection (interface wlan0).

The usb0 has a metric of 100 and the wlan0 a metric of 600. It appears because the usb0 has a lower metric I can not connect over LAN (wlan0) connection when the modem is active.

Guide I found talked about editing the /etc/dhcpcd.conf - but this file does not exist on newer versions of Rpi OS.

How can I set the wlan0 to have a lower metric?

5
  • Does this answer your question? How do I set up networking on Raspberry Pi OS - Bookworm
    – Milliways
    Jan 9 at 23:39
  • I tried nmcli connection usb0 down as a test - but it doesnt like the way I am putting the device in there despite what I see on the internet
    – Al Grant
    Jan 9 at 23:45
  • I can't find anything on routes either
    – Al Grant
    Jan 9 at 23:47
  • How do you run nmcli in interactive? Where is the Metric in Route in the GUI? I looked.
    – Al Grant
    Jan 10 at 0:23
  • To see what connections you've got use nmcli con show it will give you the names (usb0 is a device name). To see IPv4 and IPv6 addresses use ip a show. To see routes use ip r show. To set a metric to 300 use nmcli con modify <connection-name> ipv4.route-metric 300. With an appropriate modification to <connection-name>.
    – Dougie
    Jan 10 at 22:27

1 Answer 1

1

The command nmcli connection edit WiFi… puts you in interactive mode.

nmcli connection show will show you existing connections & what it chooses to call them (which is not standardised) e.g. if you preconfigure on the imager it is called preconfigured.

Under the networking icon select network Advanced Options Edit Connection ⚙︎, IPv4 Settings, Routes has an option to Add metric (you might want to ignore automatically obtained routes)

You can edit /etc/NetworkManager/system-connections/WiFi….nmconnection but I have not tried setting metric there and defaults are not shown.

I didn't say it was easy! NetworkManager can do practically anything BUT finding the right incantation is a bit hit & miss and I am still learning.

You can, of course select dhcpcd instead.


I have tried sudo nmcli connection modify 'WiFi…' ipv4.route-metric 50 which appears to work.

This sets in .nmconnection

[ipv4]
method=auto
route-metric=50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.