温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

rp_filter导致的网络异常

发布时间:2020-07-23 13:36:19 来源:网络 阅读:2248 作者:leejia1989 栏目:网络安全

问题背景如下:

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,我们重新把管理的所有机器都调整为了默认值以解决类似问题。



向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI