telnetdoogie / UDMP-ipv6

Setting up a tunnelbroker ipv6 tunnel on a Ubiquiti Dream Machine Pro
31 stars 1 forks source link

Scripts don't account for if your WAN IP changes during usage #1

Open telnetdoogie opened 2 years ago

telnetdoogie commented 2 years ago

If your WAN ip changes, the tunnel will stop working and getting it set up again requires deleting the tunnel interface and re-creating it. (annoying)

There's probably an elegant way (perhaps à la inadyn and it's use of /.inadyn/all.dnsomatic.com.cache or similar) to check for and detect a change to the WAN IP periodically and if it's changed, remove and re-create the he-ipv6 interface.

MrMarvin commented 10 months ago

Here is my hack-y workaround. Relying on pinging the tunnel remote end on the minutely cron job and recreating the tunnel if that fails. It isn't great, but works ok for my use case.

root@UDM-SE:~# cat /data/cronjobs/update_ipv6_chains
MAILTO=""
* * * * * root /data/ipv6/configure-he-ipv6-chains.sh | /usr/bin/logger
* * * * * root /data/ipv6/reset_tunnel.sh | /usr/bin/logger

root@UDM-SE:~# cat /data/ipv6/reset_tunnel.sh
#!/bin/bash
if $(ping -c3 -q $(grep '^LOCAL_IPV6=' /data/ipv6/enable-he-ipv6.sh | grep -Eo '([0-9a-f:]{4,})' | sed 's/::2/::1/') > /dev/null); then
    echo 'Tunnel he-ipv6 ok';
 else
    ip tunnel del he-ipv6
    bash /data/ipv6/enable-he-ipv6.sh
 fi
telnetdoogie commented 10 months ago

@MrMarvin this is awesome! Mind if I add this to the repo (I'll add your @ to the comments and contributors) Alternatively, if you want to push a PR to the repo I'll add it

telnetdoogie commented 10 months ago

Might be nice to add this to configure-he-ipv6-chains.sh so two conditions are checked at the same time... The iptables changes, and also the connectivity, and then resolving those in the appropriate order if one or both appears to need attention. This is really good! Then only one cron entry is needed, maybe I could rename configure-he-ipv6-chains.sh to a more appropriate maintain-he-ipv6-tunnel.sh at that point.

mikaeldui commented 8 months ago

ip monitor address could be a possible trigger.

https://unix.stackexchange.com/questions/552258/ip-monitor-responding-to-events