Configuring ISC DHCPv6 Server
Preface
This article should give you a short overview how to install a DHCPv6 Server and configure it.
With DHCPv6 you can decide in which mode you want to use your dhcp server. You can use a 'stateless' or 'stateful mode'. Both are described in this article below
Stateless Configuration
In stateless configuration mode the dhcp server interacts together with an other IPv6 address assignment mechanism (e.g. a radvd router). The client first gets its prefix (and generates his own IPv6 address - SLAAC) and receives some more informations (like DNS server IPs, NTP server) as second part from your DHCPv6 server.
In this mode the DHCPv6 Server provides the following informations to clients:
DNS serveraddresses Domain Name NTP Server SIP Server (RFC 3319) ... see http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml
Stateful Configuration
In this mode the DHCPv6 server provides their addresses without any other address assigning mechanism.
Installation
Softwaredownload
You can download the current production release of ISC DHCP Server from http://www.isc.org/software/dhcp. Single steps for installation are listed in file README. If you want to see my steps, look below:
wget http://ftp.isc.org/isc/dhcp/dhcp-4.2.1-P1.tar.gz tar -zxfv dhcp-4.2.1-P1.tar.gz cd dhcp-4.2.1-P1 ./configure make && make install
Sampleconfigurations
The folder "dhcp-4.2.1-P1/docs/examples" provides some sampleconfigs, who are documented very well.
Serverconfiguration
Preconfigurationsteps
A possible configuration could look like this:
1.) prefix '2001:ed8:77b5' (here you can use your sixxs prefix)
2.) To indicate the dhcp server in ipv6 choose an 'easy to read' ipv4-in-ipv6 address: 2001:ed8:77b5::10:123:105:122 (ipv4: 10.123.105.122/24)
3.) the dhcp range starts from 2001:ed8:77b5::1 to 2001:ed8:77b5::ffff:ffff (many addresses...)
Client | Server | |
HW MAC | 00:22:68:11:62:cd | 60:eb:69:4e:2b:8b |
Link local Address | fe80::222:68ff:fe:11:62cd | fe80::62eb:69ff:fe4e:2b8b |
IP | range 2001:ed8:77b5::1 2001:ed8:77b5::ffff:ffff | 2001:ed8:77b5::10:123:105:122/64 |
SIXXs | range <YOUR-PREFIX>::1 <YOUR-PREFIX>::ffff:ffff | <YOUR-PREFIX>::10:123:105:122/64 |
Adding the Serverinterface to your Subnet
To become the server work properly, the listening interface has to be configured with a ip address in the provided subnet - otherwise the server will not start. (With this address the server knows, which interface he should use.)
There exists two methodes to configure your interface with IPv6 addresses:
ifconfig
ifconfig <INTERFACE> inet6 {add|del} <IPV6-ADDRESS>/<PREFIX-LENGTH> example (for adding a address): ifconfig eth0 inet6 add 2001:ed8:77b5::10:123:105:122/64
ip
ip -6 addr {add|del} <IPV6-ADDRESS>/<PREFIX-LENGTH> dev <INTERFACE> example ip -6 addr add 2001:ed8:77b5::10:123:105:122/64 dev eth0
The Expected IP Flow
Keep in mind, that the IPv6 DHCP client communicates always with the 'all multicast node' (ff02::1:1,ff02::1:2) as destination address. The server always communicates with his local link address (fe80::) as source address.
At first look it's a little bit confusing, but the IP flow looks like this:
(taken from whireshark's ip flow view)
Client DHCP Server fe80::222:68ff:fe11:62cd fe80::62eb:69ff:fe4e:2b8b | | | (all nodes address) | | ff02::1:2 | | | | | | | | Solicit XID: 0x28d6 | | DHCPv6: Solicit XID: 0x28d6e4 CID: 0001000115ad822e0022681162cd |---------------------------->| | | | | | | | | Advertise XID: 0x28 | | DHCPv6: Advertise XID: 0x28d6e4 IAA: 2001:ed8:77b5::8758:1493 CID: 0001000115ad822e0022681162cd |<---------------------------------------------------------| | | | | | | | Request XID: 0x35a2 | | DHCPv6: Request XID: 0x35a211 CID: 0001000115ad822e0022681162cd IAA: 2001:ed8:77b5::8758:1493 | --------------------------->| | | | | | | | | Reply XID: 0x35a211 | | DHCPv6: Reply XID: 0x35a211 IAA: 2001:ed8:77b5::8758:1493 CID: 0001000115ad822e0022681162cd |<---------------------------------------------------------|
DHCP Server Configfiles (Create a Range)
stateful configuration
default-lease-time 2592000; preferred-lifetime 604800; option dhcp-renewal-time 3600; option dhcp-rebinding-time 7200; # Enable RFC 5007 support (same than for DHCPv4) allow leasequery; # Global definitions for name server address(es) and domain search list # # option dhcp6.name-servers 3ffe:501:ffff:100:200:ff:fe00:3f3e; option dhcp6.domain-search "test.example.com","example.com"; option dhcp6.info-refresh-time 21600; # The subnet where the server is attached subnet6 2001:ed8:77b5::/64 { range6 2001:ed8:77b5::1 2001:ed8:77b5::ffff:ffff; }
Starting the Server
Manually
You can start the server with the following command:
dhcpd -6 -cf <PATH-to-configfile> -ls <PATH-to-leasefile>
Automatically with /etc/init.d/
Here you can see my script to start the dhcpv6 server automatically at boottime. I use ubuntu, feel free to adopt this script for your purpose.
#!/bin/sh # # $Id: isc dhcp server.init.d,v 4.2.1-P1 2011/04/05 /usr/local/sbin/dhcpd$ # ### BEGIN INIT INFO # Provides: dhcpd-server # Required-Start: $remote_fs $network $syslog # Required-Stop: $remote_fs $network $syslog # Should-Start: $local_fs slapd # Should-Stop: $local_fs slapd # Default-Start: 2 3 4 5 # Default-Stop: 1 # Short-Description: DHCP server # Description: Dynamic Host Configuration Protocol Server ### END INIT INFO PATH=/sbin:/bin:/usr/sbin:/usr/bin # config file NAME=dhcpdv6 DESC="DHCP IPv6 server" INTERFACES="eth0" SERVER=/usr/local/sbin/dhcpd SERVERARGS="-6" CONFIGFILE=/etc/dhcpdv6/dhcpv6.conf LIBFOLDER=/var/lib/dhcpv6 LEASEFILE="${LIBFOLDER}/dhcpdv6.leases" RUNFOLDER=/var/run/dhcpv6 DHCPDPID="${RUNFOLDER}/dhcpdv6.pid" # check filetypes/values test -f "${SERVER}" || exit 0 # include all init functions . /lib/lsb/init-functions test_config() { # 1.) check config if [ ! "${SERVER}" "${SERVERARGS}" -t -q -cf "${CONFIGFILE}" > /dev/null 2>&1 ]; then echo "${NAME} self-test failed. Please fix the config file." echo "The error was: " "${SERVER}" "${SERVERARGS}" -t -cf "${CONFIGFILE}" exit 1 fi # 2.) test_config will started if someone wants to start the server # test if the server is currently running if [ "${1}" = "start" ]; then if [ -e "${DHCPDPID}" ]; then stop_server "Currently running instance of ${DESC} found (PID: `cat ${DHCPDPID}`) - will now stop this instance" fi fi } stop_server(){ if [ "${1}" != "" ]; then log_daemon_msg "${1}" fi if [ -e "${DHCPDPID}" ]; then log_daemon_msg "Stopping ${DESC} ${NAME} [`cat ${DHCPDPID}`]" start-stop-daemon --stop --quiet --pidfile "${DHCPDPID}" log_end_msg $? rm -f "${DHCPDPID}" else log_daemon_msg "Stopping ${DESC} ${NAME}: nothing do do, no pidfile found" fi } # single arg is -v for messages, -q for none check_status(){ if [ ! -r "$DHCPDPID" ]; then test "$1" != -v || echo "$NAME is not running." return 3 fi if read pid < "$DHCPDPID" && ps -p "$pid" > /dev/null 2>&1; then test "$1" != -v || echo "$NAME is running." return 0 else test "$1" != -v || echo "$NAME is not running but $DHCPDPID exists." return 1 fi } case "$1" in start) test_config ${1} log_daemon_msg "Starting ${DESC} ${NAME}" # allow dhcp server to write lease and pid file if [ ! -e "${RUNFOLDER}" ]; then # create run folder mkdir -p "${RUNFOLDER}" chown dhcpd:dhcpd "${RUNFOLDER}" # create pid file touch "${DHCPDPID}" chown dhcpd:dhcpd "${DHCPDPID}" else # create pid file touch "${DHCPDPID}" chown dhcpd:dhcpd "${DHCPDPID}" fi if [ ! -e "${LIBFOLDER}" ]; then # create run folder mkdir -p "${LIBFOLDER}" chown dhcpd:dhcpd "${LIBFOLDER}" # create lease file touch "${LEASEFILE}" chown dhcpd:dhcpd "${LEASEFILE}" else # create pid file touch "${LEASEFILE}" chown dhcpd:dhcpd "${LEASEFILE}" fi start-stop-daemon --start --quiet --pidfile "${DHCPDPID}" --exec "${SERVER}" -- "${SERVERARGS}" -q -pf "${DHCPDPID}" -cf "${CONFIGFILE}" -lf "${LEASEFILE}" "${INTERFACES}" sleep 2 if check_status -q; then log_end_msg 0 else log_failure_msg "check syslog for diagnostics." log_end_msg 1 exit 1 fi ;; stop) # stop dhcp server stop_server ;; restart | force-reload) test_config $0 stop sleep 2 $0 start if [ "$?" != "0" ]; then exit 1 fi ;; status) echo -n "Status of $DESC: " check_status -v exit "$?" ;; *) echo "Usage: $0 {start|stop|restart|force-reload|status}" exit 1 esac exit 0
Don't forget to configure your runlevels, to really start the server if your machine starts:
update-rc.d <FILE-above> defaults
Lets Start the engine
Now you lets start your dhcp client and see the magic of dhcpv6. :-)
For example:
The network-manager-gnome supports dhcpv6 as client