linux vlan configuration

来源:互联网 发布:手机如何连接电脑网络 编辑:程序博客网 时间:2024/04/30 15:22

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

0 0
原创粉丝点击