通常爲了節省時間,在VMware中安裝一套Linux後,會直接克隆一份出來使用。但在克隆REDHAT 6後,會發現網卡名稱發生變化,比如eth0會變爲eth1,下面介紹下克隆後的redhat 6,如何修改主機名、IP地址和網卡名稱。
修改主機名(共2步)
hostname amto02
vi /etc/sysconfig/network -> 修改項:HOSTNAME=amto02
還原網卡名稱爲eth0:
[root@amto02 u01]# cat /etc/udev/rules.d/70-persistent-net.rules.bak
# 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:27:be:dc", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:8a:8d:19", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
在該配置文件中會發現存在2條記錄,第二條記錄是克隆/複製虛擬機後,重新生成的一個mac地址(00:0c:29:8a:8d:19),因此,需要把就配置刪除掉,也就是將第1條記錄刪除。並且第2條記錄的最後面,將eth1改爲eth0。修改後的配置文件爲:
[root@amto02 u01]# 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)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:8a:8d:19", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
修改IP地址:
運行setup或者system-config-network,按照提示填寫新的IP信息即可。
重啓網卡服務:
service NetworkManager restart
service network restart