溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

redhat linux6.5下怎么修改網(wǎng)卡名稱

發(fā)布時(shí)間:2021-07-30 17:42:21 來(lái)源:億速云 閱讀:206 作者:chen 欄目:云計(jì)算

本篇內(nèi)容介紹了“redhat linux6.5下怎么修改網(wǎng)卡名稱”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

  我們?cè)诎惭bRAC時(shí),需要公有網(wǎng)絡(luò)的網(wǎng)卡名對(duì)應(yīng)一致,私有網(wǎng)絡(luò)的網(wǎng)卡名對(duì)應(yīng)一致。但是當(dāng)兩個(gè)物理機(jī)器由于網(wǎng)卡配置數(shù)量的不等,很容易出現(xiàn)一個(gè)機(jī)器有ETH12和ETH13,但另一個(gè)機(jī)器只有ETH9和ETH10。那么遇到這個(gè)問(wèn)題,如何修改網(wǎng)卡名稱使兩個(gè)機(jī)器的網(wǎng)卡名能對(duì)應(yīng)起來(lái)呢?

   其實(shí)這個(gè)問(wèn)題,跟克隆虛擬機(jī)后的網(wǎng)卡啟動(dòng)失敗問(wèn)題很相似。只是克隆后新生成的虛機(jī)需要將網(wǎng)卡的MAC與70-persistent-net.rules文件的MAC保持一致就可以了。但是如果你要修改一個(gè)物理網(wǎng)卡的名稱,其實(shí)并沒(méi)有改變它的MAC地址,只是修改了名稱而已。下面我們看一下如何實(shí)現(xiàn)網(wǎng)卡名稱的更改。

舉個(gè)例子,我們把本機(jī)的ETH1改成ETH3.

[root@test2 Desktop]# ifconfig -a

eth2      Link encap:Ethernet  HWaddr 00:0C:29:65:02:FF  

          inet addr:192.168.199.119  Bcast:192.168.199.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fe65:2ff/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:87714 errors:0 dropped:0 overruns:0 frame:0

          TX packets:45281 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:112756896 (107.5 MiB)  TX bytes:3001189 (2.8 MiB)

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:16436  Metric:1

          RX packets:87 errors:0 dropped:0 overruns:0 frame:0

          TX packets:87 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:5721 (5.5 KiB)  TX bytes:5721 (5.5 KiB)

pan0      Link encap:Ethernet  HWaddr 66:13:A7:AD:1E:79  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@test2 Desktop]# ping 192.168.199.118

PING 192.168.199.118 (192.168.199.118) 56(84) bytes of data.

64 bytes from 192.168.199.118: icmp_seq=1 ttl=64 time=0.787 ms

64 bytes from 192.168.199.118: icmp_seq=2 ttl=64 time=0.880 ms

64 bytes from 192.168.199.118: icmp_seq=3 ttl=64 time=0.758 ms

^C

--- 192.168.199.118 ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2973ms

rtt min/avg/max/mdev = 0.758/0.808/0.880/0.056 ms

下面先把eth2宕掉

[root@test2 Desktop]# ifdown eth2

然后進(jìn)入這個(gè)配置目錄

[root@test2 Desktop]# cd /etc/sysconfig/network-scripts

[root@test2 network-scripts]# ls -l ifcfg*

-rw-r--r--. 1 root root 140 Jul  6 05:30 ifcfg-eth2

-rw-r--r--. 1 root root 254 Jan  9  2013 ifcfg-lo

修改網(wǎng)卡文件名稱

[root@test2 network-scripts]# mv ifcfg-eth2 ifcfg-eth4

[root@test2 network-scripts]# ls -l ifcfg*

-rw-r--r--. 1 root root 140 Jul  6 05:30 ifcfg-eth4

-rw-r--r--. 1 root root 254 Jan  9  2013 ifcfg-lo

編輯新文件,將其中的

DEVICE=eth2改成eth4,不需要修改MAC地址。

[root@test2 network-scripts]# vi ifcfg-eth4

然后進(jìn)入U(xiǎn)DEV目錄

[root@test2 network-scripts]# cd /etc/udev/rules.d

找到70-persistent-net.rules文件

[root@test2 rules.d]# ls -l 70*

-rw-r--r--. 1 root root 1342 Feb 17  2014 70-persistent-cd.rules

-rw-r--r--. 1 root root  420 Apr 16  2014 70-persistent-net.rules

[root@test2 rules.d]# vi 70-persistent-net.rules 

修改這個(gè)文件,將

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0C:29:65:02:FF", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

改成

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0C:29:65:02:FF", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"

保存退出。

[root@test2 rules.d]# ifup eth4

Device eth4 does not seem to be present, delaying initialization.

