[CentOS] iptables rules

Barry Brimer barry.brimer at bigfoot.com
Tue May 23 13:50:06 UTC 2006

> I have 2 CentOS servers &
> I want to deny all ssh logins on port 22 on ( from any host 
> except from (
> Can anybody tell me such iptables rules to write in /etc/sysconfig/iptables
> Currently, im using the following rules (on
> *filter
> :RH-Firewall-1-INPUT - [0:0]
> -A INPUT -j RH-Firewall-1-INPUT
> -A FORWARD -j RH-Firewall-1-INPUT
> -A RH-Firewall-1-INPUT -i lo -j ACCEPT
> -A RH-Firewall-1-INPUT -i eth1 -j ACCEPT
> -A RH-Firewall-1-INPUT -i eth0 -s -j ACCEPT
> -A RH-Firewall-1-INPUT -m tcp -p tcp --dport 22 -j REJECT
> -A RH-Firewall-1-INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
> -A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
> -A RH-Firewall-1-INPUT -i eth0 -j ACCEPT
> -A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited

iptables is a first-match wins firewall.  The rule above that mentions the will accept all traffic from that IP address.  The rule 
below it seems a little vague.  I might change that to:

-A RH-Firewall-1-INPUT -m tcp -p tcp -i eth0 -d --dport 22 -j 

Hope this helps.


More information about the CentOS mailing list