rp_filter导致的网络异常-创新互联

问题背景如下:

为建瓯等地区用户提供了全套网页设计制作服务,及建瓯网站建设行业解决方案。主营业务为做网站、成都网站设计、建瓯网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

1,公司内网到某机房公网不通(ping,traceroute,curl都不行)

2,在某机房此公网的机器到公司内网也不通(ping,traceroute,curl都不行)

3,但是某机房此公网哪个的机器可以通过网关通外网,并且外网环境也能访问某机房公网ip,只有公司内网到这些ip不同。

4,公司内网到其它几个机房的公网都没问题

公司内网到某机房公网不通的traceroute结果:

$ traceroute x.x.x.x
traceroute  to x.x.x.x (x.x.x.x), 30 hops max, 60 byte  packets
 1 * * *
 2 10.x.253.1  (10.x.253.1) 7.092 ms 7.388 ms 7.384 ms
 3  10.x.2.2 (10.x.2.2) 7.372 ms 7.615 ms 8.347  ms
 4 10.x.1.2 (10.x.1.2) 7.595 ms 8.335  ms 8.331 ms
 5  192.x.168.254  (192.x.168.254) 8.879 ms 9.325 ms 10.077  ms
 6 * * *
 ......

30 * * *

公司内网到其它机房公网正常的traceroute结果:

$ traceroute xx.xx.xx.xx
traceroute  toxx.xx.xx.xx (xx.xx.xx.xx), 30 hops max, 60 byte  packets
 1 * * *
 2 10.x.253.1  (10.x.253.1) 7.092 ms 7.388 ms 7.384 ms
 3  10.x.2.2 (10.x.2.2) 7.372 ms 7.615 ms 8.347  ms
 4 10.x.1.2 (10.x.1.2) 7.595 ms 8.335  ms 8.331 ms

 5  * * *

 6  111.111.111.111  (111.111.111.111) 8.879 ms 9.325 ms 10.077  ms
 7  * * *

 8 xx.xx.xx.xx

问题分析解决步骤:(发现这个问题之后,感觉和奇怪,虽然不影响服务,但是好奇心还是驱使着想把问题搞清楚)

一,分析了一下某机房机器的路由,都正常没有发现异常

二,我测试了某机房和其它机房之间的网络,外网到某机房的网络都是正常的。第一个怀疑对象就是觉得公司内网有限制,因为看traceroute结果,数据包还没有出公司内网。所以,就和公司IT部门排查了一番,发现并没有任何限制

三,然后,怀疑公司机房是否有相关限制呢。所以,又找网络组查了一番,结果仍然是没有任何限制

四,排除外部因素之后,就怀疑可能是系统有问题了。并且,通过在某机房的外网机器上抓包能抓到公司内网送达的traceroute包,只是某机房的机器没有回复数据包,那就更确定是系统本身的问题了。通过强大的google发现了rp_filter这个参数导致了这个问题,因为我们某机房机器此参数为1.

rp_filter参数的作用:

rp_filter - INTEGER
	0 - No source validation.
	1 - Strict mode as defined in RFC3704 Strict Reverse Path
	    Each incoming packet is tested against the FIB and if the interface
	    is not the best reverse path the packet check will fail.
	    By default failed packets are discarded.
	2 - Loose mode as defined in RFC3704 Loose Reverse Path
	    Each incoming packet's source address is also tested against the FIB
	    and if the source address is not reachable via any interface
	    the packet check will fail.

	Current recommended practice in RFC3704 is to enable strict mode
	to prevent IP spoofing from DDos attacks. If using asymmetric routing
	or other complicated routing, then loose mode is recommended.

	The max value from conf/{all,interface}/rp_filter is used
	when doing source validation on the {interface}.

	Default value is 0. Note that some distributions enable it
	in startup scripts.

置为1的作用为:数据包从哪个网口进来从哪个网口出去,如果不匹配 丢弃。

结论:

公司内网到某机房机器的request数据包从公网网卡进入,而reply的数据包根据机器的路由规则则从某机房机器的内网网卡流出。而某机房机器rp_filter为1,从而导致数据包被系统丢弃。而rp_filter这个参数默认是0,由于历史原因被调整成了1,我们重新把管理的所有机器都调整为了默认值以解决类似问题。

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享文章:rp_filter导致的网络异常-创新互联
网站URL:http://pwwzsj.com/article/pgpsp.html