[root@test2 rules.d]# service network restart

Shutting down loopback interface:                          [  OK  ]

Bringing up loopback interface:                            [  OK  ]

Bringing up interface eth4:  Device eth4 does not seem to be present, delaying initialization.

                                                           [FAILED]

這個(gè)時(shí)候是啟不來(lái)的,需要重啟機(jī)器使修改生效。

[root@test2 rules.d]# reboot

重啟后我們發(fā)現(xiàn)名稱已經(jīng)變過(guò)來(lái)了。

[root@test2 etc]# ifconfig -a

eth4      Link encap:Ethernet  HWaddr 00:0C:29:65:02:FF  

          inet addr:192.168.199.119  Bcast:192.168.199.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fe65:2ff/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:39217 errors:0 dropped:0 overruns:0 frame:0

          TX packets:57 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:3162496 (3.0 MiB)  TX bytes:3905 (3.8 KiB)

還有一種情況,機(jī)器在新添加物理網(wǎng)卡后出現(xiàn)網(wǎng)卡名稱斷點(diǎn)不連續(xù)

eth22     Link encap:Ethernet  HWaddr 00:90:FA:76:A5:7C  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

eth24     Link encap:Ethernet  HWaddr 00:90:FA:76:A5:80  

          inet addr:11.11.161.65  Bcast:11.11.161.255  Mask:255.255.255.0

          inet6 addr: fe80::290:faff:fe76:a580/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:74621 errors:0 dropped:0 overruns:0 frame:0

          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:4516473 (4.3 MiB)  TX bytes:816 (816.0 b)

我們看一下少了eth23,這時(shí)可以把網(wǎng)卡配置全刪除,重啟讓系統(tǒng)重新分配就連續(xù)了。

[root@rac2 network-scripts]# cd /etc/udev/rules.d

[root@rac2 rules.d]# ls -l

total 44

-rw-r--r--. 1 root root 1652 Aug 26  2010 60-fprint-autosuspend.rules

-rw-r--r--. 1 root root 1060 Jun 29  2010 60-pcmcia.rules

-rw-r--r--. 1 root root  316 Aug  6  2013 60-raw.rules

-rw-r--r--. 1 root root  787 Dec 31 19:29 70-persistent-cd.rules

-rw-r--r--  1 root root 2905 Jan  5 21:47 70-persistent-net.rules

-rw-r--r--. 1 root root   40 Oct 25  2013 80-kvm.rules

-rw-r--r--. 1 root root  320 Sep 12  2012 90-alsa.rules

-rw-r--r--. 1 root root   83 Apr  1  2011 90-hal.rules

-rw-r--r--. 1 root root 2486 Jun 30  2010 97-bluetooth-serial.rules

-rw-r--r--. 1 root root  308 Oct 22  2013 98-kexec.rules

-rw-r--r--. 1 root root   54 Nov  3  2011 99-fuse.rules

[root@rac2 rules.d]# rm -rf 70-persistent-net.rules 

[root@rac2 rules.d]# cd /etc/sysconfig/network-scripts

[root@rac2 network-scripts]# ls -l ifcfg*

-rw-r--r--. 3 root root 136 Dec 31 18:52 ifcfg-eth0

-rw-r--r--. 3 root root 136 Dec 31 18:52 ifcfg-eth2

-rw-r--r--. 3 root root 203 Jan  5 00:14 ifcfg-eth20

-rw-r--r--. 3 root root 137 Dec 31 18:52 ifcfg-eth21

-rw-r--r--  3 root root 202 Jan  5 00:12 ifcfg-eth22

-rw-r--r--  3 root root 181 Jan  5 00:46 ifcfg-eth24

-rw-r--r--. 3 root root 136 Dec 31 18:52 ifcfg-eth3

-rw-r--r--. 3 root root 136 Dec 31 18:52 ifcfg-eth4

-rw-r--r--. 3 root root 136 Dec 31 18:52 ifcfg-eth5

-rw-r--r--. 3 root root 136 Dec 31 18:52 ifcfg-eth6

-rw-r--r--. 3 root root 136 Dec 31 18:52 ifcfg-eth7

-rw-r--r--. 3 root root 136 Dec 31 18:52 ifcfg-eth7

-rw-r--r--. 3 root root 136 Dec 31 18:52 ifcfg-eth8

-rw-r--r--. 3 root root 136 Dec 31 18:52 ifcfg-eth9

-rw-r--r--. 1 root root 254 Oct 10  2013 ifcfg-lo

[root@rac2 network-scripts]# rm -rf ifcfg-eth*

[root@rac2 network-scripts]#reboot

重啟后一切正常。

“redhat linux6.5下怎么修改網(wǎng)卡名稱”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI