I have a small home server than I occasionally move between networks. I want it to have a static IP for accessing services running on it, but also a DHCP IP so that when I move networks it will always pick up a routable address.
My config looks like this so far:
network:
version: 2
renderer: NetworkManager
ethernets:
eno1:
dhcp4: yes
dhcp6: no
addresses:
- 192.168.188.2/24
gateway4: 192.168.188.1
nameservers:
addresses: [127.0.0.1, 1.1.1.1]
This does seem to work and I end up with two IP addresses on the same interface, in the same subnet.
I know that it is possible to set a priority using the metric
property. Is that possible with this set up? I would like the static IP to have priority. Does that even make any sense? I am unsure if "priority" makes any difference if they both have the same interface and gateway.
I have tried lowering the dchp priority with:
...
dhcp4-overrides:
route-metric: 200
But that seems to set the metric on both addresses:
❯ ip route
...
192.168.188.0/24 dev eno1 proto kernel scope link src 192.168.188.2 metric 200
192.168.188.0/24 dev eno1 proto kernel scope link src 192.168.188.228 metric 200
Is what I want to do possible? Does it even make sense?
Thanks!