Since the mailing list is gone, I’m not sure if this is the right place, but thought I would try it anyway
We have an embedded system with a wired network. We want to have a fixed IP, but also run DHCP client so that if there is a DHCP server running it will use both.
I have this section in my .nmconnection, and that mostly works: If there’s a DHCP connection it will happily use both addresses.
[ipv4]
address1=10.20.30.40/24
method=auto
BUT: if there is no response from the DHCP requests, the connection goes in DISCONNECTED state and will also drop the static IP. While the connection is yellow in “nmcli conn show” the Static IP is still there, but once the max retries have been reached it will just stay DISCONNECTED.
autoconnect-retries=0
works in the sense that it will stay in this loop forever, but it means that I drop the connection every “dhcp-timeout” seconds. File transfers that are ongoing during that reconnect phase are dropped, so it’s not really an option.
# journalctl -b | grep NetworkManager.*CONN
Feb 20 16:32:32 imx8 NetworkManager[568]: <info> [1676910752.6570] manager: NetworkManager state is now CONNECTING
Feb 20 16:33:17 imx8 NetworkManager[568]: <info> [1676910797.5604] manager: NetworkManager state is now DISCONNECTED
Feb 20 16:33:17 imx8 NetworkManager[568]: <info> [1676910797.6425] manager: NetworkManager state is now CONNECTING
Feb 20 16:34:02 imx8 NetworkManager[568]: <info> [1676910842.5618] manager: NetworkManager state is now DISCONNECTED
Feb 20 16:34:02 imx8 NetworkManager[568]: <info> [1676910842.6426] manager: NetworkManager state is now CONNECTING
Feb 20 16:34:47 imx8 NetworkManager[568]: <info> [1676910887.5589] manager: NetworkManager state is now DISCONNECTED
Cloning the connection and giving it a lower priority and method=static seems like it could work, but that’s kind of silly - and I have 2 sets of values to keep in sync.
Is there a sensible solution that “just works” in the sense that:
- If there is a DHCP server on the network, my connection stays like
user@imx8:~$ ip -4 a show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet 10.20.30.40/24 brd 10.20.30.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet 192.168.0.10/24 brd 192.168.0.255 scope global dynamic noprefixroute eth0
valid_lft 86389sec preferred_lft 86389sec
- if there is no DHCP server on the network, my connection stays like:
user@imx8:~$ ip -4 a show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet 10.20.30.40/24 brd 10.20.30.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever