+ -
当前位置:首页 → 问答吧 → 请教:写了iptables后,局域网的linux要加**才能上网,而里面的win没这个毛病

请教:写了iptables后,局域网的linux要加**才能上网,而里面的win没这个毛病

时间:2007-07-29

来源:互联网

连外网的机器装的debian4.0,内网有debian,ubuntu,windows,我的iptables如下 :
#!/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -F
iptables -X
iptables -Z
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

#input chain
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A INPUT -i lo -p all -j ACCEPT
#output chain
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#freeip load//试图只让免费ip通过
iptables -A OUTPUT -d 58.17.0.0/16 -j ACCEPT
iptables -A OUTPUT -d 58.18.0.0/15 -j ACCEPT
........
#forward chain
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -s 58.17.0.0/16 -j ACCEPT
iptables -A FORWARD -i eth0 -s 58.18.0.0/15 -j ACCEPT
.........
#nat
iptables -F -t nat
iptables -X -t nat
iptables -Z -t nat
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to 1.2.3.4

启动iptable后,内网windows机器能上网,只访问免费ip好像也可以,奇怪的是里面的debian4.0 和ubuntu7.04都不能直接上,在firefox上加上**能上,不加**时看到下方在提示正在解析地址,请问我的iptable什么地方不写好,请达人帮忙 ,谢谢!

作者: zhengdsp   发布时间: 2007-07-29

引用:
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to 1.2.3.4
把1.2.3.4改成你的外网IP
或者干脆改成这样:

引用:
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE

作者: 高热   发布时间: 2007-07-29

很怀疑你的linux客户机网络设置有问题,请将客户机运行以下几条命令的输出贴出来看看:
route -n
ifconfig
cat /etc/resolv.conf

作者: abby   发布时间: 2007-07-29

多谢!我刚找到毛病了,是我的DNS没设置好

作者: zhengdsp   发布时间: 2007-07-29

呵呵,lin都装了桌面,所以偷懒设DNS没用命令,导致出错,顺便请大家帮看看这个 iptable那些
地方待改进乃至不对的,谢谢!

作者: zhengdsp   发布时间: 2007-07-30

热门下载

更多