LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 770|回复: 2

请教一个防火墙的问题

[复制链接]
发表于 2005-10-24 11:31:59 | 显示全部楼层 |阅读模式
有一台计算机上,运行着HTTP,POP3,SMTP和SSH服务,需要让外网访问本地的四个服务,同时本机可以访问任何的的IP。

以下是书上给出的配置脚本:
防火墙规则如下:
#!/bin/bash
#Standalone Host#
#Flush all chains
iptables -F
iptables -t nat -F
#Set the default policies
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -p FORWARD DROP
#Allow all outgoing Internet access
iptables -A OUTPUT -i eth0 -s LinuxFirewall -d 0/0 -j ACCEPT
iptables -A INPUT -m state -state ESTABLISHED,RELATED -j ACCEPT
#Allow incoming SSH access to this host
iptables -A INPUT -i eth0 -p tcp -tcp-flags SYN -s 0/0 -d LinuxFirewall -dport ssh -j ACCEPT
#Allow HTTP,SMTP,POP3 access to this host
iptables -A INPUT -i eth0 -p -tcp-flags SYN -s 0/0 -d LinuxFirewall -dport http -j ACCEPT
iptables -A INPUT -i eth0 -p -tcp-flags SYN -s 0/0 -d LinuxFirewall -dport smtp -j ACCEPT
iptables -A INPUT -i eth0 -p -tcp-flags SYN -s 0/0 -d LinuxFirewall -dport pop3 -j ACCEPT

请问,以上中iptables -A INPUT -m state -state ESTABLISHED,RELATED -j ACCEPT的具体含义是什么,我只知道是开放一个返回的端口,但不太理解。为什么只有第一条规则有一个返回端口,后面的规则都没有。
发表于 2005-10-24 15:29:09 | 显示全部楼层
iptables -A INPUT -m state -state ESTABLISHED,RELATED -j ACCEPT
在input链中,启用模块state,任何状态为ESTABLISHED,RELATED的数据连接都jump到target accept
你是不是打错了?
iptables -A OUTPUT -i eth0 -s LinuxFirewall -d 0/0 -j ACCEPT
按照iptables的文档这条规则基本废了
如下:packets traversing the OUTPUT chain don't have an input interface, so any rule using `-i' in this chain will never match.
下面4条开放4个端口,第一条为了保证建立连接后的数据流不会给包过滤
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-24 17:26:38 | 显示全部楼层
书上有这样一条解释,说是把网络接口写全,为了以后再加网卡的时候,不容易发生混乱。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表