【问题标题】:iptables: allow OUTPUT only for http and ssh [closed]iptables:仅允许 http 和 ssh 输出 [关闭]
【发布时间】:2014-01-09 15:52:27
【问题描述】:

如何只允许 http 和 ssh 的传出流量?

我试过了:

 iptables -A OUTPUT -p tcp --dport ssh -j ACCEPT
 iptables -A OUTPUT -p tcp --dport http -j ACCEPT

但是一旦我添加了

iptables -A OUTPUT -j DROP

没有任何作用,它会阻止一切。

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:22151
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:sso-service
ACCEPT     all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere

【问题讨论】:

    标签: linux http ssh iptables


    【解决方案1】:

    尝试使用--sport 而不是--dport

    【讨论】:

      【解决方案2】:

      首先,您的 iptables 配置的输出与您输入的规则不匹配。您是否重新启动了 iptable 服务?其次,您需要允许端口 53 上的 udp 以使 DNS 也能正常工作:

       iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
      

      【讨论】:

        猜你喜欢
        • 2013-11-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-19
        • 1970-01-01
        • 2013-09-24
        相关资源
        最近更新 更多