Skip to main content

ipv6 workaround for Unifi USG on 2 Degrees UFB

ยท 2 min read

I had an issue where our USG Pro was not getting ipv6 from 2 Degrees UFB after upgrading our Controller to 5.8. After a lot of messing around with this, I found a workaround originally posted here: https://community.ubnt.com/t5/UniFi-Routing-Switching/USG-DHCPv6-PD-bug-when-using-PPPoE/td-p/2487710.

Digging into the dhcpv6-pd logs shows this:

admin@SecurityGateway:~$ show dhcpv6-pd log
Sep/12/2018 08:14:08: dhcp6_ctl_init: bind(control sock): Address already in use
Sep/12/2018 08:14:08: client6_init: failed to initialize control channel

Dumping out the config I saw that I had two dhcpv6-pd blocks, one under interface eth2 vif 10 and the other under interface eth2 vif 10 pppoe 2 (where it should be):

mca-ctrl -t dump-cfg

"eth2": {
"description": "WAN",
"vif": {
"10": {
"description": "WAN",
"dhcpv6-pd": {
"pd": {
"0": {
"interface": {
"eth0": "''"
},
"prefix-length": "56"
}
},
"rapid-commit": "enable"
},
"firewall": {
"in": {
"ipv6-name": "WANv6_IN",
"name": "WAN_IN"
},
"local": {
"ipv6-name": "WANv6_LOCAL",
"name": "WAN_LOCAL"
},
"out": {
"ipv6-name": "WANv6_OUT",
"name": "WAN_OUT"
}
},
"pppoe": {
"2": {
"default-route": "none",
"dhcpv6-pd": {
"pd": {
"0": {
"interface": {
"eth0": "''"
},
"prefix-length": "56"
}
},
"rapid-commit": "enable"
},
"firewall": {
"in": {
"ipv6-name": "WANv6_IN",
"name": "WAN_IN"
},
"local": {
"ipv6-name": "WANv6_LOCAL",
"name": "WAN_LOCAL"
},
"out": {
"ipv6-name": "WANv6_OUT",
"name": "WAN_OUT"
}
},
"ipv6": {
"address": "autoconf",
"enable": "''"
},
"name-server": "none",
"password": "<password>",
"user-id": "<username>"
}
}
}
}
}

It was possible to temporarily fix this issue by removing the first block:

configure
delete interfaces ethernet eth2 vif 10 dhcpv6-pd
commit
exit

release dhcpv6-pd interface pppoe2
delete dhcpv6-pd duid
renew dhcpv6-pd interface pppoe2

This allowed our USG to get ipv6 from our ISP and now all the clients on the network also got ipv6.

To make this more permanent I had to add this file on the USG under /config/scripts/post-config.d/dhcp.sh

#!/bin/vbash

readonly logFile="/var/log/postprovision.log"

source /opt/vyatta/etc/functions/script-template

configure > ${logFile}

delete system task-scheduler task postprovision >> ${logFile}

delete interfaces ethernet eth2 vif 10 dhcpv6-pd >> ${logFile}
commit
exit

release dhcpv6-pd interface pppoe2 >> ${logFile}
delete dhcpv6-pd duid >> ${logFile}
renew dhcpv6-pd interface pppoe2 >> ${logFile}

To run this script, I added the following on the Controller in /usr/lib/unifi/data/sites/default/config.gateway.json:

{
"system":{
"task-scheduler":{
"task":{
"postprovision":{
"executable":{
"path":"/config/scripts/post-config.d/dhcp.sh"
},
"interval":"2m"
}
}
}
}
}

This runs the dhcp.sh script 2 minutes after provisioning and then the script removes the scheduled task (as it only needs to run once).