How to update entries in /etc/resolv.conf

I am using ubuntucore, I want to configure nameservers in /etc/resolv.conf. Configuring with “console-conf” does not allow you to set nameservers and hence will be picked from dhcp only, I want to add more nameservers with dhcp configuration.

Editing any config file (for example /etc/dhcp/dhclient.conf, /etc/resolvconf/resolv.conf.d/base) is also not possible since it’s a read only file system. I tried stopping and disabling systemd-resolved service but still no luck on reboots.

I can manually add nameservers entry in the config file (/etc/netplan/00-snapd-config.yaml) but that also doesn’t seem to work.

I am able to set nameservers in static configuration though.

any ideas for the problem?

did you call “netplan generate” and “netplan apply” after changing /etc/netplan/00-snapd-config.yaml ?

@ogra yes i did run generate and apply.

my config file:

network:
    ethernets:
        eth0:
            addresses: []
            dhcp: true
            nameservers: {
                addresses: [8.8.8.8, 10.240.23.20, 192.168.12.12]
            }
    version: 2

and my /etc/resolv.conf file after generate, apply and reboot:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 192.168.129.12

Also, I don’t see more than 3 entries in resolv.conf even after providing 4 or 5 entires only 3 appear in the file that too 8.8.8.8, 8.8.4.4 and the first one that I give in nameservers.addresses

looking at the examples on https://wiki.ubuntu.com/Netplan/Design

i dont think the curly brackets are correct in your “nameservers:” entry …
and you might also need to move them up one level (not underneath eth0 but as a global setting directly under “network:” )

@ogra The given file content is generated by “console-conf”. I’ll try adding nameservers manually in the file under networks and will let you know the result.

@ogra I’ve tried adding nameservers entry manually under network and that’s not right, netplan generate giver unknown key error:

Error in network definition //etc/netplan/00-snapd-config.yaml line 2 column 2: unknown key nameservers

not sure how to do it in dhcp configuratio, in static i just see 3 entries as i told in previous comment

hmpf … seems there is a bug …