用Linux+Iptables构建防火墙实例
2007-07-13 12:46:43 来源:WEB开发网[root@jiaoyuang init.d]# ./iptables saveSaving current rules to /etc/sysconfig/iptables: [ OK ][root@jiaoyuang init.d]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.2.4 on Sat Sep 28 16:51:22 2002
*mangle
:PREROUTING ACCEPT [61522:8074850]
:OUTPUT ACCEPT [1079:79301]
COMMIT
# Completed on Sat Sep 28 16:51:22 2002
# Generated by iptables-save v1.2.4 on Sat Sep 28 16:51:22 2002
*nat
:PREROUTING ACCEPT [31850:5091703]
:POSTROUTING ACCEPT [20:1240]
:OUTPUT ACCEPT [12:776]
COMMIT
# Completed on Sat Sep 28 16:51:22 2002
# Generated by iptables-save v1.2.4 on Sat Sep 28 16:51:22 2002
*filter
:INPUT ACCEPT [61444:8070296]
:FORWARD ACCEPT [34:1984]
:OUTPUT ACCEPT [1079:79301]
COMMIT
安装并启动IPTABLES
在安装RedHat Linux V7.3后,iptables就已经被安装了,但默认启动的是ipchains。你在安装时所定义的一些规则也在/etc/sysconfig/ipchains中被定义。我们需要将其停止,才能启动iptables(注意:虽然不停止ipchains也可以启动iptables,但这时iptables并没有真正的起作用。Ipchains和iptables是两个防火墙,你只能选择一个)。
service ipchains stop (停止ipchains)
chkconfig --level 2345 ipchains off (使ipchains系统启动时不自动启动)
chkconfig --level 2345 iptables on (使iptables 在系统启动时自动启动)
vi /etc/rc.d/rc.local (编辑rc.local,将下面四行加到最后)
更多精彩
赞助商链接