免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2289 | 回复: 9

[网络管理] Linux下NAT是否支持多个内部网段? [复制链接]

论坛徽章:
0
发表于 2004-12-08 18:00 |显示全部楼层
PPPoE拨号后,iptables设置SNAT,本网段内机器可以上网;

其它网段不行,Linux机器上已添加到这些网段的路由(交给三层交换机处理),其它网段的数据包只能到Linux机器的内网接口

#iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o ppp0 -j MASQUERADE
针对该网段的已经添加,但该网段机器访问不了Internet

还缺什么?

论坛徽章:
0
发表于 2004-12-08 18:18 |显示全部楼层

Linux下NAT是否支持多个内部网段?

难道是俺描述得不清楚?

现在需要是把192.168.2.0/24网段也做SNAT,我已经添加了#iptables -A FORWARD -s 192.168.2.0/24 -j ACCEPT 还是不生效,数据包只到达了内网接口

论坛徽章:
0
发表于 2004-12-08 18:54 |显示全部楼层

Linux下NAT是否支持多个内部网段?

#iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o ppp0 -j MASQUERADE

#iptables -A FORWARD -i ppp0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
#iptables -A FORWARD -i eth0 -o ppp0 -j ACCEPT

where eth0 is the NIC to the subnet of 192.168.2.0

论坛徽章:
0
发表于 2004-12-08 18:58 |显示全部楼层

Linux下NAT是否支持多个内部网段?

原帖由 "yunqing" 发表:
#iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o ppp0 -j MASQUERADE

#iptables -A FORWARD -i ppp0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
#iptables -A FORWARD -i eth0 -o ppp0 -j ..........


这样如何?应该可以解决了吧

招聘 : Linux运维
论坛徽章:
0
发表于 2004-12-08 19:07 |显示全部楼层

Linux下NAT是否支持多个内部网段?

应该是路由问题
既然服务器上已经加了到内部其他网段的路由
三层交换上加了指向服务器的缺省路由了吗?

招聘 : Linux运维
论坛徽章:
0
发表于 2004-12-08 19:09 |显示全部楼层

Linux下NAT是否支持多个内部网段?

内部能到服务器的内网卡,就应该是三层交换上的路由问题了

cisco 的话看看 sh run里边有没有
ip route 0.0.0.0 0.0.0.0 服务器IP

论坛徽章:
0
发表于 2004-12-08 19:24 |显示全部楼层

Linux下NAT是否支持多个内部网段?

还是没生效!

交换机上设置#ip route 0.0.0.0 0.0.0.0 服务器内网IP

#show ip route 默认路由是存在的

我不同网段的数据包都能到达这个机器的内网口了。。。

论坛徽章:
0
发表于 2004-12-08 19:37 |显示全部楼层

Linux下NAT是否支持多个内部网段?

[root@proxy ~]# iptables --list
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
RH-Firewall-1-INPUT  all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  192.168.2.0/24       anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere

Chain L (0 references)
target     prot opt source               destination

Chain RH-Firewall-1-INPUT (1 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
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:https
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited


差哪儿呢...

论坛徽章:
0
发表于 2004-12-08 20:37 |显示全部楼层

Linux下NAT是否支持多个内部网段?

可以支持!

招聘 : Linux运维
论坛徽章:
0
发表于 2004-12-08 21:18 |显示全部楼层

Linux下NAT是否支持多个内部网段?

好久没看,看见iptables还是那么头疼!

把iptables全都 -F 了
然后只加一个SNAT的,要是还不行就是你的网络结构问题,从最简单处入手把。或者你tracert
另:“Linux机器上已添加到这些网段的路由(交给三层交换机处理),”这句话什么意思?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP