How to check the rules of iptables in CentOS?
On CentOS and other Red Hat variants, iptables often comes with some pre-configured rules, check the current iptable rules using the following command. This will print out a list of three chains, input, forward and output, like the empty rules table example output below.
What do you need to know about iptables?
Iptables uses the concept of IP addresses, protocols (tcp, udp, icmp) and ports, meaning we can set up separate rules for specific combinations of those three.
How to remove a rule from an iptables chain?
sudo iptables -I INPUT 1 -p tcp –dport 80 -j ACCEPT If you wish to remove an existing rule from a certain chain, use the delete command with the parameter -D. The easiest way to select the rule for delete is to use the index numbers explained above. For example to delete the second rule on the input chain, use this command
Is it possible to flush all rules of an iptable?
It’s also possible to flush all rules of a specific chain or even the whole iptables using the -F -parameter. This is useful if you suspect iptables is interfering with your attempted network traffic, or you simply wish to start configuring again from a clean table.
Why is it not recommended to overwrite sysconfig / iptables file?
Because the tool called system-config-firewall (or it´s ncurses based brother system-config-firewall-tui) manages this file. Every time you use this tool to create new iptables rules, it will overwrite /etc/sysconfig/iptables. This is why it’s not recommended, but not prohibited.
How is / etc / iptables.current created at boot?
/etc/iptables.current is created at boot by copying /etc/iptables (which the iptables service is configured to load initially). This way I can modify things on the fly while maintaining a reference point that the system starts from.
Why are rules not reloading in iptables service?
After adding rules you have to do save before restart service or server. because when you add rule, they are in memory but after saving they will save in file and restore from that file at start-up. This will save all rules in /etc/sysconfig/iptables, then just enable the iptables service at start-up using: