问题现象

用vmwareworkstation搭建centos 7双网卡测试环境,通过system-config-network配置IP地址,在其列表里却无eth1这块网卡的信息,后我到/etc/sysconfig/network-scripts目录里查看,果不其然,该目录下并没有ifcfg-eth1配置。

于是我想通过copy ifcfg-eth0 复制出一份 ifcfg-eth1的副本出来

[root@ligle2 network-scripts]# cp ifcfg-eth0 ifcfg-eth1

在我准备修改ifcfg-eth1文件,并替换IP配置信息时,发现配置文件里有一条UUID的信息,见下:

[root@ligle2 network-scripts]# vi ifcfg-eth1 DEVICE=eth0 HWADDR=08:00:27:06:a3:94 TYPE=Ethernet UUID=9420c638-16e9-41a1-bf59-325c6f601871 ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=none IPADDR=192.168.0.53 NETMASK=255.255.255.0 GATEWAY=192.168.0.1 IPV6INIT=no USERCTL=no 问题分析

替换配置文件内的IP地址和MAC信息都比较简单,唯一就是网卡的UUID如何确定呢? 问题解决

在Linux或CentOS中,可以通过如下命令获取网卡的uuid信息:

[root@ligle2 ~]# uuidgen eth1 07d07031-eb0f-4691-8606-befb46645433

获取到eth1网卡的uuid,即可完成对ifcfg-eth1配置文件的修改,最后通过service network restart命令重启网卡,OK。

[root@ligle2 network-scripts]# ifconfig

eth0 Link encap:Ethernet HWaddr 08:00:27:06:A3:94 inet addr:192.168.0.53 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe06:a394/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:723 errors:0 dropped:0 overruns:0 frame:0 TX packets:385 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:78659 (76.8 KiB) TX bytes:66909 (65.3 KiB) eth1 Link encap:Ethernet HWaddr 08:00:27:54:F2:E0 inet addr:10.10.1.2 Bcast:10.255.255.255 Mask:255.0.0.0 inet6 addr: fe80::a00:27ff:fe54:f2e0/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:65 errors:0 dropped:0 overruns:0 frame:0 TX packets:96 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:20820 (20.3 KiB) TX bytes:30684 (29.9 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:212 errors:0 dropped:0 overruns:0 frame:0 TX packets:212 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:15232 (14.8 KiB) TX bytes:15232 (14.8 KiB)

作者:不能偷懒的这一辈子 链接:https://www.jianshu.com/p/ccd40ffc0f7c 來源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。