現象:
一臺克隆生成的centos,啓動後使用ifconfig查看網絡信息,發現只有lo而沒有任何可用網卡.
使用ifup eth0後報vmware device eth0 does not seem to be present delaying initialization
大概意識是找不到eth0這個網絡設備
使用
ls /sys/class/net
查看物理網卡信息返回結果如下:
eth1 lo
原因:
很多Linux distribution使用udev動態管理設備文件,並根據設備的信息對其進行持久化命名。例如在
解決方法:
編輯如下文件
/etc/udev/rules.d/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:50:56:bc:00:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:46", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# 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:50:56:bc:00:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:46", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
註釋掉eth0的那個段落,然後將eth1的修改爲eth0
修改網卡配置文件
/etc/sysconfig/network-scripts/ifcfg-eth0
把mac地址修改爲eth1的地址
HWADDR字段
重啓後生效
當然,如果你還什麼東西都沒裝,沒有在什麼配置文件中指定過eth0字段的話.直接cp或者mv ifcfg-eth0 ifcfg-eth1也是可以的.