I have two network adapters . One is linked to the router ,and the other one is connected to ikuai. Now the default adapter is automatically configured to the router,but I’d like to connect to ikuai . I can’t change the setting until now .
Hi,
I was able to set my default network adapter from enp0s20 to enp0s18. I have changed the metric with nmcli.
OS Version: Home Assistant OS 11.2
Home Assistant Core: 2023.12.3
Here is what I did:
$ ssh ha
...
➜ ~ docker exec homeassistant ip route
default via 10.10.10.1 dev enp0s20 src 10.10.10.2 metric 100
default via 192.168.8.1 dev enp0s18 src 192.168.8.2 metric 101
default via 10.10.100.1 dev enp0s19 src 10.10.100.2 metric 102
10.10.10.0/24 dev enp0s20 scope link src 10.10.10.2 metric 100
10.10.100.0/24 dev enp0s19 scope link src 10.10.100.2 metric 102
172.30.32.0/23 dev hassio scope link src 172.30.32.1
172.30.232.0/23 dev docker0 scope link src 172.30.232.1
192.168.8.0/24 dev enp0s18 scope link src 192.168.8.2 metric 101
➜ ~ nmcli con sh --active
NAME UUID TYPE DEVICE
Supervisor enp0s18 x ethernet enp0s18
Supervisor enp0s19 y ethernet enp0s19
Supervisor enp0s20 z ethernet enp0s20
➜ ~ nmcli connection modify "Supervisor enp0s20" ipv4.route-metric 103
➜ ~ nmcli connection modify "Supervisor enp0s20" ipv6.route-metric 103
➜ ~ nmcli connection up "Supervisor enp0s20"
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
Reboot HA.
$ ssh ha
...
➜ ~ docker exec homeassistant ip route
default via 192.168.8.1 dev enp0s18 src 192.168.8.2 metric 100
default via 10.10.100.1 dev enp0s19 src 10.10.100.2 metric 101
default via 10.10.10.1 dev enp0s20 src 10.10.10.2 metric 103
10.10.10.0/24 dev enp0s20 scope link src 10.10.10.2 metric 103
10.10.100.0/24 dev enp0s19 scope link src 10.10.100.2 metric 101
172.30.32.0/23 dev hassio scope link src 172.30.32.1
172.30.232.0/23 dev docker0 scope link src 172.30.232.1
192.168.8.0/24 dev enp0s18 scope link src 192.168.8.2 metric 100
On the UI (Settings → System → Network → Network adapter) I can see the change as well.
This is slightly offtopic for the original question, but shows how you can still use nmcli in HA 2024.11.2.
I know using nmcli is no longer supported or advised. I just wanted to leave this here for any unfortunate soul that ended up in the same predicament as me.
A few years ago I used the nmcli command to add a persistent route to my HA installation. Today, I wanted to remove this persistent route and found out I couldn’t because PR#761 removed networkmanager-cli. So I was stuck.
To fix it, I did this in the Advanced SSH & Web Terminal: