[plug] DHCPv6

Adrian Woodley Adrian at Diskworld.com.au
Wed Jul 16 13:30:25 UTC 2014


G'day PLUG, Andrew,

Sorry Onno:

a at Hex:~$ ip addr show dev eth0
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast 
state UP group default qlen 1000
     link/ether 00:e0:61:06:e2:a0 brd ff:ff:ff:ff:ff:ff
     inet 192.168.30.9/24 brd 192.168.30.255 scope global eth0
        valid_lft forever preferred_lft forever
     inet6 2001:44b8:610b:3f01:e923:e31b:bbf3:4e75/64 scope global 
temporary dynamic
        valid_lft 293sec preferred_lft 113sec

a at Hex:~$ (ip route ; ip -6 route) |grep default
default via 192.168.30.254 dev eth0
default via fe80::98db:82ff:fe93:3b38 dev eth0  proto ra  metric 1024  
expires 26sec

a at Hex:~$ netstat -ltn |grep 22
tcp        0      0 0.0.0.0:22 0.0.0.0:*               LISTEN
tcp6       0      0 :::22 :::*                    LISTEN

Right, now thats cleared up, onto DHCPv6.

DHCPDv6 listens on UDP port 547 for DHCPv6 requests, as opposed to RADVD 
which listens on a raw socket for router solicitation requests.

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

Hope this gets you on your way.

Adrian

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

On 16/07/14 17:15, Onno Benschop wrote:
> This might be a red herring, but seem to recall in the deep dark mists 
> of my memory that you couldn't have an interface that did both IPv4 
> and IPv6 at the same time.
>
> Please feel free to ridicule this comment - as I said, YMMV.
>
>
> On 16 July 2014 10:45, Andrew Cooks <acooks at gmail.com 
> <mailto:acooks at gmail.com>> wrote:
>
>     Hi List
>
>     I'm trying to configure dhcpv6 (stateful IPv6 autoconfiguration) and
>     I'm stuck. Maybe there's someone on the list who can help?
>
>     I've determined that the client sends the ICMPv6 Router Solicitation
>     message and that it arrives at the server, but the server doesn't
>     respond.
>
>     It works fine for providing DNS servers and such if I use radvd for
>     stateless address autoconfiguration, but I'd like to setup _stateful_
>     configuration to test that our devices operate correctly in this mode.
>
>     The problem seems to be that the server doesn't listen on the raw
>     interface (it does for IPv4), so it probably doesn't receive the icmp
>     messages. It does listen on UDP port 547 using IPv6 and it does claim
>     to listen on the correct interface at start-up.
>
>     Any ideas? I can post details if anyone is interested.
>
>     Thanks
>
>     a.
>     _______________________________________________
>     PLUG discussion list: plug at plug.org.au <mailto:plug at plug.org.au>
>     http://lists.plug.org.au/mailman/listinfo/plug
>     Committee e-mail: committee at plug.org.au <mailto:committee at plug.org.au>
>     PLUG Membership: http://www.plug.org.au/membership
>
>
>
>
> -- 
> Onno Benschop
>
> ()/)/)()        ..ASCII for Onno..
> |>>?            ..EBCDIC for Onno..
> --- -. -. ---   ..Morse for Onno..
>
> If you need to know: "What computer should I buy?" http://goo.gl/spsb66
>
> ITmaze   -   ABN: 56 178 057 063   -  ph: 04 1219 8888   - 
> onno at itmaze.com.au <mailto:onno at itmaze.com.au>
>
>
> _______________________________________________
> PLUG discussion list: plug at plug.org.au
> http://lists.plug.org.au/mailman/listinfo/plug
> Committee e-mail: committee at plug.org.au
> PLUG Membership: http://www.plug.org.au/membership

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20140716/32802459/attachment.html>


More information about the plug mailing list