IPv6 DNS Server Discovery by DHCPv6

JINMEI Tatuya at the KAME Project
$Id: index.html,v 1.8 2003/07/16 12:51:52 jinmei Exp $

This document is a brief instruction to play with IPv6 DNS server discovery using (stateless) DHCPv6.

1. Installation

  1. Get the latest KAME snap kit at the project web page. 20030414 version should work as described here (except relay agents, which should be updated to recent versions around July 15, 2003).
  2. Go down to the dhcp6 source directory. It should be located at kame/kame/kame/dhcp6.
  3. Build the DHCPv6 kit. The following simple procedure should work at least for the corresponding KAME snap system:
    % ./configure
    % make
    # make install
  4. Be sure to install the server (dhcp6s) to the server machine, and the client (dhcp6c) to all client hosts.

2. Server Configuration

First, add the following to your server configuration file (which is /usr/local/etc/dhcp6s.conf by default):
option domain-name-servers DNS_SERVER_ADDRESS;
where DNS_SERVER_ADDRESS is the IPv6 numeric address of the DNS server. Multiple addresses can be specified by multiple 'option' statements. Then start the server:
# dhcp6s IFNAME
where IFNAME is the interface that the server should receive requests from clients. Multiple interfaces can be specified as multiple arguments.

Note: if the server is located on a different link as the client, you will need to run a DHCPv6 relay agent on the client link and (in general) to enable IPv6 multicast routing to reach the server from the relay agent.

3. Host Configuration

3.1. DHCPv6 Client Configuration

Add the following to your server configuration file (which is /usr/local/etc/dhcp6c.conf by default):
interface IFNAME {
	request domain-name-servers;
	script "SCRIPT_PATH";
where IFNAME is the interface name, like "fxp0", on which the host machine is connected to the network, and SCRIPT_PATH is an absolute path to a script file which processes DNS server addresses given by the sever.

3.2. Client Script

If you do not mind to override the /etc/resolv.conf file, the following simple script should be fine:

rm /etc/resolv.conf
for nameserver in $new_domain_name_servers; do
      echo nameserver $nameserver >>/etc/resolv.conf
This is exactly what ISC dhclient does with regards to DNS server addresses.

Save this file to somewhere in the client machine.

Assuming the script file is /sbin/dhcp6c-script and the DHCPv6 client interface is fxp0, a complete example of dhcp6c.conf is:

interface fxp0 {
	request domain-name-servers;
	script "/sbin/dhcp6c-script";

3.3. Start the Client

Then invoke the client:
# dhcp6c fxp0
That's it. The client should be able to get DNS server addresses from the server, and will update /etc/resolv.conf accordingly.

4. Interaction with Router Advertisement

If the router(s) serving for the client host has the ability to set the "Other Configuration (O)" flag of router advertisement, you can automatically (re)invoke the DHCPv6 client upon receipt of advertisements with the flag being set. This can be done by the latest rtsold(8) daemon with the -O flag.

The following subsections describe the procedure.

4.1 Router Configuration

If you are using a KAME PC router and the rtadvd(8) daemon for router advertisements, you'll be able to set the O flag with the following configuration:
where [backslash] is the backslash character. (You may need to change the interface name "fxp0" appropriately.) If you have installed the latest version of rtadvd from KAME snapshots, you can also specify the flag as a string notation:

4.2 Host Configuration

First, prepare a script file that (re)invokes the DHCPv6 client. It should be like this:


if [ -f ${PIDFILE} ]; then
	kill -HUP `cat ${PIDFILE}`
	/usr/local/sbin/dhcp6c $IFNAME
Put this script somewhere in the client host machine (we assume "/sbin/start-dhcp6c").

Then invoke the rtsold(8) daemon (which should be built from the latest KAME snapshot):

# rtsold -O /sbin/start-dhcp6c IFNAME
When the daemon receives a router advertisement with the O flag on, it will invoke the start-dhcp6c script, which will then (re)start the DHCPv6 client. If the host machine moves from link to link, you may also want to specify the -m option to the rtsold daemon.