VMware vSphere で RedHat Enterprise Linux (RHEL) をクローンすると NIC が認識されない





VMware vSphere で RedHat Enterprise Linux (RHEL 6.0)をクローンした場合、
クローン前の NIC が正しく認識されないため、
NIC の設定を調整する必要がある。

NIC を1つ (eth0) 使用していたRHEL 6.0 をクローンした後すぐの NIC の状態は、以下の通り。

# [root@test ~]# ifconfig -a
eth1      Link encap:Ethernet  HWaddr 00:50:56:BA:00:5C
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

lo0       Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:30 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2172 (2.1 KiB)  TX bytes:2172 (2.1 KiB)

[root@test ~]#

eth0 は OS に認識されておらず、eth1 が新たに追加されている。

この場合、以下のファイルを修正することでクローン前と同様の状態に戻すことができる。

/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)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:ba:00:ae",
 ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:ba:00:5c",
 ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

問題箇所は、eth0 の MAC アドレスがクローン前の仮想マシンの MAC アドレスになっているところ。
その代わりに、eth1 がクローンで作成した新しい仮想マシンの MAC アドレスになっている。
そこで、元々定義されている eth0 の行をコメントアウトして、
eth1 の設定を eth0 用に変更する。

# 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)
# SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:ba:00:ae",
 ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:ba:00:5c",
 ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

システムを再起動して、設定が反映される。
再起動後の NIC の認識は以下の通り。

# [root@test ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:50:56:BA:00:5C
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

lo0       Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@test ~]#

これで、クローン前の仮想マシンと同様に eth0 を利用可能になった。