iptables 允许 A -> B:22 , B -> 任何位置:22

iptables 允许 A -> B:22 , B -> 任何位置:22

我想要 iptables 规则,让服务器允许来自特定主机的传入 ssh,同时该服务器可以连接任何目的地的 ssh,然后阻止任何其他进出流量

提前致谢,

答案1

六、/etc/sysconfig/iptables

然后加:

-A INPUT -i eth0 -s 100.101.102.103/32 -p tcp -m tcp --dport 22 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "SSH inbound" -j ACCEPT 
-A INPUT -j DROP
-A OUTPUT -o eth0 -p tcp --sport 22 -m state --state RELATED,ESTABLISHED -m comment --comment "SSH outbound" -j ACCEPT
-A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "General SSH outbound" -j ACCEPT

将 100.101.102.103 替换为您需要的任何 IP 地址

相关内容