centos 配置vlan
https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html/networking_guide/sec-configure_802_1q_vlan_tagging_using_the_command_line
在 Red Hat Enterprise Linux 7 中,默认载入 8021q 模块。如有必要,可作为 root 运行以下命令确定已载入该模块:
~]# modprobe --first-time 8021q
modprobe: ERROR: could not insert '8021q': Module already in kernel
请运行以下命令显示该模块信息:
~]$ modinfo 8021q
更多命令选项请查看 modprobe(8) man page。
7.4.1. 使用 ifcfg 文件设置 802.1Q VLAN 标记
-
在 /etc/sysconfig/network-scripts/ifcfg-ethX 中配置上级接口,其中 X 是与具体接口对应的唯一号码,如下:
DEVICE=ethX
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
-
在 /etc/sysconfig/network-scripts/ 目录中配置 VLAN 接口。配置文件名应为上级接口加上 . 字符再加上 VLAN ID 号码。例如:如果 VLAN ID 为 192,上级接口为 eth0,那么配置文件名应为 ifcfg-eth0.192:
DEVICE=ethX.192
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.1
PREFIX=24
NETWORK=192.168.1.0
VLAN=yes
如果需要在同一接口 eth0 中配置第二个 VLAN,比如 VLAN ID 193,请添加名为 eth0.193 的新文件,文件中包含 VLAN 配置详情。
-
重启联网服务以便更改生效。请作为 root 运行以下命令:
~]# systemctl restart network
========== End
来源:https://www.cnblogs.com/lsgxeva/p/14179008.html |