运维开发网

centos7配置vlan,实现一个网卡两个地址的功能

运维开发网 https://www.qedev.com 2020-12-01 13:54 出处:51CTO 作者:anhelenwang
1:首先yuminstallvconfig安装vconfig2:复制需要做vlan的网卡(em2)配置文件给em2.10和em2.20[[email protected]~]#cp/etc/sysconfig/network-scripts/ifcfg-em2etc/sysconfig/network-scripts/ifcfg-em2.10[[email protected]~]#cp/etc/syscon

1:首先yum install vconfig安装vconfig

2:复制需要做vlan的网卡(em2)配置文件给em2.10和em2.20

[[email protected] ~]#cp /etc/sysconfig/network-scripts/ifcfg-em2 etc/sysconfig/network-scripts/ifcfg-em2.10

[[email protected] ~]#cp /etc/sysconfig/network-scripts/ifcfg-em2 /etc/sysconfig/network-scripts/ifcfg-em2.20

3:(1)编辑[[email protected] ~]#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)编辑[[email protected] ~]#vi etc/sysconfig/network-scripts/ifcfg-em2.20

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=24

4:ipdown em2.10 关闭em2.10

ipdown em2.20 关闭em2.20

ipup em2.10 打开em2.10

ipup em2.20 打开em2.20

5 :查看交换机配置是否成功

[[email protected] ~]# 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

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号