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
Kalle Richter
  • 5,935
  • 20
  • 69
  • 101
ThiagoCMC
  • 819
  • 4
  • 13
  • 27

5 Answers5

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.

belacqua
  • 22,880
  • 23
  • 88
  • 108
3

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

Sander Steffann
  • 2,317
  • 15
  • 14
  • 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 Feb 23 '14 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 Feb 23 '14 at 22:08
  • Also relevant: http://unix.stackexchange.com/questions/28004/how-to-overcome-libc-resolver-limitation-of-maximum-3-nameservers. It mentions >3 name servers, possible increased timeouts and running a local DNS cache instead of adding more name servers. – Sander Steffann Feb 25 '14 at 00:12
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 ...

opinion_no9
  • 965
  • 2
  • 11
  • 24
  • 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! – opinion_no9 Sep 29 '19 at 09:43
2

Add it manual to the /etc/resolv.conf

 nameserver 2001:4860:4860::8844

 nameserver 2001:4860:4860::8888
Maythux
  • 82,867
  • 54
  • 239
  • 271
  • 2
    No, I can't add it manually, resolv.conf have: "DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN" – ThiagoCMC Feb 22 '14 at 05: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 Feb 22 '14 at 05:29
  • @belacqua Yeah sure sadly... – Maythux Feb 22 '14 at 05:31
  • So, this is a BUG, right?! – ThiagoCMC Feb 22 '14 at 05:33
  • @ThiagoCMC no it's not but editing manual was deprecated – Maythux Feb 22 '14 at 05:52
  • this is not always a good idea: "Add it manual to the /etc/resolv.conf" because it violates modern systemd-resolved based systems. like it or not: systemd-resolved is a new layer in between. If it applies to your Linux. So this is probably not a bug - systemd-resolved works different in modern OS like ubuntu 19.xx. a nice recap is found here: https://wiki.archlinux.org/index.php/Systemd-resolved#DNS – opinion_no9 Sep 29 '19 at 09:50
  • https://www.techrepublic.com/article/how-to-set-dns-nameservers-in-ubuntu-server-18-04/ tells you what the background is and why it is different today. Like it or not .... – opinion_no9 Sep 29 '19 at 09:57
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.

MadPsy
  • 1