1
  • I still want to use DHCP to obtain IP4 and IP6 addresses.
  • DHCP delivers DNS servers
  • I want that the DNS servers from DHCP are ignored and two servers I specify manually are used instead.
  • Must be done on a headless server (no GUI) via Bash.
  • ubuntu-14.04.2-server-amd64, standard minimal installation + sshd

How is this configured correctly?

How to verify that the configuration works as expected?

/etc/network/interfaces is:

# 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

# The primary network interface
auto em1
iface em1 inet dhcp

resolvconf is installed.

15
  • Can you use vi to edit /etc/network/interfaces and add your own DNS server entries?
    – Kinnectus
    Commented Jul 23, 2015 at 14:03
  • Yes, I could do that. What should I put there? How does it interact with resolv.conf?
    – Gustave
    Commented Jul 23, 2015 at 14:33
  • Add dns-nameservers <your DNS server IPs> to the end of your interfaces file and reboot the server... this should add the required DNS servers to the network config...
    – Kinnectus
    Commented Jul 23, 2015 at 14:42
  • There is some documentation at help.ubuntu.com/lts/serverguide/network-configuration.html, but it doesn't help me (no enough details about how to write the "stanza"s and what effect they have).
    – Gustave
    Commented Jul 23, 2015 at 14:47
  • Can you expand on the last comment? You shouldn't need to put < and > - this was my way of saying "this is where you type your DNS server IPs". For example: dns-nameservers 8.8.8.8 8.8.4.4 to add Google's primary and secondary DNS addresses.
    – Kinnectus
    Commented Jul 23, 2015 at 14:50

1 Answer 1

0

Add the line

supersede domain-name-servers 8.8.8.8, 8.8.4.4;

to the DHCP client configuration file /etc/dhcp/dhclient.conf.

To verify get the names of your network interfaces with ifconfig, shut down the interface(s) with ifdown ifname (e.g. ifdown eth0), restart it with ifup ifname (e.g. ifup eth0). After that (or after a reboot) /etc/resolv.conf should contain the two lines

nameserver 8.8.8.8
nameserver 8.8.4.4

Thanks to Big Chris.

You must log in to answer this question.

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