Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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-nameservers 127.0.0.2
        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

1 Answer 1

up vote 3 down vote accepted

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 13.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
        address 172.24.111.49
        netmask 255.255.255.0
        broadcast 172.24.111.255
        dns-nameservers 8.8.8.8
        dns-search foo

iface eth0 inet6 static
        address fe80::8a51:fbff:fe7e:6e91/64
        dns-nameservers 8.8.4.4
        dns-search bar

I then did

$ sudo ifup eth0
ssh stop/waiting
ssh start/running, process 20175
ssh stop/waiting
ssh start/running, process 20271
$

The results:

$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 88:51:fb:7e:6e:91  
          inet addr:172.24.111.49  Bcast:172.24.111.255  Mask:255.255.255.0
          inet6 addr: fe80::8a51:fbff:fe7e:6e91/64 Scope:Link
[...]
$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4
search foo bar

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

share|improve this answer

Your Answer

 
discard

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.