[plug] DHCPv6

Andrew Cooks acooks at gmail.com
Thu Jul 17 02:03:57 UTC 2014


Hi Adrian, PLUG

On Wed, Jul 16, 2014 at 9:30 PM, Adrian Woodley <Adrian at diskworld.com.au> wrote:
>
> DHCPDv6 listens on UDP port 547 for DHCPv6 requests, as opposed to RADVD
> which listens on a raw socket for router solicitation requests.

Hmm, ok, thanks for that. Yet another little gotcha in IPv6. So, if I
don't see the client UDP packets it's a client-side problem. I was
under the impression that even stateful DHCPv6 still requires an RA
response (with M bit set), before it will request the rest of the
parameters with DHCP. My assumption was that the DHCP server would
send the RA in the absence of radvd, but it seems that that's
incorrect.

Anyway, for the record, I'm using the following:
The client is dhcpcd-6.4.0, run as follows:
$ dhcpcd -B -d --timeout 0 --noipv4 --noipv4ll --duid -m 5 vlan1

And the server is ISC DHCP Server 4.2.4, as follows:
$ dhcpd -user dhcpd -group dhcpd -f -6 -pf /run/dhcp-server/dhcpd6.pid
-cf /etc/dhcp/dhcpd6.conf br_v602

The rest of the configuration is similar to what you described below,
though I see that you omitted an radvd config.

