Script for adding "iptables -A INPUT" and "iptables -I FORWARD"

I have a simple question.

I use this iptable for denying and IP accessing me in anyway:

iptables -A INPUT -s XX.XXX.XX.XX-j DROP
iptables -I FORWARD -d XX.XXX.XX.XX-j DROP

So my question is: Is there a way to make a script that automatically checks for IP added in a file. Example:

I create a script in Firewall>Custom Rules and a file blockedips.txt and put it in /etc/config/ (for example, could be anywhere). So it there a way to make a script that will read the IPs from this particular txt file and the only thing i must do is add the IP in the same txt file.


So I managed to do something like this and it's working.

for x in $(cat /etc/config/blacklistips)
iptables -A INPUT -s $x -j DROP
iptables -I FORWARD -d $x -j DROP

The question now is: Is there a way for the firewall automatically (somehow) to restart when I add/remove and IP.

You could add:

/etc/init.d/firewall restart

after your loop.

Warning: Unable to locate ipset utility, disabling ipset support

That's what I get.