为 CentOS7 虚拟机添加第二块网卡
为 CentOS7 虚拟机添加第二块网卡一、在虚拟中添加网卡
1、右击虚拟机,在弹出的菜单中选择【设置】,弹出如下图所示的【虚拟机设置】窗口,在窗口单击【添加】按钮。
https://i-blog.csdnimg.cn/direct/9030e9272f5b4b51ace483682ad472ac.png#pic_center
2、弹出如下图所示的【添加硬件向导】窗口,在窗口中的【硬件类型】列表中选择【网络适配器】,单击【下一步】按钮。
https://i-blog.csdnimg.cn/direct/560a91aaaf20489d9a4f7f190829a9b1.png#pic_center
3、弹出如下图所示的窗口,在窗口的【网络连接】列表中选择【仅主机模式】,单击【完成】按钮完成网卡添加。
https://i-blog.csdnimg.cn/direct/a15eebb943164c3a82731549b0ba938a.png#pic_center
4、最终结果如下图所示。此中【网络适配器3】就是新添加的网卡。
https://i-blog.csdnimg.cn/direct/c70e8d36064844caa4b43eb0d8494d93.png#pic_center
二、网卡配置
1、查看新增的网卡信息
# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500
inet 192.168.1.12netmask 255.255.255.0broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe89:50eprefixlen 64scopeid 0x20<link>
inet6 2409:8a44:3d36:4750:20c:29ff:fe89:50eprefixlen 64scopeid 0x0<global>
ether 00:0c:29:89:05:0etxqueuelen 1000(Ethernet)
RX packets 149bytes 12923 (12.6 KiB)
RX errors 0dropped 50overruns 0frame 0
TX packets 91bytes 12014 (11.7 KiB)
TX errors 0dropped 0 overruns 0carrier 0collisions 0
ens38: flags=4099<UP,BROADCAST,MULTICAST>mtu 1500
ether 00:0c:29:89:05:22txqueuelen 1000(Ethernet)
RX packets 0bytes 0 (0.0 B)
RX errors 0dropped 0overruns 0frame 0
TX packets 0bytes 0 (0.0 B)
TX errors 0dropped 0 overruns 0carrier 0collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>mtu 65536
inet 127.0.0.1netmask 255.0.0.0
inet6 ::1prefixlen 128scopeid 0x10<host>
looptxqueuelen 1(Local Loopback)
RX packets 72bytes 6248 (6.1 KiB)
RX errors 0dropped 0overruns 0frame 0
TX packets 72bytes 6248 (6.1 KiB)
TX errors 0dropped 0 overruns 0carrier 0collisions 0
2、创建网卡配置文件
(1)查看网卡配置文件
# cd /etc/sysconfig/network-scripts/
# ls
ifcfg-ens33ifdown-eth ifdown-isdn ifdown-sit ifup ifup-ib ifup-plip ifup-routes ifup-tunnel network-functions-ipv6
ifcfg-lo ifdown-ib ifdown-post ifdown-Team ifup-aliasesifup-ipppifup-plusbifup-sit ifup-wireless
ifdown ifdown-ipppifdown-ppp ifdown-TeamPortifup-bnep ifup-ipv6ifup-post ifup-Team init.ipv6-global
ifdown-bnepifdown-ipv6ifdown-routesifdown-tunnel ifup-eth ifup-isdnifup-ppp ifup-TeamPortnetwork-functions
(2)查看新增网卡的UUID
# nmcli con show
名称 UUID 类型 设备
ens33 0a5654b2-79b9-4f51-960d-bf567c68bdb9802-3-ethernetens33
有线连接 17a1aae4e-a183-351f-95d0-d0c34ded228d802-3-ethernet--
(3)利用已存在的网卡配置文件复制一个新的配置文件,名称为ifcfg-ens38
# cp ifcfg-ens33 ifcfg-ens38
# ls
ifcfg-ens33ifdown-bnepifdown-ipv6ifdown-routes ifdown-tunnelifup-eth ifup-isdn ifup-ppp ifup-TeamPort network-functions
ifcfg-ens38ifdown-eth ifdown-isdnifdown-sit ifup ifup-ib ifup-plip ifup-routesifup-tunnel network-functions-ipv6
ifcfg-lo ifdown-ib ifdown-postifdown-Team ifup-aliases ifup-ipppifup-plusbifup-sit ifup-wireless
ifdown ifdown-ipppifdown-ppp ifdown-TeamPortifup-bnep ifup-ipv6ifup-post ifup-Team init.ipv6-global
(4)修改网卡配置文件ifcfg-ens38的内容如下:
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
NAME=ens38 # 网卡名称
UUID=7a1aae4e-a183-351f-95d0-d0c34ded228d
DEVICE=ens38 # 设备名称
ONBOOT=yes
IPADDR=10.1.1.12
PREFIX=24
(5)重新查看新增网卡的`UUID
# nmcli con show
名称 UUID 类型 设备
ens330a5654b2-79b9-4f51-960d-bf567c68bdb9802-3-ethernetens33
ens387a1aae4e-a183-351f-95d0-d0c34ded228d802-3-ethernetens38
(6)查看网卡信息
# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500
inet 192.168.1.12netmask 255.255.255.0broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe89:50eprefixlen 64scopeid 0x20<link>
inet6 2409:8a44:3d36:4750:20c:29ff:fe89:50eprefixlen 64scopeid 0x0<global>
ether 00:0c:29:89:05:0etxqueuelen 1000(Ethernet)
RX packets 1374bytes 110608 (108.0 KiB)
RX errors 0dropped 515overruns 0frame 0
TX packets 588bytes 89928 (87.8 KiB)
TX errors 0dropped 0 overruns 0carrier 0collisions 0
ens38: flags=4099<UP,BROADCAST,MULTICAST>mtu 1500
inet 10.1.1.12netmask 255.255.255.0broadcast 10.1.1.255
ether 00:0c:29:89:05:22txqueuelen 1000(Ethernet)
RX packets 0bytes 0 (0.0 B)
RX errors 0dropped 0overruns 0frame 0
TX packets 0bytes 0 (0.0 B)
TX errors 0dropped 0 overruns 0carrier 0collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>mtu 65536
inet 127.0.0.1netmask 255.0.0.0
inet6 ::1prefixlen 128scopeid 0x10<host>
looptxqueuelen 1(Local Loopback)
RX packets 116bytes 10740 (10.4 KiB)
RX errors 0dropped 0overruns 0frame 0
TX packets 116bytes 10740 (10.4 KiB)
TX errors 0dropped 0 overruns 0carrier 0collisions 0
添加成功。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]