iptables

vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter

:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]

-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT

-A INPUT -i eth0 -p tcp –dport 20:21 -j ACCEPT #vsftpd
-A INPUT -i eth0 -p tcp –dport 22 -j ACCEPT
-A INPUT -i eth0 -p tcp –dport 25 -j ACCEPT #postfix
-A INPUT -i eth0 -p tcp –dport 80 -j ACCEPT
-A INPUT -i eth0 -p tcp –dport 110 -j ACCEPT #postfix
-A INPUT -i eth0 -p tcp –dport 143 -j ACCEPT #postfix
-A INPUT -i eth0 -p tcp –dport 65400:65410 -j ACCEPT #vsftpd

-A INPUT -i eth0 -m state –state RELATED,RELATED -j ACCEPT
-A INPUT -i eth0 -m state –state NEW,INVALID -j DROP

#-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
#-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
#-A INPUT -m state –state NEW -m tcp -p tcp –dport 25 -j ACCEPT
#-A INPUT -m state –state NEW -m tcp -p tcp –dport 110 -j ACCEPT
#-A INPUT -m state –state NEW -m tcp -p tcp –dport 143 -j ACCEPT
#-A INPUT -j REJECT –reject-with icmp-host-prohibited
#-A FORWARD -j REJECT –reject-with icmp-host-prohibited

COMMIT

chkconfig –list |grep iptables

iptables        0:關閉  1:關閉  2:開啟  3:開啟  4:開啟  5:開啟 6:關閉

/etc/rc.d/init.d/iptables start           //啟動 iptables 服務
/etc/rc.d/init.d/iptables stop            //停止 iptables 服務
/etc/rc.d/init.d/iptables restart         //重新啟動 iptables 服務
/etc/rc.d/init.d/iptables status          //查看目前 iptables 規則
/etc/rc.d/init.d/iptables save            //將目前規則存入 iptables 設定檔

 

本篇發表於 Linux。將永久鏈結加入書籤。

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>