码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2020-12-04 11:20:23      阅读:7      评论:0      收藏:0      [点我收藏+]

标签:交换机配置   文件   复制   gate   dev   config   roo   VID   ref   

1:首先yum install vconfig安装vconfig
2:复制需要做vlan的网卡(em2)配置文件给em2.10和em2.20

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

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

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.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 :查看交换机配置是否成功
[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

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

标签:交换机配置   文件   复制   gate   dev   config   roo   VID   ref   

原文地址:https://blog.51cto.com/10720233/2557191

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!