Netplan on Ubuntu 18.10 (Cosmic Cuttlefish): DHCP4 + static routes

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 apply

WORKS

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: 2

DOES 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: 2

EDIT: [20.12.2018]: After new research I was able to find that my issue is an animal (a bug to be specific).

5

2 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.2

Then...

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 this

Then 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.2

sudo netplan --debug generate # generate config files

sudo netplan apply # apply configuration

reboot # reboot and confirm proper operation

8

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like