Linux 添加虚拟网卡

使用的Linux版本是Centos 7:

[root@vnode33 bin]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

使用ifconfig命令查看当前可用的网卡有eth1:

[root@vnode33 network-scripts]# ifconfig
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.86.40.129  netmask 255.255.255.0  broadcast 172.86.40.255
        inet6 fe80::5054:ff:fe19:6363  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:19:63:63  txqueuelen 1000  (Ethernet)
        RX packets 79292  bytes 5128248 (4.8 MiB)
        RX errors 0  dropped 22  overruns 0  frame 0
        TX packets 668  bytes 128859 (125.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

进入目录 [root@vnode33 sysconfig]# cd /etc/sysconfig/network-scripts/ 查看eth1的配置:

[root@vnode33 network-scripts]# cat ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=no
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eth1
UUID=575fa71d-1ba7-468e-bd3c-2a6a5f379a78
DEVICE=eth1
ONBOOT=yes
IPADDR=172.86.40.129
PREFIX=24
GATEWAY=172.86.40.254
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_PRIVACY=no

复制该文件并修改红色标注的三行: cp ifcfg-eth1 ifcfg-eth1:1 

TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=no
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eth1:1
UUID=575fa71d-1ba7-468e-bd3c-2a6a5f379a78
DEVICE=eth1:1
ONBOOT=yes
IPADDR=172.86.40.130
PREFIX=24
GATEWAY=172.86.40.254
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_PRIVACY=no

最后重启系统网络服务:  service network restart 

我们再次查看接口,可以看见虚拟网卡已经启动了:

[root@vnode33 network-scripts]# ifconfig
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.86.40.129  netmask 255.255.255.0  broadcast 172.86.40.255
        inet6 fe80::5054:ff:fe19:6363  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:19:63:63  txqueuelen 1000  (Ethernet)
        RX packets 80006  bytes 5177274 (4.9 MiB)
        RX errors 0  dropped 22  overruns 0  frame 0
        TX packets 799  bytes 142765 (139.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.86.40.130  netmask 255.255.255.0  broadcast 172.86.40.255
        ether 52:54:00:19:63:63  txqueuelen 1000  (Ethernet)

 

转载于:https://www.cnblogs.com/z-joshua/p/6377566.html

相关资源:Linux虚拟网卡配置
表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页