I'm a bit confused as to the proper place to add custom DNS entries for a server that uses DHCP. This instance is in AWS but I have a custom DNS server that it needs to use as it's primary name server. Should I add that in to the interfaces file? If so, what should that syntax look like?


You should do two things: Yes, add the DNS that you want to your /etc/network/interfaces file; And change your /etc/dhcp/dhclient.conf file to not ask for it via when it is getting or renewing it's IP lease.

These examples are from my main 16.04 server: First, /etc/network/interfaces file (in my case the DNS is this server itself):

doug@DOUG-64:~/config/etc/network$ cat interfaces
# interfaces file for smythies.com 2016.01.30
#       attempt to set local DNS herein, as the method
#       used with the old 12.04 server no longer works.
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback
pre-up /home/doug/init/doug_firewall

# The primary interface (d-link PCI card)
auto enp4s0
iface enp4s0 inet dhcp

# Local network interface (uses built in ethernet port)
auto enp2s0
iface enp2s0 inet static

And, etc/dhcp/dhclient.conf:

doug@DOUG-64:~/config/etc/dhcp$ cat dhclient.conf
# Smythies.com 2016.02.02
#       For 16.04, in terms of DNS, this stuff isn't working.
#       Try deleting the domain-name-servers from the request.
#       See also /resolvconf/resolv.conf.d/base.

#request subnet-mask, broadcast-address, time-offset, routers,
#       domain-name, domain-name-servers, domain-search, host-name,
#       netbios-name-servers, netbios-scope, interface-mtu,
#       rfc3442-classless-static-routes, ntp-servers;

request subnet-mask, broadcast-address, time-offset, routers;
| improve this answer | |
  • Nice answer! Can multiple dns be used on the same line? such as: dns-nameservers – Thaidog Nov 9 '18 at 21:59
  • Also wondering how to make this regenerate resolv without rebooting... do you know what service handles this? – Thaidog Nov 9 '18 at 22:10
  • Yes, I think you can specify multiple dns-nameservers. I'm not sure about your 2nd comment. – Doug Smythies Nov 10 '18 at 4:57

You can specify the DNS server which you want to use in the config file specified below. Add the DNS server that you want to use in /etc/network/interfaces file. Example


After that, edit your /etc/dhcp/dhclient.conf file and add the line below:

request subnet-mask, broadcast-address, time-offset, routers;

Then save both the files.

| improve this answer | |

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.