linux vlan configuration

本文介绍了如何在Ubuntu上安装并配置VLAN,包括安装vlan软件包,创建eth0.100和eth0.200子接口,将主机和虚拟机连接到不同的VLAN,并通过arp和tcpdump进行验证。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.installation

sample:ubuntu

apt-get install vlan

modprobe 8021q


2. create subinterface eth0.100 belong to vlan 100,eth0.200 belong to vlan 200

vconfig add eth0 100

vconfig add eth0 200



3. make host use vlan interface

ifconfig eth0.100 192.168.100.1

ping 192.168.100.254

tcpdump -i eth0 -nn -e

root@xiaotech-desktop:~# tcpdump -i eth0 -nn -e arp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
08:33:01.043090 30:0e:d5:1a:97:4d > ff:ff:ff:ff:ff:ff, ethertype 802.1Q (0x8100), length 46:vlan 100, p 0, ethertype ARP, Request who-has 192.168.100.100 tell 192.168.100.1, length 28
08:33:02.041380 30:0e:d5:1a:97:4d > ff:ff:ff:ff:ff:ff, ethertype 802.1Q (0x8100), length 46: vlan 100, p 0, ethertype ARP, Request who-has 192.168.100.100 tell 192.168.100.1, length 28


4.make vm use vlan interface

brctl addbr test

brctl addif test eth0.200

create vm user virt-manager,attach the vm interface to the bridge test such as follows

root@xiaotech-desktop:~# brctl show
bridge   name bridge   idSTP     enabled   interfaces

test 8000.300ed51a974d no                     eth0.200
                                                                      vnet0

in the vm,ping 192.168.200.254

root@xiaotech-desktop:~# tcpdump -i eth0 -nn -e arp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
08:36:59.738330 52:54:00:5e:cd:49 > ff:ff:ff:ff:ff:ff, ethertype 802.1Q (0x8100), length 64: vlan 200, p 0, ethertype ARP, Request who-has 192.168.200.254 tell 192.168.200.2, length 46

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值