you have tried blockhosts, denyhosts, fail2ban, and they can still be annoying.an alternative is to use some feature or features of iptables.On Cent OS 6, the default firewall program is iptables.

updating iptables-47updating iptables-21updating iptables-67

We can use a firewall along with other safety measures to protect our servers from hackers' pries and attacks.

The design of a firewall can be either dedicated hardware or a software program running on our machine.

Firewall decides fate of packets incoming and outgoing in system.

IPTables is a rule based firewall and it is pre-installed on most of Linux operating system. IPTables was included in Kernel 2.4, prior it was called ipchains or ipfwadm.

Below command save TPTables rulesets in /etc/sysconfig/iptables file by default and rules are applied or restored in case of IPTables flushes out.

[[email protected] ~]# iptables -L -n -v Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 6 396 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED, ESTABLISHED 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT 5 packets, 588 bytes) pkts bytes target prot opt in out source destination[[email protected] ~]# iptables -n -L -v --line-numbers Chain INPUT (policy ACCEPT 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination 1 51 4080 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED, ESTABLISHED 2 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 3 0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 4 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 5 0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination 1 0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT 45 packets, 5384 bytes) num pkts bytes target prot opt in out source destination[[email protected] ~]# iptables -L INPUT -n --line-numbers Chain INPUT (policy ACCEPT) num target prot opt source destination 1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED, ESTABLISHED 2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited View all Posts Ravi Saive I am Ravi Saive, creator of Tec Mint.

If the address has not gone up to 5 hits, it passes through and gets ACCEPTed.

This tutorial guides you how firewall works in Linux Operating system and what is IPTables in Linux?

Different services is used for different protocols as: Saving IPTables rulesets with below command.