Linux – Network device eth0 , eth1

Loading

在 VMWare 下面的虛擬機器遇到一個怪問題,我的網路裝置不知怎麼回事,以前是 eth0 後來不知道為什麼變成 eth1 ,而且改不回來.一開始還以為是 NetworkManager 設定有問題,檢查了設定檔

  • /etc/NetworkManager/NetworkManager.conf
  • /etc/sysconfig/network-scripts/ifcfg-*

改了半天還是一樣.

那會不會是因為有設定 Biosdevname 或是 net.ifnames 仔細看應該不是,最後才想到 udev 的命名規則 https://benjr.tw/10626

udev 可以依據裝置特性來個別命名,設定檔存放在 /etc/udev/rules.d/ 系統已經有一個是專門為網路卡預設的檔案 “70-persistent-net.rules ”

[root@benjr ~]# cd /etc/udev/rules.d/
[root@benjr rules.d]# ll 70-persistent-net.rules 
-rw-r--r-- 1 root root 630 2016-07-07 23:05 70-persistent-net.rules

設定已經有一筆 eth0 而且跟目前的 MAC 不符合.應該有人改過 這一台虛擬機的硬體裝置.

[root@benjr rules.d]# cat 70-persistent-net.rules 
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:1c:52:10", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f6:4d:73", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

直接註記掉最早的設定,並將後來的 eth1 修改成 eth0 , 重新開機即可.

[root@benjr rules.d]# vi 70-persistent-net.rules 
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:1c:52:10", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f6:4d:73", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
沒有解決問題,試試搜尋本站其他內容

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料