Last active
April 4, 2017 11:03
-
-
Save jiri001meitner/efd4bc46b3632c2f93fba9075e3efd63 to your computer and use it in GitHub Desktop.
Dynv6 with teredo
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/bash | |
# This is a modified file /etc/network/if-up.d/miredo, replace it there. | |
#prerequisites: miredo autostart enabled, curl installed. | |
PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
ipv6=$(ip a | grep -s -i -o '200[1-2]\:[a-f0-9\.:]*' | head -n 1) | |
hostname="yourhostnameat.dynv6.net" | |
token="yourtokenatdynv6.net" | |
set -e | |
# Don't bother to reload when lo is configured. | |
if [ "$IFACE" = lo ]; then | |
exit 0 | |
fi | |
# Only run from ifup. | |
if [ "$MODE" != start ]; then | |
exit 0 | |
fi | |
# Miredo only cares about (underlying) IPv4 interfaces. | |
#if [ "$ADDRFAM" != inet ]; then | |
# exit 0 | |
#fi | |
# Actually, due to this bug: | |
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=475188 | |
# exclude IPX and IPv6 explicitly instead. | |
if [ "$ADDRFAM" = "ipx" ] || [ "$ADDRFAM" = "inet6" ]; then | |
ip -6 route add default dev teredo; | |
curl -m 30 "https://dynv6.com/api/update?hostname=$hostname.dynv6.net&ipv6=$ipv6&token=$token"; | |
ip -6 route add default dev teredo; | |
ip link set dev teredo mtu 1400; | |
ping6 teredo.nic.cz -i 30 &>/dev/null & | |
exit 0 | |
fi | |
# Is /usr mounted? | |
if [ ! -e /usr/sbin/miredo ]; then | |
exit 0 | |
fi | |
# Is the miredo service running? | |
if ! invoke-rc.d --quiet miredo status >/dev/null; then | |
exit 0 | |
fi | |
invoke-rc.d --quiet miredo reload || true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment