环境准备sudo apt-get install vlansudo modprobe 8021q检查环境A quick review of lsmod will ensure the kernel m
环境准备
sudo apt-get install vlansudo modprobe 8021q
- 检查环境
A quick review of lsmod will ensure the kernel module was loaded:
lsmod | grep 8021q
The output of the command should look similar to this:
.8021q 26896 0”
.- 给enp2s0f1划到vlan102:
sudo vim /etc/network/interfaces
.auto enp2s0f1
iface enp2s0f1 inet static
auto enp2s0f1.102
iface enp2s0f1.102 inet static
address 10.0.0.220
network 10.0.0.0
netmask 255.255.255.0
broadcast 10.0.0.255
vlan_raw_device enp2s0f1
sudo /etc/init.d/networking restartsudo ifdown enp2s0f1sudo ifup enp2s0f1.102sudo ifup enp2s0f1
- 遇到错误
Cannot find device "enp2s0f1.102"
.或者网络不通
重启机器:
reboot
或者:
init 6
- 检查环境
Once the interface is initialized you may want to refer to the following proc locations for configuration information:
/proc/net/vlan/config/proc/net/vlan/[vlan-device]