Linux網卡名改eth0方法__Linux

來源:互聯網
上載者:User
Linux網卡名改eth0方法

註:需要在物理機(即:linux伺服器上操作)這裡實驗的linux是redhat 6.7版   (親測有效)

轉載請註明出處:尋找&星空の孩子

步驟一

root使用者下查看網卡資訊 ifconfig –a

如果網卡名是ethX的執行步驟二,否則從步驟三開始執行。(X表示任一數字,步驟三開始ethX表示物理網卡名可以是其他名字eg:p3p1、em1等) 步驟二

下面先把ethX宕掉
[root@app1 Desktop]# ifdown ethX 找到70-persistent-net.rules檔案

[root@app1 Desktop]# cd /etc/udev/rules.d

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

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

-rw-r--r--.1 root root 420 Apr 16 2014 70-persistent-net.rules 修改70-persistent-net.rules這個檔案

[root@app1 rules.d]# vi70-persistent-net.rules

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

改成(只需該name)

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

儲存退出。 步驟三

然後進入network-scripts這個配置目錄 [root@app1 Desktop]# cd/etc/sysconfig/network-scripts

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

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

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

修改網卡檔案名稱

[root@app1 network-scripts]# mv ifcfg-ethX ifcfg-eth0

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

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

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

編輯網卡設定檔

[root@app1 network-scripts]# vi ifcfg-eth0

將其中的DEVICE=ethX改成eth0不需要修改MAC地址
並把uuid刪除(如果沒有就不用)

儲存並退出。 步驟四 重啟新網卡並驗證

[root@app1network-scripts]# ifup eth0

Device eth0does not seem to be present, delaying initialization.

[root@app1network-scripts]# servicenetwork restart

Shuttingdown loopback interface: [ OK ]

Bringingup loopback interface: [ OK ]

Bringingup interface eth3: Device eth3 does not seem to be present, delayinginitialization. [FAILED]

這個時候是啟不來的,需要重啟機器使修改生效。 重啟伺服器

[root@app1network-scripts]#reboot

重啟之後如果發現網路沒有自動連接的需要再次重啟

如果原先是eth系列的網卡名稱則已經修改過來,網路正常。

 

重啟後驗證:

[root@app1~]# ifconfig –a

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.