dhcpcd-discuss

6rd configuration script

Kristoffer Brånemyr

Sun May 06 17:03:28 2012

Hi,

I threw together a small script to configure IPv6 via 6rd information från dhcpcd. You must enable the option "sixrd" in dhcpcd.conf. I thought I might post it here if someone else could have some use for it. It will fail it your prefix lenght is anything else than 32 though... I put it in /lib/dhcpcd/dhcpcd-hooks/60-6rd. It seems to work well for me at least. Put together using information from http://www.litech.org/6rd/


----

# Configure the tunnel for 6rd
# By Kristoffer Brånemyr (2012)

set_sixrd()
{
        local ipv6=
        local tmp=
        local prefix=
        local prefix_len=

        ipv6=$(printf "%02x%02x:%02x%02x\n" $(echo $new_ip_address | sed "s/\./
/g"))
        tmp=$(echo $new_sixrd | cut -d" " -f3)
        prefix=$(echo $tmp | cut -d: -f1):$(echo $tmp | cut -d: -f2)
        prefix_len=$(echo $new_sixrd | cut -d" " -f2)

        ip addr add $prefix:$ipv6::1/64 dev $interface
        ip tunnel add 6rd mode sit local $new_ip_address ttl 64
        ip tunnel 6rd dev 6rd 6rd-prefix $prefix::/$prefix_len
        ip addr add $prefix:$ipv6::1/$prefix_len dev 6rd
        ip link set 6rd up
        ip route add ::/0 via ::$(echo $new_sixrd | cut -d" " -f4) dev 6rd
}

if $if_up && [ "$reason" = BOUND ]; then
        if [ -n "$new_sixrd" ]; then
                set_sixrd
        fi
fi


--------

 
-- 
/Kristoffer Brånemyr

Archive administrator: postmaster@marples.name