LinuxSir.cn,穿越时空的Linuxsir!

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

应用防火墙规则后,dns无法解析,是何道理?

[复制链接]
发表于 2005-8-23 16:27:16 | 显示全部楼层 |阅读模式
一台linux服务器为内网做nat共享宽带,还开samba服务

但自从防火墙删掉-i eth0 -j ACCEPT这条规则后,内网机器就无法访问网页
内网机器对外网dns的ip能ping通,但输入域名就不行,我猜是dns的问题

另外,samba共享文件夹也无法正常访问,必须输入ip地址才能访问,比如浏览器地址栏输入:\\192.168.0.1

不知道是什么地方的问题,请大家帮忙解答一下,先谢!

以下是我的防火墙规则:

]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain RH-Firewall-1-INPUT (2 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere            icmp any
ACCEPT     ipv6-crypt--  anywhere             anywhere
ACCEPT     ipv6-auth--  anywhere             anywhere
ACCEPT     udp  --  anywhere             224.0.0.251         udp dpt:5353
ACCEPT     udp  --  anywhere             anywhere            udp dpt:ipp
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:microsoft-ds
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:netbios-ssn
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:https
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:mysql
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:cvspserver
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpts:6881:6889
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpts:2101:2121
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:14672
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:14662
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
发表于 2005-8-23 16:55:32 | 显示全部楼层
DNS 不能解析应该是因为这一行吧。
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:5353

DNS(domain) 用的是udp53, 不是5353

SAMBA的PORT.
netbios-ns        137/tcp                                # NETBIOS Name Service
netbios-ns        137/udp
netbios-dgm        138/tcp                                # NETBIOS Datagram Service
netbios-dgm        138/udp
netbios-ssn        139/tcp                                # NETBIOS session service
netbios-ssn        139/udp

不过我觉得你这样写是不是从internet上都可以访问你的samba
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:microsoft-ds
ACCEPT udp -- anywhere anywhere state NEW udp dpt:netbios-ssn


最后,你为什么非要把eth0那一行去掉呢? 相信eth0就是连接你们局域网的网卡吧。不信任?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-23 17:13:26 | 显示全部楼层
eth0小区宽待内网,虽然说是邻居,但放人之心不可无
samba端口外网应该访问不到,因为我加了-i eth0参数,外网接口是ppp0

刚才逼得我没办法,用iptables log了一下客户机连接,果然如你所说有53,137目的端口的udp连接
非常感谢!我现在就去改规则试试
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-23 17:37:02 | 显示全部楼层
搞定,137,138是udp,139tcp

现在的iptables规则:

]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain RH-Firewall-1-INPUT (2 references)
target     prot opt source               destination
LOG        all  --  Luo                  anywhere            LOG level warning prefix `packets'
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere            icmp any
ACCEPT     ipv6-crypt--  anywhere             anywhere
ACCEPT     ipv6-auth--  anywhere             anywhere
ACCEPT     udp  --  anywhere             ns-px.online.sh.cn  udp dpt:domain
ACCEPT     udp  --  anywhere             ns-pd.online.sh.cn  udp dpt:domain
ACCEPT     udp  --  anywhere             224.0.0.251         udp dpt:5353
ACCEPT     udp  --  anywhere             anywhere            udp dpt:ipp
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:microsoft-ds
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:netbios-ssn
ACCEPT     udp  --  anywhere             anywhere            state NEW multiport dports netbios-ns,netbios-dgm
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:https
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:mysql
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:cvspserver
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpts:6881:6889
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpts:2101:2121
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:14672
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:14662
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

但理论上还有个疑问:既然客户机53端口连的目的ip是dns服务器,不是网关服务器,网关只是转发,为什么会被防火墙拦截?
回复 支持 反对

使用道具 举报

发表于 2005-8-24 11:28:24 | 显示全部楼层
网关再不拦截的话,还有什么地方让你拦截?:)。

拦截的原因是:你的Reject ALL,把所有不符合规定的,都过滤了。
回复 支持 反对

使用道具 举报

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

本版积分规则

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