I thought that if anyone else is on a dynamic endpoint and wants some examples of excellent update scripts then I have provided these which I wrote for my edge NETBSD edge router!
[example begin]
root@ultra30: echo 1.1.1.1 > last_ip
root@ultra30: ./ip_change.sh
[./ip_change.sh 16760] Last IP/Current IP: 1.1.1.1/24.162.235.19
[./ip_change.sh 16760] Updating network...
[/etc/scripts/update_tunnel.sh 16808] Updating he.net tunnel... 24.162.235.19
-ERROR: This tunnel is already associated with this IP address. Please try and limit your updates to IP changes.
[/etc/scripts/update_dns.sh 5493] Updating he.net dns...
[/etc/scripts/update_dns.sh 5493] ultra30.tptp.cc... nochg 24.162.235.19
[/etc/scripts/update_dns.sh 5493] v40z.tptp.cc... nochg 24.162.235.19
[/etc/scripts/update_dns.sh 5493] tptp.cc... nochg 24.162.235.19
add net default: gateway 2001:470:7:33e::1
net.inet6.ip6.forwarding: 1 -> 1
root@ultra30:
[example end]
[ip_change.sh begin]
#!/bin/sh
# handle an ip change
LAST_IP=$(cat /etc/scripts/last_ip)
MYIP=$(ifconfig hme1 | awk '/inet /' | awk '{ printf $2 }')
if [ "$MYIP" = "0.0.0.0" ]; then MYIP=$LAST_IP; fi
echo "[$0 $$] Last IP/Current IP: $LAST_IP/$MYIP"
if [ "$LAST_IP" = "$MYIP" ]; then echo "[$0 $$] No change.";
else echo "[$0 $$] Updating network..."
/etc/scripts/update_tunnel.sh
/etc/scripts/update_dns.sh
ifconfig gif0 down
ifconfig gif0 destroy
/etc/scripts/up_ipv6_interface.sh
echo -n $MYIP > /etc/scripts/last_ip;
exit 0
fi
exit 1
[ip_change.sh end]
[update_dns.sh begin]
#!/bin/sh
## update dns
echo "[$0 $$] Updating he.net dns..."
echo -n "[$0 $$] ultra30.tptp.cc... "
/usr/pkg/bin/curl -k -4 --retry 1112 -K /etc/scripts/HE_AUTH_CRED_1
echo ""
echo -n "[$0 $$] v40z.tptp.cc... "
/usr/pkg/bin/curl -k -4 --retry 1112 -K /etc/scripts/HE_AUTH_CRED_2
echo ""
echo -n "[$0 $$] tptp.cc... "
/usr/pkg/bin/curl -k -4 --retry 1112 -K /etc/scripts/HE_AUTH_CRED_3
echo ""
[update_dns.sh end]
[update_tunnel.sh begin]
#!/bin/sh
MYIP=$(ifconfig hme1 | awk '/inet /' | awk '{ printf $2 }')
if [ "$MYIP" = "0.0.0.0" ]; then MYIP=$LAST_IP; fi
echo "[$0 $$] Updating he.net tunnel... $MYIP"
/usr/pkg/bin/curl -k --retry 1024 -K /etc/scripts/HE_AUTH_CRED-TUNNEL
echo ""
[update_tunnel.sh end]
[up_ipv6_interface.sh begin]
#!/bin/sh
MYIP=$(ifconfig hme1 | awk '/inet /' | awk '{ printf $2 }')
if [ "$MYIP" = "0.0.0.0" ]; then MYIP=$(cat /etc/scripts/last_ip); fi
ifconfig gif0 create
ifconfig gif0 tunnel $MYIP 216.66.22.2
ifconfig gif0 inet6 2001:470:7:33e::2 2001:470:7:33e::1 prefixlen 128
route -n add -inet6 default 2001:470:7:33e::1
ifconfig gif0 inet6 alias 2001:470:e216::1
ifconfig gif0 inet6 alias 2001:470:e216::2
ifconfig gif0 inet6 alias 2001:470:e216::3
ifconfig gif0 inet6 alias 2001:470:e216::4
sysctl -w net.inet6.ip6.forwarding=1
[up_ipv6_interface.sh end]
Further more, you can either run ip_change.sh on a normal basis from crontab or via atd or somewhat, either that or you can do as I have and modify add a dhcpcd hook for RENEW and BOUND exceptions that will run the script, example:
[/libexec/dhcpcd-hooks/40-update-ip begin]
#!/bin/sh
if [ "$reason" = "BOUND" ] || [ "$reason" = "RENEW" ];
then if ! /etc/scripts/ip_change.sh;
then /etc/scripts/up_ipv6_interface.sh;
fi
fi
[/libexec/dhcpcd-hooks/40-update-ip end]
These are tools I wrote for the NetBSD sparcv9 edge router at tptp.cc !!
Yeah, you know, so like keep it pro, yo.
ip_change.sh - run from crontab or as dhcpcd hook, monitors for an ip change, touch /etc/scripts/last_ip
up_ipv6_interface.sh - runs from ip_change.sh and also the dhcpcd hook to up the ipv6 interfaces when apropriate
update_dns.sh - runs from ip_change.sh if there is an ip change, to update the he.net dns respectively
update_tunnel.sh - runs from ip_change.sh if there is an ip change, to update the he.net tunnel respectively
40-update-ip - hook for dhcpcd to run ip_cahnge.sh and up interfaces on new lease or bind, on netbsd: /libexec/dhcpcd-hooks/
The AUTH files are in the form of
url <url> # like for tunnel
https://ipv4.tunnelbroker.net/ipv4_end.php?tid=<tunnel id>
user <user>:<pass> # like for tunnel <he.net user>:<he.net password>
url <url> # like for dynamic dns
https://dyn.dns.he.net/nic/update?hostname=<hostname>
user <user>:<pass> # like for dns <hostname>:<key generated from he.net dns interface>
-- Infinity of teh ArkNet at tptp.cc [ first word at tptp.cc ]
http://tptp.cc/scriptz/he-net-scriptz.tar.xz 1.46 kB
Uther AWEZOME net script references hosted:
http://tptp.cc/scriptz/iptables.save.txt <iptables save from a linux install, has nat, port forward, filter, redirect, conn # rate limit>
http://tptp.cc/scriptz/tc.sh.txt <tc linux traffic control extensive packet scheduler and quality of service>
http://tptp.cc/scriptz/pf.conf.txt <NetBSD/FreeBSD/OpenBSD> packet filter, packet scheduler, qos, conn # rate limit>