I am having trouble getting a good mental map of how to configure netplan for a common network setup we are seeing.
- Two network interfaces
- Network interface A, connected to the internet on 10.0.1.40/24, assigned via DHCP
- Network interface B, connected to a network on 192.168.50.1/24 via 192.168.50.1/24 assigned a static IP (192.168.50.20/24)
Something like:
network:
version: 2
ethernets:
eno1:
dhcp4: yes
enp6s0f1:
dhcp4: no
addresses:
- 192.168.50.20/24
gateway4: 192.168.50.1
Seems like it should work, but after applying this, it seems that either
- The server loses internet access and somehow the static IP address has a lower priority than the dhcp interface? Is that possible?
- The server has network access, but cannot communicate with any of the devices on the
192.168.50.1/24
network (possibly using the wrong ethernet card).
FWIW, removing the non-dhcp interface from netplan and just using sudo ip addr add 192.168.50.20/24 dev eno2
"just works", however doesn't persist across reboots.
The final route table looks like this:
$ ip route
default via 192.168.50.1 dev enp6s0f1 proto dhcp src 192.168.50.11 metric 100
default via 10.1.10.1 dev eno1 proto dhcp src 10.1.10.178 metric 100
10.1.10.0/24 dev eno1 proto kernel scope link src 10.1.10.178
10.1.10.1 dev eno1 proto dhcp scope link src 10.1.10.178 metric 100
192.168.50.0/24 dev enp6s0f1 proto kernel scope link src 192.168.50.11
192.168.50.1 dev enp6s0f1 proto dhcp scope link src 192.168.50.11 metric 100
In this case, the 192.168.50.1
is the static network that does not have public internet access, but the 10.1.10.1
route is not used.