How to add two IPv6 dns-nameservers into /etc/network/interfaces?

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

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


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.


Add it manual to the /etc/resolv.conf

 nameserver 2001:4860:4860::8844

 nameserver 2001:4860:4860::8888

@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 ...