2

I am trying to set up Ubuntu 18.04 LTS, which appears to be using netplan to configure networking. In this case I need to override the DNS servers provided by DHCP and use manually assigned nameservers. So I modified the netplan configuration as follows:

# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp2s1:
      dhcp4: yes
      dhcp4-overrides:
        use-dns: false
      dhcp6: yes
      dhcp6-overrides:
        use-dns: false
      nameservers:
        addresses: ["fd35:2ff0:b0b9:d0c0::1:1", 192.168.255.17]

In another question, and on netplan.io, it was explained that netplan had options dhcp4-overrides and dhcp6-overrides which would permit this, but these don't appear to work. netplan generate or netplan apply gives the error:

Error in network definition //etc/netplan/01-netcfg.yaml line 6 column 6: unknown key dhcp4-overrides

How, then, can I be sure that my specified nameservers will be used, and the nameservers obtained from DHCP will never be used? I'm willing to toss netplan in the bin if necessary.

2

dhcp4-overrides requires netplan 0.95 or later, which is not yet available in Ubuntu 18.04. See https://bugs.launchpad.net/netplan/+bug/1759014 for the status of this stable update.

0

I'm about halfway to throwing netplan in the bin, but I have a workaround that appears to work.

Seeing that it was rendering to networkd, and that systemd-resolved was handling DNS, I just created the relevant configuration directly.

I dropped the dhcp overrides bits from netplan, leaving me with only:

# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp2s1:
      dhcp4: yes
      dhcp6: yes

Then I created a file /etc/systemd/resolved.conf.d/dns.conf to specify the DNS servers I needed:

[Resolve]
DNS=fd35:2ff0:b0b9:d0c0::1:1 192.168.255.17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.