2014-10-29 53 views
-1

我想使用iptables來阻止所有傳入流量,但另一方面我想將所有傳出流量列入白名單。目前,我的iptables阻止我所有的傳出流量。我如何將這個白名單列入?如何阻止傳出流量?

iptables規則

iptables -F 

iptables -P OUTPUT DROP 
iptables -P INPUT DROP 
iptables -P FORWARD DROP 

iptables -A OUTPUT -o enp0s18 -j ACCEPT 

iptables -I INPUT -p tcp --dport 26666 -j ACCEPT 

的iptables -L

Chain INPUT (policy DROP) 
target  prot opt source    destination 
ACCEPT  tcp -- anywhere    anywhere    tcp dpt:26666 

Chain FORWARD (policy DROP) 
target  prot opt source    destination 

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

但它不工作:

curl http://google.com 
curl: (6) Couldn't resolve host 'google.com' 

有什麼不對?

回答

2

它不阻止出站流量;你只是阻止作爲響應的入站數據(具體來說,在這種情況下,DNS服務器的響應)。

一下添加到年底允許ESTABLISHEDRELATED數據通過INPUT鏈進來:

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT 

Here's的explainshell.com鏈接,將引導您完成該規則做什麼。

+0

非常感謝:)現在有效:) – Hanashi 2014-10-29 07:55:13