Linux comes with a firewall called netfilter, which is controlled by iptables. Here, I will explain the useful iptables commands for system admins and a super user with bash shell. Please remember that a wrong command will disconnect you from the system and will block your access to the server.
iptables -L -n
To display the iptables status and rules.
iptables -n -L -v –line-numbers
To inspect the firewall rules with line numbers.
service iptables start/stop/restart
To start / stop / restart iptables.
iptables -F – to flush the rules
iptables -X – to delete a chain rule.
iptables -D INPUT 4 – to delete the rule number 4.
iptables -L INPUT -n –line-numbers – to display the rules with line numbers.
iptables -A INPUT -s IP-address -j DROP – Rule for dropping connection from the IP-address.
Save the rules by the command,
service iptables save
man iptables – will give you a help section about how to use iptables commands.