Remove Duplicate IPTables Rules
Written by BiRU Tuesday, 11 July 2017 16:04
Duplicate entries may appear in your iptables configuration due to parallel efforts of various network security-related applications that may be running on your server. In most cases, having duplicate iptables rules is no big deal, but sometimes they may become an annoyance. Here’s a list of commands you can run on your RHEL/CentOS system to de-dupe your iptables configuration.
1
2
3
4
5
6
7
|
/sbin/service iptables save
/sbin/iptables-save | awk '!x[$0]++' > /tmp/iptables.conf
/sbin/iptables -F
/sbin/iptables-restore < /tmp/iptables.conf
/sbin/service iptables save
/sbin/service iptables restart
if [ -f /tmp/iptables.conf ] ; then /bin/rm -f /tmp/iptables.conf ; fi
|