What's new

IPSET rule keeps disappearing on AC68U

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

peraburek

Senior Member
Hello,

I am running Merlin Firmware Version: 384.18 on RT-AC68U

I want to allow only IPs from UptimeDoctor in order to check my Internet Connection every 60 seconds (1 minute interval) using ICMP (ping)

here is script I am using /jffs/scripts/ddns-start

Code:
#!/bin/sh

#whitelist uptimedoctor IPv4 for ICMP
curl https://www.uptimedoctor.com/de/network.php?type=xml > /mnt/sda1/router/uptimedoctor-raw.txt
cat /mnt/sda1/router/uptimedoctor-raw.txt | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])' > /mnt/sda1/router/uptimedoctor-ipv4.txt
sed -i -e 's/^/add uptimedoctor /' /mnt/sda1/router/uptimedoctor-ipv4.txt

if (ipset list | grep -c uptimedoctor)
#if the keyword is in the conent
then
echo "ipset list uptimedoctor found"
else
ipset create uptimedoctor hash:ip
fi

ipset restore -! < /mnt/sda1/router/uptimedoctor-ipv4.txt

if (iptables -nL | grep -c uptimedoctor)
#if the keyword is in the conent
then
echo "uptimedoctor found in iptables"
else
iptables -I INPUT -p icmp -m set --match-set uptimedoctor src -j ACCEPT
fi

#remove iptables rule and delete uptimedoctor ipset
#iptables -D INPUT -p icmp -m set --match-set uptimedoctor src -j ACCEPT
#ipset destroy uptimedoctor

Do you have any idea, why this rule keeps disappearing from iptables, it seems that router is deleting this ipset list on its own, for no reason?

Suggestions are welcome, in order to improve script and get this working stable. Thank you!
 
since I use DNS-O-Matic, I thought ddns-start would be OK place to store ipset commands

I have renamed/moved file
from /jffs/scripts/ddns-start
to /jffs/scripts/firewall-start

I will report here if it makes any improvement, thank you for sharing your idea!
 
you are right, it could be that router doesn't mount USB drive fast enough...
I will adjust script (path) and move files to /jffs folder
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top