問題現象centos
用vmwareworkstation搭建centos 7雙網卡測試環境,經過system-config-network配置IP地址,在其列表裏卻無eth1這塊網卡的信息,後我到/etc/sysconfig/network-scripts目錄裏查看,果不其然,該目錄下並無ifcfg-eth1配置。ide
因而我想經過copy ifcfg-eth0 複製出一份 ifcfg-eth1的副本出來oop
[root@ligle2 network-scripts]# cp ifcfg-eth0 ifcfg-eth1測試
在我準備修改ifcfg-eth1文件,並替換IP配置信息時,發現配置文件裏有一條UUID的信息,見下:ui
[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
問題分析rest
替換配置文件內的IP地址和MAC信息都比較簡單,惟一就是網卡的UUID如何肯定呢?
問題解決ip
在Linux或CentOS中,能夠經過以下命令獲取網卡的uuid信息:get
[root@ligle2 ~]# uuidgen eth1
07d07031-eb0f-4691-8606-befb46645433it
獲取到eth1網卡的uuid,便可完成對ifcfg-eth1配置文件的修改,最後經過service network restart命令重啓網卡,OK。io
[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來源:簡書著做權歸做者全部。商業轉載請聯繫做者得到受權,非商業轉載請註明出處。