Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

All examples I have seen of configurations (/etc/network/interfaces) showed that you configure an interface and then underneath that gave the dns-* lines such as:

auto eth0
iface eth0 inet static
        dns-search example.com my.example.com

Now I am aware that the DNS protocol is independent of the transport mechanism. Therefore it shouldn't be per-se wrong to add an IPv6 address on the dns-nameservers line.

However, since I am also configuring the interface for IPv6 anyway, it made sense to add the dns-nameservers line there:

iface eth0 inet6 static
        dns-nameservers ::2
        dns-search example.com my.example.com

... or did it? Because when resolvconf creates /etc/resolv.conf it simply ignores all the IPv6 DNS servers. It also seems to ignore dns-search and dns-domain. The only line it seems to honor is the dns-nameservers line from the IPv4 configuration for eth0.

What is the correct method of configuring DNS servers?

Further circumstantial evidence as to why it should be part of each respective iface stanza. Quote from man 8 resolvconf:

The ifup(8) program can be used to configure network interfaces according to settings in /etc/network/interfaces(5). To make ifup push nameserver information to resolvconf when it configures an interface, add dns- lines to the relevant iface stanza in /etc/network/interfaces. To add nameserver addresses add a line beginning with dns-nameservers.

share|improve this question
If you still have this problem then please post your whole /etc/network/interfaces file and the output of /usr/share/resolvconf/dump-debug-info which is included in the resolvconf package in Ubuntu 15.04. – jdthood May 30 '15 at 18:45

It is correct to put dns-* options in either the iface eth0 inet static stanza or the iface eth0 inet6 static stanza. The options become active when the logical interface definition to which they belong becomes active.

I just tested this on my own Ubuntu 15.04 machine which I normally configure with DHCP. I disabled NetworkManager and edited /etc/network/interfaces so that it looks like this:

iface eth0 inet static
        dns-search foo

iface eth0 inet6 static
        address fe80::390:f5ff:fef7:96b9/64
        dns-nameservers ::2
        dns-search bar

I then did

$ sudo ifup eth0

The results:

$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:90:f5:f7:96:b9  
      inet addr:  Bcast:  Mask:
      inet6 addr: fe80::390:f5ff:fef7:96b9/64 Scope:Link
      RX packets:2114609 errors:0 dropped:1 overruns:0 frame:0
      TX packets:1757693 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:2033346950 (2.0 GB)  TX bytes:1318685445 (1.3 GB)
      Interrupt:20 Memory:f7e00000-f7e20000 

$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
nameserver ::2
search bar foo

Note that the addresses, dns-nameservers and dns-search options from both stanzas are now active.

[Updated 30 May 2015]

share|improve this answer
This is the behavior I described in my question. How can I cause /etc/network/interfaces and resolvconf to add the IPv6 DNS servers as well? You'll notice that this part is missing from your produced /etc/resolv.conf. – 0xC0000022L Feb 2 '15 at 10:37
You wrote, "when resolvconf creates /etc/resolv.conf it simply ignores all the IPv6 DNS servers." What you are seeing is probably an effect of resolvconf truncating the nameserver list after the first loopback address. Look in resolvconf(8) for the section describing the environment variable "TRUNCATE_NAMESERVER_LIST_AFTER_LOOPBACK_ADDRESS". – jdthood May 1 '15 at 8:48
nope, my list of DNS servers contains none that listens on the loopback address, so according to the man page the configuration wouldn't be affected this way. The example I gave was merely to not give away too many details. But no DNS is on a local net. – 0xC0000022L May 1 '15 at 13:16
Hi. I just updated my answer to show the results when I use an IPv6 address instead of an IPv4 address as argument to the dns-nameservers option in /e/n/i. Executive summary: everything works as expected. – jdthood May 30 '15 at 18:42
thanks, so it works on 15.04 which doesn't help me on the 14.04 and 12.04 LTS versions, though. Thanks anyway. – 0xC0000022L May 31 '15 at 10:50

