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 dns-nameservers 127.0.0.1 # 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 address 192.168.111.1 network 192.168.111.0 netmask 255.255.255.0 broadcast 192.168.111.255
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. # ...[snip]... #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;
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.