LinuxSir.cn,穿越时空的Linuxsir!

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

iptables关于转发的问题

[复制链接]
发表于 2007-6-18 16:59:14 | 显示全部楼层 |阅读模式
我要实现的目的:内网上的IP既能ping通172.168.1.1,也能ping通58.20.51.1

三个网络:
1、网络光纤,IP:58.20.51.xx/24 GW:58.20.51.1 eth0
2、电信ADSL,IP:172.168.1.123/24 GW:172.168.1.1 eth2
3、内网IP, IP:10.0.4.1/24 eth1

现在做了下面的规则,内网机器(10.0.4.0/24网段)可以ping通下列IP:
10.0.4.1
58.20.51.1
172.168.1.123
就是跳不到172.168.1.1上面去。

关了iptables用这个命令
iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
可以实现转发,但是打开iptables就是不行

路由表信息如下:
麻烦了




Table: nat
Chain PREROUTING (policy ACCEPT)
num target prot opt source destination

Chain POSTROUTING (policy ACCEPT)
num target prot opt source destination
1 vpn all -- 10.0.4.0/24 0.0.0.0/0
2 MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0
3 MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0
4 MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0
5 MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

Chain vpn (1 references)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 10.0.0.0/16
2 ACCEPT all -- 0.0.0.0/0 172.16.101.0/24
3 ACCEPT all -- 0.0.0.0/0 83.136.93.138
4 ACCEPT all -- 0.0.0.0/0 83.136.93.149
5 SNAT all -- 0.0.0.0/0 0.0.0.0/0 to:58.20.51.xx

Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination

Chain FORWARD (policy ACCEPT)
num target prot opt source destination

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
 楼主| 发表于 2007-6-23 10:37:03 | 显示全部楼层
解决
只要把snat那一行换成这一行就OK了
5    MASQUERADE  all  --  0.0.0.0/0            0.0.0.0/0
回复 支持 反对

使用道具 举报

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

本版积分规则

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