niels / Hardware / #linux,#router

ExtraIP.com and UDM Pro

Heads up! This post is more than a year old.

The Script

Place the script below in /mnt/data/on_boot.d and call it extraip.sh.

Replace the necessary values with those provided to you by extraip.com.

#!/bin/sh

#####################
### CONFIGURATION ###
#####################

LAN_INTERFACE=br0

# IPv6 "Interconnect" subnet (/64)
IPV6_WAN_ENDPOINT=185.40.xx.xx
IPV6_WAN_IP=2a03:10c3:xx:xx::2/64

# IPv6 routed subnet (/48)
IPV6_LAN_SUBNET=2a03:10c3:xx::
IPV6_LAN_IP_ADDRESS=2a03:10c3:xx::1/48

# Actual IPv4 subnet
IPV4_WAN_ENDPOINT=185.40.xx.xx
IPV4_LAN_SUBNET=37.148.xx.xx/29

###################
### IPv6 TUNNEL ###
###################

ip l set dev sit0 down

ip t a sit1 mode sit ttl 64 remote ${IPV6_WAN_ENDPOINT} 
ip a a ${IPV6_WAN_IP} dev sit1
ip l set dev sit1 up
ip -6 r r ::/0 dev sit1 

################
### IPv6 LAN ###
################

ip a a ${IPV6_LAN_IP_ADDRESS} dev ${LAN_INTERFACE}

cat > /run/dnsmasq.conf.d/slaac.conf <<EOF
interface=${LAN_INTERFACE}
dhcp-range=${IPV6_LAN_SUBNET},ra-stateless,ra-names
enable-ra
EOF

start-stop-daemon -K -q -x /usr/sbin/dnsmasq
sleep 1
start-stop-daemon -S -q -x /usr/sbin/dnsmasq

###################
### IPv4 TUNNEL ###
###################

ip t del tun_extra_ip > /dev/null 2>&1
ip t add tun_extra_ip mode gre remote ${IPV4_WAN_ENDPOINT} ttl 225  
ip l set dev tun_extra_ip up

################
### IPv4 LAN ###
################

ip r a ${IPV4_LAN_SUBNET} dev ${LAN_INTERFACE} table 911
ip r a default dev tun_extra_ip table 911
ip ru d from ${IPV4_LAN_SUBNET} lookup 911 > /dev/null 2>&1
ip ru a from ${IPV4_LAN_SUBNET} lookup 911
ip ru d to ${IPV4_LAN_SUBNET} lookup 911 > /dev/null 2>&1
ip ru a to ${IPV4_LAN_SUBNET} lookup 911

Don’t forget to make the script executable:

chmod +x /mnt/data/on_boot.d/extraip.sh

You may now manually run the script, to see if it works:

/mnt/data/on_boot.d/extraip.sh

If you run the script multiple times in a row, you will see some errors. This is expected as you are creating thing that already exist:

add tunnel "sit0" failed: No buffer space available
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists

HE.net Tunnelbroker

If you don’t need an IPv4 subnet and just want to add IPv6 to your network, I recommend checking out tunnelbroker.net.

In my experience the HE.net tunnelbroker is occasionally congested but works well >99% of the time.

0 comments