I have a fresh install of ubuntu server 17.10, however the problem may affect previous versions, but this is the first time I have encountered this situation.
The server is running 2 separate network cards, one for internal local network communications (trusted), the other is a public (untrusted) connection to the internet with the ISP.
In the past, I have always configured the internal connection as static, and without a default gateway, as the external card would be provided via DHCP from my ISP (static lease).
/etc/netplan/00-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses: [192.168.1.xx/24]
nameservers:
addresses: [8.8.8.8,8.8.4.4]
eth1:
dhcp4: yes
dhcp6: no
Now this worked fine as I did not provide a gateway4 line in the eth0 configuration so it bound the default gateway from the ISP and worked fine.
I have since decided I wanted to use static leases for the server(s) in my homelab, and have configured as such on the internal router. But when I set up the netplan config as dhcp for both devices, it adds the default gateway for both interfaces (which makes sense because both DHCP servers are providing a gateway).
> route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 eth0
0.0.0.0 173.xxx.xxx.1 0.0.0.0 UG 100 0 0 eth1
173.xxx.xxx.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
173.xxx.xxx.1 0.0.0.0 255.255.255.255 UH 100 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.1 0.0.0.0 255.255.255.255 UH 100 0 0 eth0
How can I setup netplan so the eth0 adapter (internal) to disregard the default gateway provided by the DHCP server (without removing the gateway on the DHCP server itself as other machines still need a default gateway).
Best Answer
Netplan v0.90 introduces a new set of options:
dhcp4-overrides
(pull request).So, if your version of the
netplan.io
package is new enough (see available versions here), you can use this: