centos7配置vlan,實現一個網卡兩個地址的功能

1:首先yum install vconfig安裝vconfig
2:複製須要作vlan的網卡(em2)配置文件給em2.10和em2.20ide

[root@localhost ~]#cp /etc/sysconfig/network-scripts/ifcfg-em2 etc/sysconfig/network-scripts/ifcfg-em2.10ip

[root@localhost ~]#cp /etc/sysconfig/network-scripts/ifcfg-em2 /etc/sysconfig/network-scripts/ifcfg-em2.20pdo

3:(1)編輯[root@localhost ~]#vi etc/sysconfig/network-scripts/ifcfg-em2.10
TYPE=Vlan
VLAN=yes
VLAN_ID=10
BOOTPROTO=none
#UUID="4d878421-3a26-4150-b3aa-d75d3802ebe2" (特別注意註銷MAC)
DEVICE="em2.10" (設備名記得更改)
NAME="em2.10"
ONBOOT="yes"
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.1
(2)編輯[root@localhost ~]#vi etc/sysconfig/network-scripts/ifcfg-em2.20it

TYPE=Vlan
VLAN=yes
VLAN_ID=10
BOOTPROTO=none
#UUID="4d878421-3a26-4150-b3aa-d75d3802ebe2" (特別注意註銷MAC)
DEVICE="em2.20" (設備名記得更改)
NAME="em2.20"
ONBOOT="yes"
IPADDR=192.168.1.200
PREFIX=24class

4:ipdown em2.10 關閉em2.10
ipdown em2.20 關閉em2.20
ipup em2.10 打開em2.10
ipup em2.20 打開em2.20
5 :查看交換機配置是否成功
[root@localhost ~]# cat /proc/net/vlan/config
VLAN Dev name | VLAN ID
Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
em.20 | 20 | em2
em.10 | 10 | em2配置

相關文章
相關標籤/搜索