ContOS 克隆虛擬機器修改ip方法
阿新 • • 發佈:2019-02-15
臨時的意義不大,現查就行
1改ip
ifconfig
eth1 Link encap:Ethernet HWaddr 00:0C:29:32:F5:64 inet addr:192.168.25.133 Bcast:192.168.25.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe32:f564/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:49 errors:0 dropped:0 overruns:0 frame:0 TX packets:41 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:6623 (6.4 KiB) TX bytes:5543 (5.4 KiB) Interrupt:19 Base address:0x2024 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:119 errors:0 dropped:0 overruns:0 frame:0 TX packets:119 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:8684 (8.4 KiB) TX bytes:8684 (8.4 KiB)
cd /etc/sysconfig/network-scripts
ll
-rw-r--r--. 1 root root 262 Jul 29 2015 ifcfg-Auto_eth2
-rw-r--r--. 1 root root 254 Jan 9 2013 ifcfg-lo
vim ifcfg-Auto_eth2
TYPE=Ethernet HWADDR=00:0C:29:32:F5:64 #不能與其他虛擬機器的mac相同 TYPE=Ethernet BOOTPROTO=none IPADDR=192.168.25.130 #不與其他虛擬機器的ip相同 PREFIX=24 G:ATEWAY=192.168.25.2 DNS1=192.168.25.2 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="eth0" UUID=6e6f9829-0737-4943-ab21-61d6173ba8c4 ONBOOT=yes LAST_CONNECT=1438160743
cd /etc/sysconfig/network-scripts
發現修改的eth0無效
2 檢視虛擬機器網絡卡資訊
vim /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_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. #mac要與虛擬機器的相同 # PCI device 0x1022:0x2000 (vmxnet) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:cc:16:f0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" #刪了下邊的 # PCI device 0x1022:0x2000 (vmxnet) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:32:f5:64", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
3 重啟網路配置。
service network restart