Editing network interfaces in order to add use your custom DNS is a way ...but for permanently modifying system-wide resolv.conf with your custom dnsnameserver you need to install resolvconf package (if it not already installed by default) and populate its base configuration file with your custom DNS nameservers values. Hope this short guide will help you for further configurations concerning resolv.conf DNS entries http://www.bytelinux.com/make-permanent-changes-to-resolv-conf-file-on-ubuntu/

share|improve this answer
Welcome to Unix & Linux! Whilst this may theoretically answer the question, it would be preferable to include more of the essential parts of that guide here, and provide the link for reference. – Anthon Feb 2 '15 at 10:07
@MateiCezar: could you please elaborate? I'm not sure you even read my question to the end. Package resolvconf is installed. I'd like to /etc/network/interfaces to configure my DNS servers for IPv4 and IPv6 respectively. – 0xC0000022L Feb 2 '15 at 10:36

You want to use IPv6 DNS servers on /etc/network/interfaces...just put your IPv6 DNS namesers entries on the specific network interface like this:

dns-nameservers 2001:4860:4860::8844 2001:4860:4860::8888. 

For permanent adding IPv6 dnsnamesers to resolv.conf use the same link i've added below and edit resolvconf base file by populating with your own IPv6 DNS namesers :

nameserver 2001:4860:4860::8844
nameserver 2001:4860:4860::8888 

To configure /etc/network/interfaces with IPv6 use this guide http://www.bytelinux.com/configure-permanent-static-ip-address-alias-interfaces-debian-based-systems/ and replace IPv4 with IPv6 the as it follows: auto eth0

iface eth0 inet6 static
        address 2800:210:0:1::3
        netmask 64
        gateway 2800:210:0:1::1
        dns-nameservers 2001:4860:4860::8844 
share|improve this answer
Fixed your formatting. Again, my question clearly states that this doesn't result in those DNS servers for IPv6 being added to /etc/resolv.conf. If this somehow works for you it'd be useful to know the exact system version. – 0xC0000022L Feb 2 '15 at 11:00
let me get this straight...you want to use IPv6 DNS resolvers from /etc/network/interfaces and somehow adding them in that file doesn't work for you? – Matei Cezar Feb 2 '15 at 11:31
I can add them to /etc/network/interfaces fine. What doesn't happen is that they get transferred into /etc/resolv.conf as they should. And I am trying to figure out what I am doing wrong, yes. – 0xC0000022L Feb 2 '15 at 13:03
Still didn't get it? Those DNS entries from /etc/network/interfaces gets transfered to /etc/resolv.conf or not? Usullay those namservers entries from interfaces never get transferred or written to /etc/resolv.com, they work on their own from that NIC and are not implemented system-wide. Just the /etc/resolv.conf file DNS are used by the interfaces who lack dnsnameservers entries. – Matei Cezar Feb 2 '15 at 13:34
Sorry ...but still i do not understand what you try to achieve with this DNS nameservers entries. – Matei Cezar Feb 2 '15 at 13:38

Why don't you implement those IPv6 DNS nameservers directly on /etc/resolv.conf system-wide file by editing resolvconf base file as suggested in my previous answer with the link and still continue to use network interfaces file? You can add a set of DNS IPv6 nameservers in /etc/resolv.conf and if you want to use other IPv6 nameservers for a specific NIC use them only on /etc/network/interfaces.

share|improve this answer
what you mention in your last sentence is exactly the reason why I don't want to use the resolvconf base config and it's exactly what I am trying. Furthermore it is exactly what is failing. – 0xC0000022L Feb 11 '15 at 12:11
ok..I got it! But why you want to implement things in this manner?either way you only need those DNS nameservers to be accessible system-wide,is there any reason to transfer them from network/interfaces to resolv.conf, when you could just write them in both files and you're done!? – bytelinux com Feb 11 '15 at 13:37
Not sure how many machines you administrate, but for me it's enough to try and make my life easier. Since /etc/network/interfaces is supposed to do the job, I am trying to figure out what I am doing wrong. – 0xC0000022L Feb 11 '15 at 16:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.