Adding DHCPv6-PD support to DD-WRT

I got my new buffalo router this week, and surprisingly, no-one had documented how to do DHCPv6 with Prefix Delegation. I managed to get it working so I thought I would document it so others can find it.

Edit: I added a check to make sure dhcp6c is only running once. My router ended up running multiple copies and having them interfere with each other

Steps:

  1. Set up jffs. You’ll be using it through the rest of these steps
  2. Copy /usr/bin/ipkg /jffs
  3. Edit /jffs/ipkg and change
    IPKG_DIR_PREFIX=/usr/local/lib/ipkg
    to:
    IPKG_DIR_PREFIX=/jffs/usr/local/lib/ipkg
  4. Copy /etc/ipkg.conf /jffs
  5. Edit /jffs/ipkg.conf and add the following source:
    src openwrt-trunk http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
    comment out the whiterussian source.
  6. jffs update and install needed packges:
    # IPKG_CONF_DIR=/jffs /jffs ipkg update
    # IPKG_CONF_DIR=/jffs /jffs ipkg install wide-dhcpv6-client
    # IPKG_CONF_DIR=/jffs /jffs ipkg install rdisc6
  7. Put the following in /jffs/etc/config/dhcp6c.wanup:
    #!/bin/sh
    if [ ! -f /tmp/var/run/dhcp6c.pid ] ; then
      dhcp6c -c /jffs/etc/dhcp6/dhcp6c.conf -p /tmp/var/run/dhcp6c.pid vlan2
    fi
  8. Put the following in /jffs/etc/config/rdisc6.wanup:
    #!/bin/sh
    echo 2 > /proc/sys/net/ipv6/conf/vlan2/accept_ra
    rdisc6
  9. Make those scripts executable. # chmod 755 /jff/etc/config/*.wanup
  10. Put the following in /jffs/etc/dhcp6/dhcp6c.conf:
    interface vlan2 {
      send rapid-commit;
      send ia-pd 0;
      send ia-na 0;
      request domain-name-servers, domain-name;
      script "/jffs/etc/dhcp6/dhcp6c-script";
    };
    
    id-assoc pd 0 {
      prefix-interface br0 {
        sla-id 0;
        sla-len 0;
      };
    };
    
    id-assoc na 0 {};
  11. Put the following in /jffs/etc/dhcp6/dhcp6c-script:
    #!/bin/sh
    if [ -f /var/run/radvd.pid ] ; then
    	kill -HUP `cat /var/run/radvd.pid`;
    fi
  12. Make dhcp6c-script executable.
  13. Make sure ipv6 is enabled in the web interface, along with radvd. Put the following as radvd.conf:
    interface br0 {
      AdvSendAdvert on;
      prefix ::/64 {};
      RDNSS 2001:558:FEED::1 2001:558:FEED::2 {};
    };
    
  14. Replace the nameservers above if this isn’t for comcast. It’s probably possible with a little work to re-write radvd.conf dynamically based on the received dns servers. This works for now.
  15. Reboot

If you run into an issue following these steps, please contact me. Note that I tried several things first and attempted to distill the results down to instructions. It’s possible that in trying something, I did something relevant that I didn’t record here.

Advertisements