iptables and combining additional rule sources
aruna.hewapathirane at gmail.com
Sun Apr 26 08:42:18 EDT 2020
> The problem I am having is, adding the new information to the existing
> iptables rules in /etc/sysconfig/iptables. I want to write my rules to
> a separate file and then tell /etc/sysconfig/iptables to include it at
> the correct position.
> I read the iptables(8), iptables-save(8) and iptables-restore(8) man
> pages, but I don't see how to combine the different sources.
> How do I tell iptables to include a second external source at a
> specific location?
1 - Get the iptables rules list with the line numbers enabled
$ iptables -nL –line-numbers
2 - Look up the line number you want to use and insert your rule.
( I am inserting a rule at line number 10, the existing rule will
$ sudo /sbin/iptables -I INPUT 10 -s 220.127.116.11 -j DROP -m comment
--comment "DROP spam IP address - "
3 - Save the rules to a file in etc so you can reload them at the next
$ sudo /sbin/iptables-save > /etc/iptables.local
4 - To make the rules persistent, add the following rule to your
sudo /sbin/iptables-restore < /etc/iptables.local
If your system reboots you will not loose the rules now.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Kernelnewbies