今回も、VMware の設定ファイルをいじって実験しています。
MAC を変更して再起動したら、eth0 ではなくて eth1 になってしまいました。
[root@centos6 ~]# cat /etc/redhat-release
CentOS Linux release 6.0 (Final)
[root@centos6 ~]# ls /etc/sysconfig/network-scripts/ifcfg-eth*
/etc/sysconfig/network-scripts/ifcfg-eth0
[root@centos6 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
HWADDR="00:0C:29:A3:8B:6B"
NM_CONTROLLED="yes"
ONBOOT="no"
[root@centos6 ~]# cat /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 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:8b:6b", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:8b:69", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
[root@centos6 ~]# ifconfig eth0
eth0: error fetching interface information: Device not found
[root@centos6 ~]# ifconfig eth1
eth1 Link encap:Ethernet HWaddr 00:0C:29:A3:8B:69
CentOS 5 や 4 と違って、/etc/sysconfig/network-scripts/ifcfg-eth* が自動で増えたり書き換わることはないのですが、udev のルールファイルが自動更新されます。素直に下記のように変更して、システムを再起動すれば、対処できます。
[root@centos6 ~]# cat /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 0x8086:0x100f (e1000) (custom name provided by external tool)
# SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:8b:6b", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:8b:69", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
[root@centos6 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
HWADDR="00:0C:29:A3:8B:69"
NM_CONTROLLED="yes"
ONBOOT="no"
[root@centos6 ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:A3:8B:69
わたしは初回、udev のほうに気をとられて、ifcfg-eth* の中の HWADDR の書き換えを忘れてハマりました。ご注意ください。なお、70-persistent-net.rules ファイルを自動書き換えしているのは、/lib/udev/write_net_rules です。シェルスクリプトなので、眺めてみると、メカニズムが垣間見えて良いかも。
2011-08-07追記
固定化する方法について、書きましたので、よろしければ参照ください。
CentOS 6.0 で NIC と ethX の対応を固定化する

0 件のコメント:
コメントを投稿