2013-08-20 12:07:55 +0000 2013-08-20 12:07:55 +0000
34
34
Advertisement

需要iptables规则来接受所有传入的流量

Advertisement

我的测试环境中,我想接受所有传入的流量,请问有谁能给我添加一个iptable规则。 0/0 tcp dpt:2124

Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all – 0.0.0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT) target prot opt source destination

Thanks

Advertisement
Advertisement

答案 (2)

54
54
54
2013-08-20 16:20:23 +0000

运行下面的规则。它将把这个规则插入到你的iptables的顶部,并允许所有的流量,除非随后由其他规则处理。

iptables -I INPUT -j ACCEPT
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设置:

iptables -A INPUT -i lo -j ACCEPT -m comment --comment "Allow all loopback traffic"
iptables -A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT -m comment --comment "Drop all traffic to 127 that doesn't use lo"
iptables -A OUTPUT -j ACCEPT -m comment --comment "Accept all outgoing"
iptables -A INPUT -j ACCEPT -m comment --comment "Accept all incoming"
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -m comment --comment "Allow all incoming on established connections"
iptables -A INPUT -j REJECT -m comment --comment "Reject all incoming"
iptables -A FORWARD -j REJECT -m comment --comment "Reject all forwarded"

如果你要冲洗,你可能会想运行类似的东西。

iptables -I INPUT -p tcp --dport 80 -j ACCEPT -m comment --comment "Allow HTTP"
iptables -I INPUT -p tcp --dport 443 -j ACCEPT -m comment --comment "Allow HTTPS"
iptables -I INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT -m comment --comment "Allow SSH"
iptables -I INPUT -p tcp --dport 8071:8079 -j ACCEPT -m comment --comment "Allow torrents"
iptables-save > /etc/network/iptables.rules #Or wherever your iptables.rules file is

如果你想让你的流量更安全一点,不要使用 accept all incoming 规则,或者用 “iptables -D INPUT -j ACCEPT -m comment –注释 "Accept all incoming "来删除它,然后添加更多的具体规则,比如:

&001

注意:它们需要在底部的两个拒绝规则上面,所以用 I 来插入顶部。或者,如果你像我一样爱分析,用 "iptables -nL –line-numbers "得到行号,然后用 "iptables -I INPUT … "在特定的行号处插入规则。

16
16
16
2013-08-20 13:24:49 +0000

要接受所有入网流量,可以使用以下命令,-P是将默认策略设置为接受

iptables -P INPUT ACCEPT

,如果你不需要以前的规则,只需刷新/删除这些规则,然后使用上述命令。

Advertisement

相关问题

6
10
5
37
3
Advertisement