Allowing ssh in iptables
Posted
by
sat
on Server Fault
See other posts from Server Fault
or by sat
Published on 2013-11-04T06:48:05Z
Indexed on
2013/11/04
9:59 UTC
Read the original article
Hit count: 143
I am doing iptables
firewall configuration. Actually, I need to allow ssh
connection only from particular IP. But, It is blocking the ssh connection.
I used the below commands.
sat:~# iptables -F
sat:~# iptables -A INPUT -p tcp -s src_ip_address -d my_ip_address --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
sat:~# iptables -A INPUT -j DROP
sat:~# iptables -nL
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- src_ip_address my_ip_address tcp dpt:22 state NEW,ESTABLISHED
DROP all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
If I try to connect from src_ip_address to my_ip_address, it is blocking the connection. Even, It is blocking from my_ip_address to src_ip_address . I haven't put any rules for OUTPUT chain.
What is wrong with my commands?
How to allow ssh in iptables?
© Server Fault or respective owner