IPv6 with CenturyLink Fiber


In case you want to know how to configure IPv6 using CenturyLink’s 6rd tunneling service.

There are four files to update with my script:

There are a couple of environment variables in /etc/default/centurylink-6rd that you will want to set. Mine looks like this:

LAN_IFACE="ens18,ens21,ens22"
HEADER_FILE=/etc/radvd.conf.header

The script will configure radvd to advertise v6 routes to a /64 of clients on each of the interfaces delimited by a comma in LAN_IFACE. Current interface limit is 9. I can patch something to go up to 0xff, but I don’t want to at this time.

If you have some static configuration that you want to preserve, place them into the file pointed to by ${HEADER_FILE} and it will be prepended to the generated /etc/radvd.conf file. The up script will remove the file and re-create it every time your ppp link comes up, so keep that in mind and don’t manually modify the file and expect it to perist. You’ve been warned :-)

So here’s the script. It’s also linked above if you want to curl it.

#!/bin/bash
#
# Copyright 2023 Collier Technologies LLC
# https://wp.c9h.org/cj/?p=1844
#

# # These variables are for the use of the scripts run by run-parts
# PPP_IFACE="$1"
# PPP_TTY="$2"
# PPP_SPEED="$3"
# PPP_LOCAL="$4"
# PPP_REMOTE="$5"
# PPP_IPPARAM="$6"

${PPP_IFACE:="ppp0"}
if [[ -z ${PPP_LOCAL} ]]; then
    PPP_LOCAL=$(curl -s https://icanhazip.com/)
fi

6rd_prefix="2602::/24"

#printf "%x%x:%x%x\n" $(echo $PPP_LOCAL | tr . ' ')

# This configuration option came from CenturyLink:
# https://www.centurylink.com/home/help/internet/modems-and-routers/advanced-setup/enable-ipv6.html
border_router=205.171.2.64

TUNIFACE=6rdif

first_ipv6_network=$(printf "2602:%02x:%02x%02x:%02x00::" $(echo ${PPP_LOCAL} | tr . ' '))

ip tunnel del ${TUNIFACE} 2>/dev/null
ip -l 5 -6 addr flush scope global dev ${IFACE}

ip tunnel add ${TUNIFACE} mode sit local ${PPP_LOCAL} remote ${border_router}
ip tunnel 6rd dev ${TUNIFACE} 6rd-prefix "${first_ipv6_network}0/64" 6rd-relay_prefix ${border_router}/32
ip link set up dev ${TUNIFACE}
ip -6 route add default dev ${TUNIFACE}

ip addr add ${first_ipv6_network}1/64 dev ${TUNIFACE}

rm /etc/radvd.conf
i=1
DEFAULT_FILE="/etc/default/centurylink-6rd"
if [[ -f ${DEFAULT_FILE} ]]; then
    source ${DEFAULT_FILE}
    if [[ -f ${HEADER_FILE} ]]; then
	cp ${HEADER_FILE} /etc/radvd.conf
    fi
else
    LAN_IFACE="setThis"
fi
   
for IFACE in $( echo ${LAN_IFACE} | tr , ' ' ) ; do

    ipv6_network=$(printf "2602:%02x:%02x%02x:%02x0${i}::" $(echo ${PPP_LOCAL} | tr . ' '))

    ip addr add ${ipv6_network}1/64 dev ${TUNIFACE}
    ip -6 route replace "${ipv6_network}/64" dev ${IFACE} metric 1

    echo "
interface ${IFACE} {
   AdvSendAdvert on;
   MinRtrAdvInterval 3;
   MaxRtrAdvInterval 10;
   AdvLinkMTU 1280;
   prefix ${ipv6_network}/64 {
     AdvOnLink on;
     AdvAutonomous on;
     AdvRouterAddr on;
     AdvValidLifetime 86400;
     AdvPreferredLifetime 86400;
   };
};
" >> /etc/radvd.conf

    let "i=i+1"
done

systemctl restart radvd
, , , , ,

Leave a Reply