[Linux] 啟動網路報錯 Device not managed by NetworkManager or unavailable

如標題
Linux虛擬機網絡配置中,執行重啟網絡命令:

service network start

系統報錯
Error:Connection activation failed:Device not managed by NetworkManager

VMWare 再複製CentOS虛擬機後,ifconfig -a ,eth0不見, 多了一個eth1,
但是有/etc/sysconfig/network-scripts/ifcfg-eth0文件, 無ifcfg-eth1
在運行#/etc/init.d/network restart, 重啟網絡連接時出現以下錯誤:
Bringing up interface eth0: Error:Connection activation failed:Device not managed by NetworkManager

造成的原因是複製CentOS虛擬機後,
VMWare為了避免網卡衝突又重新為新的CentOS虛擬機虛擬出來了一個網卡eth1,
這就是為什麼ifconfig時沒有eth0了,雖然VMWare為新的CentOS虛擬機虛擬了一個新的網卡eth1,
但它並沒有更改/etc/sysconfig/network-scripts/ifcfg-eth0 文件, 因此錯誤就出現了。如果重複幾次或許可能會有eth2,eth3等


解法:

  1. mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
  2. 修改/etc/sysconfig/network-scripts/ifcfg-eth1中的
    DEVICE="eth0"改為DEVICE="eth1"
    HWADDR="XX:XX:XX:XX:XX:XX"改為eth1的物理地址(用ifconfig -a查看)
    並修改IPADDR裡的IP地址
  3. service network restart還是會報錯:
    Bringing up interface eth0: Error:Connection activation failed:Device not managed by NetworkManager
  4. Remove Network Manager from startup Services.
    #chkconfig NetworkManager off
  5. Add Default Net Manager
    #chkconfig network on
  6. Stop NetworkManager first
    #service NetworkManager stop
  7. and then start Default Manager
    ​#service network start