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

4 Answers 4

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
    
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 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 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 at 13:16

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
2  
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 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 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 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 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 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 at 13:34
    
Sorry ...but still i do not understand what you try to achieve with this DNS nameservers entries. –  Matei Cezar Feb 2 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 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 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 at 16:28

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.