標題: Firewall 一問 [打印本頁]
作者: milanolarry 時間: 2015-4-27 15:09 標題: Firewall 一問
本帖最後由 milanolarry 於 2015-4-27 16:14 編輯
我 set 起左個 vpn ,跟 instruction 響個 iptables 開左 個 port 同做左 forward,行起黎都冇問題。
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 1194 -j ACCEPT
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
問題係當我用 iptables -L 睇個 iptable 既時候,發覺所有野根本係 ACCEPT,包括 input,output 同 forward。咁係咪即係話我個 firewall 根本就冇柵,開吾開 port ,做吾做 forward 都冇分別?另外,如果要封左個 wan (但要保持 port 1194開放),可以用乜野 command? 我試過用
iptables -A INPUT -j REJECT
結果就乜都封曬,連個 vpn 都入吾翻!
作者: sunlite 時間: 2015-4-27 16:50
回覆 1# milanolarry
You need to set the default policy to drop first:
iptables -P INPUT DROP
iptables -P FORWARD DROP
Don't set the output policy to drop unless you know what you are doing.
After that, make sure to save your rules, usually
/sbin/iptables-save > /etc/sysconfig/iptables
or
service iptables save
作者: milanolarry 時間: 2015-4-29 12:33
新手一名。有問題如下:
1. 曾經加入 iptables -P INPUT -j DROP ,結果乜野都封曬。吾知小左 -j 會有乜野分別?
2. iptables -P INPUT DROP 應該加響其他 input rules 既前面定後面?放響吾同位置會吾會有分別?
吾該。
