DD-WRT and HiNet dynamic IPv6 service

Based on Buffalo WZR-HP-G450H model, with firmware version: DD-WRT v3.0-r30357 std (12/20/17) from Buffalo.

HiNet service is PPPoE dynamic IPv4 and IPv6.

It’s quite simple at first place.

  1. Enable IPv6 support under Setup -> IPv6.
  2. Type is DHCPv6 with Prefix Delegation.
  3. The prefix is 64.
  4. Enable radvd.
  5. Enable custom radvd config too. Differences between auto-generated radvd config are auto prefix (::/64) and turn on DeprecatePrefix option.
interface br0
{
 IgnoreIfMissing on;
 AdvSendAdvert on;
 MinRtrAdvInterval 3;
 MaxRtrAdvInterval 10;
 AdvHomeAgentFlag off;
 AdvManagedFlag off;
 AdvOtherConfigFlag on;
 AdvLinkMTU 1492;
 prefix ::/64
 {
  AdvOnLink on;
  AdvAutonomous on;
  DeprecatePrefix on;
 };
 RDNSS 2001:b000:168::1 2001:b000:168::2 {};
};

So far so good, until HiNet drops your PPPoE connection then gives you a new IPv4 address and IPv6 prefix. Here is a simple workaround to deal with it, but you need to enable USB support and put a custom shell script in it.

I use an old 4G usb thumb drive, and format it to 3 partitions before plugging in the device. First partition is 512M swap, second is 3G ext2 for /opt, rest space is ext2 also, for /jffs.

On DD-WRT web interface, under Services -> USB, enable Core USB Support, USB Storage Support, and fill UUIDs for /opt and /jffs accordingly.

When all stuff ready, put a custom script: /jffs/etc/config/radvd.wanup

#!/bin/sh
LOGFILE=/dev/null
#LOGFILE can be anywhere in your /opt or /jffs.
PPP0=`ifconfig ppp0`
UPTIME=`uptime | grep '0 min'`
if [ -z "$UPTIME" ] && [ -n "$PPP0" ]; then
        echo -n "Log at ">> $LOGFILE
        date >> $LOGFILE
        uptime >> $LOGFILE
        sleep 3
        stopservice radvd
        sleep 1
        startservice radvd
        sleep 1
        grep radvd /var/log/messages | tail -6 >> $LOGFILE
fi

Using putty to telnet into your device, and using built-in vi should do the job. Don’t forget to chmod 700 for the script.

This script will be called when WAN is up. The first boot up (by checking the uptime output) is fine, so no need to restart radvd service. For rest WAN up events, this script will restart radvd AGAIN for you.

DD-WRT did the restart on WAN up events already, but most of the time this is done a little bit early when working with HiNet. You’ll see radvd complains something like

no auto-selected prefix on interface br0, disabling advertisements

and IPv6 for LAN is gone. So I put a few sleep to make sure this workaround really works.

For PPPoE fixed IP v4 service, the workaround described above is required too, since HiNet does not provide fixed v6 prefix for PPPoE customers yet.

BTW, since USB storage is used, Entware is strongly recommended. That’s why I leave larger space for /opt. For my device, using Atheros install link works just fine. You can also do many other things by checking the Script Execution instructions.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s