1

I have setup new ubuntu 18.04 server which has dhcp assigned ip and dns 192.168.120.62 , after setup when i checked i waw able to get result using nslookup for local dns entries of 192.168.120.62 but nlsookup were showing nameserver 127.0.0.1:53 but after sometime it started failing with error name of service not known for ping response even for nslookup i was getting nxdomain , i checked dns server its working properly but still i am facing issue can you guide me what is the correct method if i want to assign dns to server using dhcp permanently

1

1 Answer 1

1

If you know which name servers you would like to use, you can add them to Netplan.

Look in /etc/netplan for a .yaml file and open it. For example:

$ sudo vi /etc/netplan/01-netcfg.yaml

You are going to see something that looks like this:

network:
    ethernets:
        eth0:
            dhcp4: true
            dhcp6: false
            match:
                macaddress: 00:01:02:03:04:05
            set-name: eth0
    version: 2

NOTE: Yours will probably look a little different. Do not worry if your file is just a few lines long.

Create a new nameservers item under the device section followed by an addresses item. Note that spacing is very important here.

network:
    ethernets:
        eth0:
            dhcp4: true
            dhcp6: false
            nameservers:
                addresses: [1.2.3.4, 5.6.7.8]
            match:
                macaddress: 00:01:02:03:04:05
            set-name: eth0
    version: 2

Do change the IP addresses here to proper addresses. If you would like to use one of the more popular services for DNS, here are the addresses:

Provider Addresses
Google [8.8.8.8, 8.8.4.4]
Cloudflare [1.1.1.1, 1.0.0.1]
OpenDNS [208.67.222.222, 208.67.220.220]
Level3 [209.244.0.3, 209.244.0.4]

Once done, save the file and then apply it:

$ sudo netplan apply

Test the DNS Servers are being used with this:

$ systemd-resolve --status | grep 'DNS Servers' -A2

You should see something that looks like this:

         DNS Servers: 1.1.1.1
                      1.0.0.1

Done.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .