我已经构build了这个简单的configuration:
---------------- ---------------- | Linux host A | <----- patch cable -------> | Linux host B | ---------------- ----------------
然后我在每台主机上configuration了2个VLAN:
eth1 eth1 | | |-- eth1.2 -> 192.168.1.2/24 |-- eth1.2 -> 192.168.1.4/24 |-- eth1.3 -> 192.168.1.3/24 |-- eth1.3 -> 192.168.1.5/24
在主机A上,当我这样做的时候:
ping -I eth1.2 192.168.1.4
它的工作,但是当我这样做:
ping -I eth1.3 192.168.1.5
它不起作用。
我试图在两台主机上设置:
sysctl net.ipv4.conf.enth1.rp_filter=0 sysctl net.ipv4.conf.enth1/2.rp_filter=0 sysctl net.ipv4.conf.enth1/3.rp_filter=0
但是还没有解决问题。
使用主机B上的wireshark进行间谍eth1,可以看到有VLAN 3的ping被正确接收,但主机B没有回应。
当然,我已经检查了我的iptables:
Chain INPUT target prot opt in out source destination ACCEPT all -- eth1 any anywhere anywhere Chain OUTPUT (policy ACCEPT)
当我在主机A上做一个简单的:
ping 192.168.1.5
主机B答案,但我看到wireshark数据包被标记的VLAN ID 2,这当然有效。
所以我猜想VLAN标记的数据包路由到主机B是错误的,但我找不到什么!
您使用的是相同的IP段,并且没有特殊的路由规则。 这意味着,总是使用默认路由,默认路由设置为VLAN2。
最好的,如果你区分你的VLAN不同的IP段。 例如你的VLAN2可以使用现有的192.168.1.1/24,一个VLAN3可以使用192.168.3.1/24。