我如何使用iptables拒绝所有stream量到localhost端口80,但允许从本地机器来的?

我如何使用iptables拒绝所有stream量到localhost端口80,但允许从本地机器来的?

这是我目前的解决scheme,似乎并没有阻止stream量。 ip,本地机器的ip。 如果我没有放第二线,所有的交通是封锁,并启用它,所有的stream量被接受?!

iptables -F iptables -X iptables -t nat -F iptables -t nat -X iptables -t mangle -F iptables -t mangle -X iptables -P INPUT ACCEPT iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT iptables -A INPUT -p tcp --dport 80 -s 127.0.0.1 -j ACCEPT iptables -A INPUT -p tcp --dport 80 -s 10.80.225.83 -j ACCEPT iptables -A INPUT -p tcp --dport 80 -j LOG --log-prefix "TCP LOGDROP: " 

只是要确定:

  • 10.80.225.83是Web服务器的IP地址,我希望能够访问127.0.0.1:80
  • 我希望10.80.225.83拒绝端口80上的任何连接,其他人则从本地主机发起。

 iptables -I INPUT ! -i lo -p tcp --dport 80 -j DROP 

当你的stream量从你的机器到你的机器,总是有input接口“LO”。 src或dst IP地址无关紧要。

如果可能,请提供/etc/sysconfig/iptables的全部内容吗? (如果信息可用,我会更新我的答案)

由于我必须假定没有默认的DROP规则,因此您需要:

 iptables -A INPUT -p tcp --dport 80 -s 127.0.0.1 -j ACCEPT iptables -A INPUT -p tcp --dport 80 -s 10.80.225.83 -j ACCEPT iptables -A INPUT -p tcp --dport 80 -j LOG --log-prefix "TCP LOGDROP: " 

iptables -A INPUT -p tcp –dport 80 -j DROP