I'm using fresh Ubuntu Server 18.10 (Cosmic) installation with netplan. What I'm trying to achieve is to setup network interface via DHCP and add some static routes.
With static IP settings things are working correctly. With DHCP 'routes:' are not applied
Any ideas how to change that?
Commands used to apply settings:
netplan generate
netplan applyWORKS
network: ethernets: enp0s3: addresses: [] dhcp4: true dhcp6: true enp0s8: dhcp4: false addresses: - 192.168.1.10/24 routes: - to: 10.10.0.0/24 via: 192.168.1.2 - to: 10.9.0.0/24 via: 192.168.1.2 version: 2DOES NOT WORK
network: ethernets: enp0s3: addresses: [] dhcp4: true dhcp6: true enp0s8: dhcp4: true # <- CHANGED addresses: [] # <- CHANGED routes: - to: 10.10.0.0/24 via: 192.168.1.2 - to: 10.9.0.0/24 via: 192.168.1.2 version: 2EDIT: [20.12.2018]: After new research I was able to find that my issue is an animal (a bug to be specific).
52 Answers
After new research I was able to find that my issue is an animal (a bug to be specific).
Routes are applied before DHCP, which destroys them.
Try this... (keep the indentation and spacing as it is)...
network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: true dhcp6: true addresses: [] enp0s8: dhcp4: true addresses: [] routes: - to: 10.10.0.0/24 via: 192.168.1.2 - to: 10.9.0.0/24 via: 192.168.1.2Then...
sudo netplan --debug generate # generate config files
sudo netplan apply # apply configuration
reboot # reboot and confirm proper operation
Update #1:
Because of the bugs that you found, try this...
Name the only existing .yaml file as 01-dhcp.yaml and include this text...
network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: true dhcp6: true addresses: [] enp0s8: dhcp4: true addresses: [] gateway4: 10.x.x.1 <-adjust this address for your environment optional: true <-don't wait for connection, try with/without thisThen create a second .yaml file called 02-routes.yaml with this text...
network: version: 2 renderer: networkd ethernets: enp0s8: dhcp4: false <-disable dhcp this time around addresses: [] <-this MAY need to be removed routes: - to: 10.10.0.0/24 via: 192.168.1.2 - to: 10.9.0.0/24 via: 192.168.1.2sudo netplan --debug generate # generate config files
sudo netplan apply # apply configuration
reboot # reboot and confirm proper operation