Is there any way to execute a local script on the router after the DDNS update service was executed?
As I'm running OpenWRT on a router with 4G and having a VPS, it's important to me, adding a firewall rule to the VPS in case OpenWRT DDNS service was running. In a perfect world just after detecting an IP change, but that just a bonus.
The option to execute another script would be good enough.
current.IP = ping -c 1 DDNS.FQ.DN | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1
while( true )
do
sleep( 60 )
new.IP = ping -c 1 DDNS.FQ.DN | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1
if current.IP <> new.IP
firewall open new.IP
firewall close current.IP
current.IP = new.IP
fi
done
on my VPS I've opened the public IPv4 ranges my cell phone operator uses, that's enough to keep 99.99% of internet out, and I don't have to play around with scripts.
That's a pretty good hint and saves me as well acting with any ugly individual scripts.
Doing now on each boot on the VPS:
ASN="AS35141 AS8717 AS24964 AS8672 AS12716 AS42157 AS29580 AS13124"
for asn in $ASN
do
for cidr in $(whois -h ``whois.radb.net`` -- "-i origin $asn" | grep -E '^route:' | awk '{print $2}')
do
ufw allow from "$cidr" to any comment "Allow via $asn"
done
done