root@host-3:~# uname -a
Linux host-3 4.4.35-1-pve #1 SMP Fri Dec 9 11:09:55 CET 2016 x86_64 GNU/Linux
root@host-3:~# cat /etc/debian_version
8.9
root@host-3:~# ifconfig
eth0 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.1.2 Bcast:192.168.1.2.255 Mask:255.255.255.0
inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3313 errors:0 dropped:0 overruns:0 frame:0
TX packets:348 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:224843 (219.5 KiB) TX bytes:29794 (29.0 KiB)
eth1 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.2.2 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3028 errors:0 dropped:0 overruns:0 frame:0
TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:196588 (191.9 KiB) TX bytes:1330 (1.2 KiB)
在下面的设置中,在主机3上,流量不会通过网络传输出去。堆栈只是将其发送回接收应用程序。
在两个接口上捕获的数据包都表明,实际上没有数据包到达任何网络接口。
为什么是这样?
2个主机,1个NIC /主机:此工作方式(与下面的主机3比较)
--------------------- ------------------------------------------- ---------------------
| Linux Host host-1 | | Device Under Test (router) | | Linux Host host-2 |
| 192.168.1.2/24|----------|192.168.1.1/24 192.168.2.1/24|----------|192.168.2.2/24 |
--------------------- ------------------------------------------- ---------------------
1个主机和2个NIC:不起作用
---------------------
| Linux Host host-3 |
| 192.168.1.2/24|--------|
| eth0| |
| | |
| | |
| eth1| |
| 192.168.2.2/24|---| |
--------------------- | |
| |
| |
| |
| | -------------------------------------------
| | | Device Under Test (router) |
| |---------|192.168.1.1/24 192.168.2.1/24|---------|
| ------------------------------------------- |
| |
| |
| |
| |
|------------------------------------------------------------------|
主机3的路由表,包括静态路由
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.2 192.168.2.1 255.255.255.255 UGH 0 0 0 eth1
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.2.2 192.168.1.1 255.255.255.255 UGH 0 0 0 eth0
主机3的相关内核参数
root@host-3:~# sysctl -a | grep "\.rp_filter"
net.ipv4.conf.eth0.rp_filter = 0
net.ipv4.conf.eth1.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.lo.rp_filter = 0
root@host-3:~# sysctl -a | grep "accept_local"
net.ipv4.conf.eth0.accept_local = 1
net.ipv4.conf.eth1.accept_local = 1
net.ipv4.conf.all.accept_local = 1
net.ipv4.conf.default.accept_local = 1
net.ipv4.conf.lo.accept_local = 0
更新#1
回应评论询问流量类型以及是否涉及虚拟机...
流量只是ping。我还对UDP单播进行了测试,发现行为没有差异。
是的,这些是VM。实际上,更确切地说,它们是在Proxmox 4.4下运行的LXC Linux容器。
另外,自从我的原始帖子以来,我还发现了另一件事。
进行ping操作时,如果使用-I选项指定出口(即源)IP地址,则看不到行为更改。但是,如果我使用ping的-I选项指定出口接口,则似乎有一点需要注意。我说它们起作用是因为ping命令以大约40毫秒的往返时间获得回复。这是关于如果数据包实际上是流出而不是被堆栈短路(在这种情况下,往返时间不到一毫秒)的情况,我所期望的。但是,这是警告...
出口和入口接口上的数据包捕获仅显示回显请求。捕获结果未显示回声回复。我不确定这怎么可能...
# ip rule list
0: from all lookup local
32766: from all lookup main
32767: from all lookup default
# ip route list table local
[...]
broadcast 192.168.0.0 dev eth0 proto kernel scope link src 192.168.0.100
local 192.168.0.100 dev eth0 proto kernel scope host src 192.168.0.100
broadcast 192.168.0.255 dev eth0 proto kernel scope link src 192.168.0.100
您不能修改表local
; 内核维护它。这是具有最高优先级的表,因此您在其他表(即main
)中定义的内容无关紧要。这些条目永远不匹配。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句