Think before you speak, read before you think.

centos6.2基本iptables模版

vim /etc/sysconfig/iptables

# Generated by iptables-save v1.4.7 on Mon Mar 26 09:52:21 2012
*filter
:INPUT ACCEPT [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 -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Mon Mar 26 09:52:21 2012

-A 选项来附加(新增)规则到某条链

-i 选项(interface「界面」之意)来指定那些符合或来自 lo(localhost、127.0.0.1)界面的封包

-j(jump「跳至」)符合这条规则的目标动作

-m 选项来装入一个模块(state)。state 模块能够查看一个封包并判断它的状态是 NEW、ESTABLISHED 抑或 RELATED。NEW 指进入的封包属于不是由主机初始化的新增连接。ESTABLISHED 及 RELATED 指进入的封包隶属于一条现存的连接,或者与现存的连接有关系。


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *