2012-12-31 102 views
0

OUTPUT如何允許傳出TRAFIC僅對HTTP和SSH?iptables的:只允許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 

回答

2

嘗試用--sport而不是--dport

2

首先,你的iptables配置的輸出不匹配您鍵入的規則。你重新啓動iptable的服務?其次,你需要允許端口53上的UDP進行DNS的工作,以及:

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