Created
January 28, 2021 20:59
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Sonic & he.net tunnel configuration script, appropriate for usage in | |
# dhcp-exit-hooks. Tested on FreeBSD 12.2-STABLE | |
set -x -u -e | |
if [ "$1" = "he" ]; then | |
server_v4="72.52.104.74" | |
server_v6="2001:470:803d::1" | |
client_v6="2001:470:803d::2" | |
prefixlen=128 | |
int_gateway="2001:470:803d:1024::1" | |
lab_gateway="2001:470:803d:cafe::1" | |
elif [ "$1" = "sonic" ]; then | |
server_v4="208.201.234.221" | |
server_v6="2001:05a8:0000:0001:0000:0000:0000:28aa" | |
client_v6="2001:05a8:0000:0001:0000:0000:0000:28ab" | |
prefixlen=127 | |
int_gateway="2001:5a8:4:320::1" | |
lab_gateway="2001:5a8:4:321::1" | |
else | |
echo "please specify 'he' or 'sonic'" | |
fi | |
# DHCP makes me sad | |
client_v4=$(ifconfig em2| grep inet | awk '{print $2 }') | |
# Configure internal gateway IP's | |
ifconfig igb0 inet6 "${int_gateway}" prefixlen 64 | |
ifconfig em0 inet6 "${lab_gateway}" prefixlen 64 | |
ifconfig gif0 destroy | |
ifconfig gif0 create | |
ifconfig gif0 tunnel "${client_v4}" "${server_v4}" | |
# This seems crazy - is it necessary? | |
if [ "${prefixlen}" = 128 ]; then | |
ifconfig gif0 inet6 "${client_v6}" "${server_v6}" prefixlen "${prefixlen}" | |
else | |
ifconfig gif0 inet6 "${client_v6}/${prefixlen}" | |
fi | |
route -n add -inet6 default "${server_v6}" | |
ifconfig gif0 up | |
echo "${int_gateway} and ${lab_gateway} should be routable" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment