10

With IPv4, I can add two DNS Name Servers without any problem, like this:

"dns-nameservers 8.8.4.4 8.8.8.8"

Then on my resolv.conf I got:

   nameserver 8.8.4.4
   nameserver 8.8.8.8

BUT, it does not work for IPv6, only the first IPv6 DNS Server appear at my resolv.conf, look:

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

But then, my resolv.conf remain only with the first one:

   nameserver 2001:4860:4860::8844

Apparently, Ubuntu (resolvconf / ifupdown) is ignoring the second DNS Name Server, so, how to fix it?!

Here is my /etc/network/interfaces file:

auto lo
iface lo inet loopback
iface lo inet6 loopback

auto eth0
iface eth0 inet6 static
        address 2800:210:0:4::2
        netmask 64
        gateway 2800:210:0:4::1
        dns-nameservers 2001:4860:4860::8844 2001:4860:4860::8888
1
  • You seem to have found a bug. I'd file a report at launchpad. Commented Feb 22, 2014 at 18:40

5 Answers 5

5

There can be only three nameservers in resolv.conf. If you remove one of the IPv4 nameservers the second IPv6 nameserver will be added.

3
  • Is this a limitation of the implementation, or is this actually following some specification? Looks like you'd have to change MAXNS in resolv.h and recompile. Unless there are special v6 rules.
    – belacqua
    Commented Feb 23, 2014 at 22:06
  • @ThiagoCMC let us know if this fixes it (and if it does, you can checkmark this to accept it as the answer).
    – belacqua
    Commented Feb 23, 2014 at 22:08
  • Also relevant: unix.stackexchange.com/questions/28004/…. It mentions >3 name servers, possible increased timeouts and running a local DNS cache instead of adding more name servers. Commented Feb 25, 2014 at 0:12
3

I was initially thinking this was a bug, but I'm going to assume @Sander's answer is correct here. I'm not sure if resolvconf uses resolv.h or something else for the maximum nameserver value, though.

Generally, instead of using resolv.conf, Here are a couple things to try:

You could try editing dhclient.conf as suggested in the Google dev docs :

prepend domain-name-servers 2001:4860:4860::8888, 2001:4860:4860::8844;

For this method on Ubuntu, I believe the current path is /etc/dhcp/dhclient.conf.

The same document gives instructions for using NetworkManager. If you use that, you can right-click on your network icon, find your connection then select "Edit", then go to the IPv6 tab. You can set "additional DNS servers" there.

2

Add it manual to the /etc/resolv.conf

 nameserver 2001:4860:4860::8844

 nameserver 2001:4860:4860::8888
7
  • 3
    No, I can't add it manually, resolv.conf have: "DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN"
    – ThiagoCMC
    Commented Feb 22, 2014 at 5:26
  • 3
    @maythux sadly (in my opinion), editing resolv.conf is deprecated.... However, this can be used as a test. You won't break anything.
    – belacqua
    Commented Feb 22, 2014 at 5:29
  • @belacqua Yeah sure sadly...
    – Maythux
    Commented Feb 22, 2014 at 5:31
  • So, this is a BUG, right?!
    – ThiagoCMC
    Commented Feb 22, 2014 at 5:33
  • @ThiagoCMC no it's not but editing manual was deprecated
    – Maythux
    Commented Feb 22, 2014 at 5:52
2

@ThiagoCMC said "No, I can't add it manually, resolv.conf ... ": Yes, you are right - but you can force the system NOT to change this file: edit it and (as root) chattr +i resolv.conf then it can never be edited again by scripts. Unfortunately from that moment on you have to maintain it yourself, always ...

1
  • Ubuntu 19.xx actively checks for the link character of resolv.conf in some DNS related tasks. Not finding a link makes some processes fail. >> do avoid this brute force solution! Commented Sep 29, 2019 at 9:43
0

Although MAXNS is set, resolvconf can add as many NS's as you like by using /etc/resolvconf/resolv.conf.d

In there you will find 'head' which contains the warning message found at the top of /etc/resolv.conf and a (probably empty) file called 'base'.

You can edit these files freehand to add additional lines in resolv.conf (such as 'nameserver xx.xx.xx.xx').

Whether or not adding >MAXNS lines will actually work is a different matter but that's how to force custom content into the resolv.conf itself.

You must log in to answer this question.

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