Cannot set custom DNS servers and use DHCP in 20.04 Kubuntu

Bug #1886768 reported by Dan
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Netplan
New
Undecided
Unassigned

Bug Description

I am only able to set custom DNS servers using the /etc/netplan/01-network-manager-all.yaml if i use the configuration below with a static IP address:

d@a:~$ more /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  wifis:
    wlp3s0:
      dhcp4: false
      addresses: [10.0.0.49/24]
      gateway4: 10.0.0.1
      access-points:
        accesspointename:
          password: passwordgoeshere
      nameservers:
        addresses: [8.8.4.4,8.8.8.8,1.1.0.0,1.1.1.1]

The configuration above works, Network Manager restarts after issuing sudo netplan --debug apply, there is a new connection that is created with the same name as my original access point but prepended with netplan-wlp3s0.

I would like not to use a static IP address. When i try the below configuration to set custom DNS servers and have DHCP enabled. No new connection is created and the original one has the service providers DNS servers.

d@a:~$ more /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  wifis:
    wlp3s0:
      dhcp4-overrides:
        use-dns: no
      access-points:
        accesspointname:
          password: passwordgoeshere
      nameservers:
        addresses: [8.8.4.4,8.8.8.8,1.1.0.0,1.1.1.1]

d@a:~$ sudo netplan --debug apply
** (generate:11280): DEBUG: 22:03:24.251: Processing input file /etc/netplan/01-network-manager-all.yaml..
** (generate:11280): DEBUG: 22:03:24.251: starting new processing pass
** (generate:11280): DEBUG: 22:03:24.251: wlp3s0: adding wifi AP 'accesspointname'
** (generate:11280): DEBUG: 22:03:24.252: We have some netdefs, pass them through a final round of validation
** (generate:11280): DEBUG: 22:03:24.252: wlp3s0: setting default backend to 2
** (generate:11280): DEBUG: 22:03:24.252: Configuration is valid
** (generate:11280): DEBUG: 22:03:24.252: Generating output files..
** (generate:11280): DEBUG: 22:03:24.252: networkd: definition wlp3s0 is not for us (backend 2)
(generate:11280): GLib-DEBUG: 22:03:24.252: posix_spawn avoided (fd close requested)
DEBUG:no netplan generated networkd configuration exists
DEBUG:netplan generated NM configuration changed, restarting NM
DEBUG:wlp3s0 not found in {}
DEBUG:Merged config:
network:
  bonds: {}
  bridges: {}
  ethernets: {}
  vlans: {}
  wifis:
    wlp3s0:
      access-points:
        accesspointname:
          password: passwordgoeshere
      dhcp4-overrides:
        use-dns: false
      nameservers:
        addresses:
        - 8.8.4.4
        - 8.8.8.8
        - 1.1.0.0
        - 1.1.1.1

DEBUG:Skipping non-physical interface: lo
DEBUG:Skipping non-physical interface: enp0s25
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp0s25
DEBUG:netplan triggering .link rules for wlp3s0

How can i keep DHCP on and use custom DNS servers?

Thanks

Revision history for this message
Dan (codecando-x) wrote :

Someone on a different forum suggested i use this configuration:

network:
  version: 2
  renderer: NetworkManager
  wifis:
    wlp3s0:
      dhcp4: true
      access-points:
        accesspointgoeshere:
          password: passwordgoeshere
      nameservers:
        addresses: [8.8.4.4,8.8.8.8,1.1.0.0,1.1.1.1]

However then when i run: nmcli dev show | grep DNS
The service providers DNS servers are before the custom ones i have defined:

IP4.DNS[1]: 75.75.75.75
IP4.DNS[2]: 75.75.76.76
IP4.DNS[3]: 8.8.4.4
IP4.DNS[4]: 8.8.8.8
IP4.DNS[5]: 1.1.0.0
IP4.DNS[6]: 1.1.1.1

I could do it all in Network Manager, i am however looking for a config file solution so that i can script it.

Does netplan support this configuration?

Thanks

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.