vconfig不标记带有vlan标签的传出数据包(Ubuntu)

我试图在我的桌面Ubuntu机器上尝试一个VLAN接口。 桌面只有一个连接到公司LAN的单个接口(eth0)。 使用vconfig创buildvlan接口后,在接口上运行wireshark不会显示作为vlan标记的传出数据包。 这是我做的:

$ ifconfig eth0 Link encap:Ethernet HWaddr 84:2b:2b:87:2c:87 inet addr:192.168.0.126 Bcast:192.168.0.255 Mask:255.255.255.0 etc... 

然后我添加vlan接口:

 $ sudo vconfig add eth0 55 $ sudo ifconfig eth0.55 192.168.10.100 netmask 255.255.255.0 up $ sudo ifconfig eth0.55 mtu 1412 $ ifconfig -a eth0 Link encap:Ethernet HWaddr 84:2b:2b:87:2c:87 inet addr:192.168.0.126 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::862b:2bff:fe87:2c87/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:12195 errors:0 dropped:0 overruns:0 frame:0 TX packets:7435 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:6831057 (6.8 MB) TX bytes:1138706 (1.1 MB) Interrupt:18 eth0.55 Link encap:Ethernet HWaddr 84:2b:2b:87:2c:87 inet addr:192.168.10.100 Bcast:192.168.10.255 Mask:255.255.255.0 inet6 addr: fe80::862b:2bff:fe87:2c87/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1412 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:168 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:23515 (23.5 KB) 

到目前为止这么好..这里是额外的相关信息:

 $ sudo cat /proc/net/vlan/eth0.55 eth0.55 VID: 55 REORDER_HDR: 1 dev->priv_flags: 1 total frames received 0 total bytes received 0 Broadcast/Multicast Rcvd 0 total frames transmitted 170 total bytes transmitted 23697 Device: eth0 INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 EGRESS priority mappings: $ sudo iptables -L -v Chain INPUT (policy ACCEPT 3317 packets, 2230K bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 1528 packets, 189K bytes) pkts bytes target prot opt in out source destination $ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0 192.168.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0 192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0.55 

现在我尝试在192.168.10.xx范围内ping一些不存在的机器:

 $ ping -I eth0.55 192.168.10.101 

但是,当用wireshark或tcpdump捕获这个接口时,我看到正常的arp消息被发送出去。 它们不是vlan标记的。 (我的兴趣在于先看看是否可以从我的机器中获取vlan数据包。使用实际的vlans将在稍后提供)。 我也能够从同一台机器上的vbox VM ping通eth0.55接口。

 $ sudo /usr/sbin/tcpdump -vv -i eth0.55 tcpdump: listening on eth0.55, link-type EN10MB (Ethernet), capture size 65535 bytes 11:55:52.625984 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 192.168.10.101 tell 192.168.10.100, length 28 11:55:53.625983 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 192.168.10.101 tell 192.168.10.100, length 28 

我什至试过set_flag命令,但仍然是一个不行:

 $ sudo vconfig set_flag eth0.55 0 

我错过了什么?

这里有一个类似的问题: 通过tcpdump,数据包捕获(Linux)中没有显示VLAN标记

实际上你看到的是使用tcpdump时内核过滤的数据包,其中vlan层被删除,所以它总是看起来像没有标记的。

你已经看到通过/proc/net/vlan/eth0.55传输帧,所以它工作得很好。

根据你的情况,使用这个命令来查看VLAN标签:

 tcpdump -Uw - | tcpdump -i eth0 -en -r - vlan 55 

要查看实际的802.1q标记,请尝试捕获底层物理接口,即eth0 ,这是数据包进出的位置。

可能你不会错过任何事情。
当你在界面上没有vlan时,你可以用tcpdump看到802.1q标签。
当您添加vlan到接口,然后8021q模块启用硬件加速和…你停下来看标签。 您将在子接口上看到分离的stream量,但主接口上的tcpdump会显示来自所有具有剥离标签的子接口的stream量。
如果你有现代的ethtool那么你可以看看ethtool -k eth0输出,你可以尝试closuresethtool -K eth0 rxvlan off; ethtool -K eth0 txvlan off;加速ethtool -K eth0 rxvlan off; ethtool -K eth0 txvlan off; ethtool -K eth0 rxvlan off; ethtool -K eth0 txvlan off; (说实话 – 我从不testing它是否有助于查看标签,并且现在无法访问良好的实验室主机进行检查)。
但我认为你应该configuration其余的基础设施,并试图看看它是否按预期工作(请参阅未加载8021q模块的另一台机器上的带标签的ARP请求)。