複製した仮想マシンのNIC

昨日vCenter Converterで複製した仮想マシンubuntuを起動してみたが、eth0がupしない。

これって以前も経験した記憶があるのだけど、どこかにメモしてなかったっけ...

ということで、もう一度メモ。

ubuntuでは、

/etc/udev/rules.d/70-persistent-net.rules

に、利用しているNICMACアドレスで記録しておき、eth0やeth1など番号を固定している様子で、NICMACが変更になった場合は、これを直接viなんかで開いて、下記のようになっている箇所のMACを書き換えてあげる必要がある。

xxxx@ubuntu:/etc/udev/rules.d$ cat 70-persistent-net.rules.old 
# 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)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:fd:6b:ef", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:fd:6b:f9", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

このATTR{address}って所に書いているMACを書き換える。

でも、面倒な場合はひとまずSUBSYSTEMから始まる行をすべて消してしまい、再起動、というのが一番楽かも。
すると、認識した順にeth0, eth1, .... とこのファイルに自動で書き込んでくれるので、この後は/etc/network/interfaceに設定されているとおりに、IFの設定を行ってくれるようになる。