Http://www.microhowto.info/tutorials/802.1q.html
Configure an Ethernet interface as a VLAN trunk
Host needs to connect 2 VLANs, on 192.168.2.1/24 VLAN 2 and on 192.168.3.1/24 VLAN 3
Modprobelsmodgrep 8021q
3 ways:
1 through configuration files
Auto Eth0. 2 iface eth0. 2 inet Static 192.168. 2.1 255.255. 255.0 auto eth0. 3 iface eth0. 3 inet Static 192.168. 3.1 255.255. 255.0
Ifup eth0. 2 ifup eth0. 3
ifconfigEth0.2eth0.2Link encap:ethernet HWaddrxx:xx:xx:xx:xx:xxinet Addr:192.168.2.1Bcast:12.168.2.255Mask:255.255.255.0Up Broadcast multicast MTU: theMetric:1RX Packets:0Errors0Dropped0Overruns:0Frame0TX Packets:0Errors0Dropped0Overruns:0Carrier0Collisions:0Txqueuelen:0RX Bytes:0(0.0b) TX Bytes:0(0.0b
If you need to specify a connection to that physical network card:
Auto Vlan2iface vlan2 inet static 192.168. 2.1 255.255. 255.0 VLAN-raw-device eth0
Http://www.microhowto.info/tutorials/802.1q.html
2 Vconfig
23
ifconfig eth0. 2 192.168. 2.1 255.255. 255.0 192.168. 2.255 ifconfig eth0. 3 192.168. 3.1 255.255. 255.0 192.168. 3.255 up
Get more information on VLAN interface
# cat/proc/net/vlan/eth0.5
Remove VLAN interface
ifconfig eth0. 5 down# vconfig rem eth0. 5
3 via IP
# IP link Add link eth0 name eth0. 2 ID 2 -D link show eth0. 2 192.168. 2.1/192.168. 2.255 Dev eth0. 2 # IP link set dev eth0. 2 up
Delete:
# IP link Set dev eth0. 2 down# IP link delete eth0. 2
After configuring, to ping eth0 IP, eth0 can receive and reply, but eth0.2 receive but not reply.
http://blog.csdn.net/suiyuan19840208/article/details/8221529
Configuring the NIC for VLAN trunk