安裝VLAN(802.1Q)
apt-get install vlanLoad the 8021q kernel module
sudo modprobe 8021qEnsure that this module gets loaded after a reboot by adding to /etc/modules:
sudo sh -c 'grep -q 8021q /etc/modules || echo 8021q >> /etc/modules'替網卡加入VLAN
sudo vconfig add eth0 100 sudo vconfig add <Ether Card> <VID> sudo vconfig delete <Ether Card> <VID>設定每個網卡對應VLAN的IP, netmask
sudo ifconfig eth0.100 192.168.100.1 netmask 255.255.255.0 sudo ifconfig eth0.<VID> <IP> netmask 255.255.255.0測試VLAN是否作用,Ping 192.168.100.1/24,使用wireshark錄eth0封包
永久設定每個網卡對應VLAN的IP, netmask
sudo vim /etc/network/interfacesauto eth0.100 iface eth0.100 inet static address 192.168.100.1 netmask 255.255.255.0