4

I want tp supersede the name server information, which I get from the DHCP server with my own configuration. Therefor I'm using the following option in my /etc/dhcp/dhclient.conf:

supersede domain-name-servers 1.1.1.1, 2.2.2.2, 3.3.3.3;

Everything works well, but I want to add IPv6 addresses as well as this is a dual stack server. The following statement does not work (I get /etc/dhcp/dhclient.conf line 56: semicolon expected. in the syslog):

supersede domain-name-servers 1.1.1.1, 2.2.2.2, 3.3.3.3, ::1, 2000::BEEF, FURTHER_IPv6_ADDRESS;

So my question is: How to I add IPv6 addresses to the supersede domain-name-servers option in /etc/dhcp/dhclient.conf?

manifestor
  • 2,423
  • 6
  • 22
  • 47
  • How are you assigning IPv6 addresses to your client? SLAAC or DHCPv6? – hardillb Jun 17 '20 at 11:39
  • @hardillb - frankly speaking: I don't know :) How can I check that? – manifestor Jun 17 '20 at 11:40
  • @hardillb - it's a static configuration in `/etc/network/interfaces` (regarding IPv6). – manifestor Jun 17 '20 at 11:42
  • So can't you just set up the static IPv6 DNS with the static address config? (The IPv4 DHCP client knows nothing about IPv6) – hardillb Jun 17 '20 at 13:21
  • @hardillb - I could, but the `dhclient` overrides my `resolv.conf` - that means if I set static DNS servers in `/etc/network/interfaces` and issue `ifup` they might be added, but they will be deleted with the next DHCP lease, because I added `supersede domain-name-servers` to the `dhclient` configuration. – manifestor Jun 17 '20 at 13:30
  • Since you are already throwing away the DNS servers from the DHCP server, you'd do better just not asking for them and hard coding all the DNS servers you want in the `/etc/resolv.conf` https://wiki.debian.org/resolv.conf – hardillb Jun 17 '20 at 13:39

1 Answers1

6

Background

I found the solution buried in this bug titled: Bug 643890 - dhclient refuses to prepend ipv6 nameservers.

Jiri Popelka 2010-10-18 15:37:46 UTC

(In reply to comment #0)
> prepend domain-name-servers 2001:470:20::2 ;
correct is
prepend dhcp6.name-servers 2001:470:20::2;
(see dhcp-options(5) man page)
but it seems that dhclient is really ignoring it.

I'm trying to figure out what's wrong.

The man page for dhcp-options shows it as well:

   option dhcp6.name-servers ip6-address [, ip6-address ... ] ;

     The  name-servers  option  instructs  clients about locally available 
     recursive DNS servers.  It is easiest to describe this as the "nameserver"
     line in /etc/resolv.conf.

Example Fix

So on my clients I've added the following lines to do dual stack (IPv4 & IP6):

$ cat /etc/dhcp/dhclient.conf
...
...
## Global section example
prepend domain-name-servers 192.168.7.14,192.168.7.85;
prepend dhcp6.name-servers 2602:6030:dd00:d807::1a11;

## Interface section example
interface "eth0" {
    prepend domain-name-servers 192.168.7.14,192.168.7.85;
    prepend dhcp6.name-servers 2602:6030:dd00:d807::1a11;
}
...
...
slm
  • 363,520
  • 117
  • 767
  • 871