Linux 的内置firewall机制,是通过kernel中的netfilter模块实现的(www.netfilter.ort)。Linux kernel使用netfilter对进出的数据包进行过滤,netfilter由三个规则表组成,每个表又有许多内建的链组成。通过使用iptables命令可以对这些表链进行操作,如添加、删除和列出规则等。
二. Ubuntu Server中的Iptables Ubuntu Server6.06中已经默认安装iptables,版本是1.3.3.默认状态是关闭。 通过修改/etc/network/interfaces可将iptables打开: auto lo
Iface lo inet loopback
auto eth0 iface eth0 inet dhcp #添加以下内容 pre-up iptables-restore < /etc/iptables.up.rule #call the restored rule when active the eth0 post-down iptables-save > /etc/iptables.up.rule #restore the iptables rule when shutdown the interface eth0 然后重新激活eth0即可。 另外,可随时修改/etc/iptables.up.rule配置文件,来更改iptables的规则。Iptables.up.rule格式如下: #Generated by iptables-save V1.3.3 on Tue Jul 31 14:18:44 2007 *filter :INPUT ACCEPT [73:8213] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [8:825] -A INPUT –i lo –p icmp –j DROP -A INPUT –i eth0 –p icmp –j DROP COMMIT #Completed on Tue Jul 31 14:10:44 2007 行与行之间不能有空行。