Chinaunix首页 | 论坛 | 博客
  • 博客访问: 409700
  • 博文数量: 403
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: -70
  • 用 户 组: 普通用户
  • 注册时间: 2016-09-05 12:45
文章分类

全部博文(403)

文章存档

2014年(3)

2013年(1)

2012年(3)

2011年(21)

2010年(13)

2009年(64)

2008年(9)

2007年(36)

2006年(253)

分类:

2006-11-13 21:41:31

我想做一个双层代理,其中有客户端(A)、代理服务器1(B)、代理服务器2(C),两个代理服务器分别是两个网卡,IP设置:
A:eth0  192.168.0.2   网关:192.168.0.1
B:eth1  192.168.0.1   网关:192.168.0.1
   eth0  192.168.1.2   网关:192.168.1.1
C:eth0  192.168.1.1   网关:192.168.1.1
   eth1   外网IP(假设1.1.1.2)   网关:外网网关(假设1.1.1.1)
连接线路:
A(eth0)<------>B(eth1)----B(eth0)<----->C(eth0)-----C(eth1)<----->外网
B和C的ip_forward都设置了1
B中使用了   iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source 192.168.1.2   
C中使用了   iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source 1.1.1.2

现在我用A能够ping通B的两个网卡和C的eth0,但是ping不通C的eth1。

还是网关的问题?是不是我的网关设置有问题?跟子网掩码没有关系吧?我是这样设置IP的:
A:ifconfig eth0 192.168.0.2
   route add default gw 192.168.0.1

B:ifconfig eth1 192.168.0.1  
   route add default gw 192.168.0.1  eth1
   ifconfig eth0 192.168.1.2
   route add default gw 192.168.1.1  eth0

C:ifconfig eth0 192.168.1.1
   route add default gw 192.168.1.1  eth0
   ifconfig eth1 1.1.1.2
   route add default gw 1.1.1.1  eth1
 
今天晚上经一个高高手的指点终于恍然大悟,每个机器只能有一个default网关,而我在B、C分别设置了两个default gw,肯定ping不通了,解决方法是删除B的eth1网关和C的eth0网关,这样不仅A能ping通C的外网网卡,连C都可以ping通A了(原来只能单向ping通,以为本来就是这样的,现在看来自己错了)。自己一周的头疼病今天一晚上就被人家解决了,真是自愧不如啊。
阅读(3180) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~