> To get DHCPDv6 working (on Debian/Ubuntu) install isc-dhcp-server and modify
> the default config thusly:
>
> subnet 10... becomes:
>
> subnet6 2011:DB8:1234:5678::/64 {
>   range6 2011:DB8:1234:5678::10 2011:DB8:1234:5678::fff0;
> }
>
> You can also include the following options:
>
> option dhcp6.domain-search "test.net";
> option dhcp6.name-servers 2011:DB8:1234:5678::1;
>
> I would also change the lease file to a unique dhcpd-v6 file:
>
> lease-file-name "/var/lib/dhcp/dhcpd-v6.leases";
>
> To run this concurrently with your IPv4 DHCP server, copy
> /etc/init.d/isc-dhcp-server to /etc/init.d/isc-dhcp-server-v6 and apply the
> following patch:
>
> root at Router:/etc/init.d# diff -ruN isc-dhcp-server isc-dhcp-server-v6
> --- isc-dhcp-server    2012-09-14 11:24:53.000000000 +0800
> +++ isc-dhcp-server-v6    2012-01-05 10:06:09.000000000 +0800
> @@ -3,14 +3,14 @@
>  #
>
>  ### BEGIN INIT INFO
> -# Provides:          isc-dhcp-server
> +# Provides:          isc-dhcp-server-v6
>  # Required-Start:    $remote_fs $network $syslog
>  # Required-Stop:     $remote_fs $network $syslog
>  # Should-Start:      $local_fs slapd $named
>  # Should-Stop:       $local_fs slapd
>  # Default-Start:     2 3 4 5
>  # Default-Stop:      0 1 6
> -# Short-Description: DHCP server
> +# Short-Description: DHCPv6 server
>  # Description:       Dynamic Host Configuration Protocol Server
>  ### END INIT INFO
>
> @@ -18,38 +18,29 @@
>
>  test -f /usr/sbin/dhcpd || exit 0
>
> -DHCPD_DEFAULT="${DHCPD_DEFAULT:-/etc/default/isc-dhcp-server}"
> -
>  # It is not safe to start if we don't have a default configuration...
> -if [ ! -f "$DHCPD_DEFAULT" ]; then
> -    echo "$DHCPD_DEFAULT does not exist! - Aborting..."
> -    if [ "$DHCPD_DEFAULT" = "/etc/default/isc-dhcp-server" ]; then
> -        echo "Run 'dpkg-reconfigure isc-dhcp-server' to fix the problem."
> -    fi
> +if [ ! -f /etc/default/isc-dhcp-server ]; then
> +    echo "/etc/default/isc-dhcp-server does not exist! - Aborting..."
> +    echo "Run 'dpkg-reconfigure isc-dhcp-server' to fix the problem."
>      exit 0
>  fi
>
>  . /lib/lsb/init-functions
>
> -# Read init script configuration
> -[ -f "$DHCPD_DEFAULT" ] && . "$DHCPD_DEFAULT"
> +# Read init script configuration (so far only interfaces the daemon
> +# should listen on.)
> +[ -f /etc/default/isc-dhcp-server ] && . /etc/default/isc-dhcp-server
>
>  NAME=dhcpd
> -DESC="ISC DHCP server"
> -# fallback to default config file
> -DHCPD_CONF=${DHCPD_CONF:-/etc/dhcp/dhcpd.conf}
> -# try to read pid file name from config file, with fallback to
> /var/run/dhcpd.pid
> -if [ -z "$DHCPD_PID" ]; then
> -    DHCPD_PID=$(sed -n -e 's/^[ \t]*pid-file-name[ \t]*"(.*)"[
> \t]*;.*$/\1/p' < "$DHCPD_CONF" 2>/dev/null | head -n 1)
> -fi
> -DHCPD_PID="${DHCPD_PID:-/var/run/dhcpd.pid}"
> +DESC="ISC DHCP server v6"
> +DHCPDPID=/var/run/dhcpd6.pid
>
>  test_config()
>  {
> -    if ! /usr/sbin/dhcpd -t $OPTIONS -q -cf "$DHCPD_CONF" > /dev/null 2>&1;
> then
> -        echo "dhcpd self-test failed. Please fix $DHCPD_CONF."
> +    if ! /usr/sbin/dhcpd -cf /etc/dhcp/dhcpd-v6.conf -6 -t -q > /dev/null
> 2>&1; then
> +        echo "dhcpd-v6 self-test failed. Please fix the config file."
>          echo "The error was: "
> -        /usr/sbin/dhcpd -t $OPTIONS -cf "$DHCPD_CONF"
> +        /usr/sbin/dhcpd -cf /etc/dhcp/dhcpd-v6.conf -6 -t
>          exit 1
>      fi
>  }
> @@ -57,15 +48,15 @@
>  # single arg is -v for messages, -q for none
>  check_status()
>  {
> -    if [ ! -r "$DHCPD_PID" ]; then
> +    if [ ! -r "$DHCPDPID" ]; then
>      test "$1" != -v || echo "$NAME is not running."
>      return 3
>      fi
> -    if read pid < "$DHCPD_PID" && ps -p "$pid" > /dev/null 2>&1; then
> +    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 $DHCPD_PID exists."
> +    test "$1" != -v || echo "$NAME is not running but $DHCPDPID exists."
>      return 1
>      fi
>  }
> @@ -74,9 +65,8 @@
>      start)
>          test_config
>          log_daemon_msg "Starting $DESC" "$NAME"
> -        start-stop-daemon --start --quiet --pidfile "$DHCPD_PID" \
> -            --exec /usr/sbin/dhcpd -- \
> -            -q $OPTIONS -cf "$DHCPD_CONF" -pf "$DHCPD_PID" $INTERFACES
> +        start-stop-daemon --start --quiet --pidfile $DHCPDPID \
> +            --exec /usr/sbin/dhcpd -- -6 -q $INTERFACES -cf
> /etc/dhcp/dhcpd-v6.conf
>          sleep 2
>
>          if check_status -q; then
> @@ -89,9 +79,9 @@
>          ;;
>      stop)
>          log_daemon_msg "Stopping $DESC" "$NAME"
> -        start-stop-daemon --stop --quiet --pidfile "$DHCPD_PID"
> +        start-stop-daemon --stop --quiet --pidfile $DHCPDPID
>          log_end_msg $?
> -        rm -f "$DHCPD_PID"
> +        rm -f "$DHCPDPID"
>          ;;
>      restart | force-reload)
>          test_config
>
> An alternative would be to install wide-dhcpv6-server. This will require
> must less mucking around to get going, but doesn't allow the option to
> automatically and dynamically update your local DNS zone as hosts receive
> (and relinquish) IPv6 leases. Given the length of IPv6 address, having your
> hosts automatically added to DNS is a Good Thing (TM). (This can be somewhat
> ameliorated by using Avahi/mDNS).

Yes, I agree. It works fine for me as long as I have radvd as well. I
guess I could shuffle things around to make either radvd or dhcpd
provide different pieces of config to see what breaks, but I'm too
lazy for that.

> Hope this gets you on your way.

Thanks!

> Also, you've totally stolen my username and claimed it first, because I
> stole the idea from Bernard Blackham (b) around 2001. :-P

I'll try not to use our username in vain. :-P

Strangely, I'm working in the same company (Tieline) where Bernard
worked around 2007. I've never met him, but we still rely on some of
the magic he created. Bernard, if you're reading this, the JitterBox
is about to be replaced with netem. :)

Cheers!

a.


More information about the plug mailing list