Set default network adapter manually

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 .

HA is a VM running in esxi.
Ha OS 2023.10

Until now?

So now you can?

IIRC, all you need to do is go to Settings → System → Network and remove the DNS server for the adaptor you don’t want to rout over.

1 Like

Ahh,but HA doesn’t allow me to save without DNS server.

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.

1 Like

Not working, i get:

Warning: nmcli (1.46.0) and NetworkManager (1.44.2) versions don't match. Restarting NetworkManager is advised.
Error: Failed to modify connection 'Supervisor enp0s18': connection.autoconnect-ports: unknown property

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:

cd /tmp
wget http://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/libnm-1.44.4-r0.apk
wget http://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/networkmanager-1.44.4-r0.apk
wget http://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/networkmanager-cli-1.44.4-r0.apk
wget http://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/networkmanager-common-1.44.4-r0.apk
apk add networkmanager-1.44.4-r0.apk networkmanager-cli-1.44.4-r0.apk networkmanager-common-1.44.4-r0.apk libnm-1.44.4-r0.apk
nmcli con modify "HassOS default" -ipv4.routes "172.22.100.0/24 192.168.29.9"

I still got a warning about mismatched versions 1.44.4 vs 1.44.2, but now at least there was no unknown property stopping the command.

So if you really really need to use nmcli, it’s possible. Hope that helps someone.

1 Like

The apk add command returned an Unverified Signature error for me.

I was able to get it working by:

  1. Replacing the /etc/apk/repositories file with the 3.19 repo:
https://dl-cdn.alpinelinux.org/alpine/v3.19/main
https://dl-cdn.alpinelinux.org/alpine/v3.19/community
  1. Run apk update
  2. Then simply run apk add networkmanager-cli which installed the 1.44.4 nmcli
1 Like

The only solution that works long term for me and is scalable to future releases of HASS is to set the default interface as static and give it a default gateway, then create DHCP reservations/static mappings for the affected VLANs/interfaces without a default gateway, this way HASS wont be able to assume those interfaces as the default ones.
Nothing else worked for me, i was able to get temporarily the correct interface as default because i have HASS virtualized but after a while it just insisted on using the other interfaces as the default ones, killing remote access for me.