Centos6克隆虚拟机改IP和mac地址
1.生成新的MAC地址
2.查看ip
[root@localhost ~]# ifconfig eth1 Link encap:Ethernet HWaddr 00:50:56:23:B0:4F inet addr:192.168.146.130 Bcast:192.168.146.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:fe23:b04f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:121 errors:0 dropped:0 overruns:0 frame:0 TX packets:54 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:10975 (10.7 KiB) TX bytes:6571 (6.4 KiB) lo 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:16 errors:0 dropped:0 overruns:0 frame:0 TX packets:16 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:940 (940.0 b) TX bytes:940 (940.0 b) [root@localhost ~]#
3.使用vim /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:50:56:31:32:0e", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # PCI device 0x8086:0x100f (e1000) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:23:b0:4f", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" ~ ~
4.根据ifconfig查看HWaddr 00:50:56:23:B0:4F除外的删除,就是还剩下的,(注:你们根据你们自己的定)
# 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:50:56:23:b0:4f", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" ~
5.使用 vim /etc/sysconfig/network-scripts/ifcfg-eth0 修改成下面
[root@localhost ~]# cd / [root@localhost /]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO="dhcp" HWADDR="00:50:56:23:B0:4F" IPV6INIT="yes" NM_CONTROLLED="yes" ONBOOT="yes" TYPE="Ethernet" UUID="2dbea590-a659-4e94-9626-f5f59dacde22" IPADDR="192.168.146.130" NETMASK="255.255.255.0" GATEWAY="192.168.146.1"
6.service network restart 重启网络
[root@localhost /]# service network restart Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: Active connection state: activating Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1 state: activated Connection activated [ OK ] [root@localhost /]#
这样就可以了
# 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:50:56:23:b0:4f", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" ~ |