Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Featured, Security

Remove Duplicate IPTables Rules

Submitted by on September 24, 2014 – 6:26 pm 4 Comments

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.

/sbin/service iptables save
/sbin/iptables-save | awk '/^COMMIT$/ { delete x; }; !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

 

Print Friendly, PDF & Email

4 Comments »

Leave a Reply

%d bloggers like this: