Setting SSH Gateway with iptables


Case :
user smiertx allow access ssh and ping on 10.10.10.0/24 and 10.10.20.0/24 networks
user ikhyar only allow access ssh and ping on 10.10.10.11 and 10.10.20.11 servers

Edit iptables config file
# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
:smiertx - [0:0]
:ikhyar - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A OUTPUT -m owner --gid-owner smiertx -j smiertx
-A OUTPUT -m owner --gid-owner ikhyar -j ikhyar
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
-A smiertx -d 10.10.10.0/255.255.255.0 -j ACCEPT
-A smiertx -d 10.10.20.0/255.255.255.0 -j ACCEPT
-A smiertx -j DROP
-A ikhyar -d 10.10.10.11 -j ACCEPT
-A ikhyar -d 10.10.20.11 -j ACCEPT
-A ikhyar -j DROP
COMMIT

Restart iptables
# /etc/init.d/iptables restart

Make sure that iptables is running when booting
# chkconfig iptables on

Thanks to Mas Hansen n Mas Cahya for helping me.

Popular posts from this blog

Howto configure boot device order on ILOM

SAN Switch Config Command

Howto cstm on HP-UX