Configure static IP addresses in Centos in VMware NAT Mode
1. First, deselect the "use local DHCP service to allocate IP addresses to virtual machines" option, view the gateway address of the virtual network card in NAT mode, and record it (default VMnet8 ).
2. Enter the following command on the terminal to edit the/etc/sysconfig/network file.
# vim /etc/sysconfig/network
Add GATEWAY address 192.168.166.2
NETWORKING = yesHOSTNAME = localhost. localdomain # Add GATEWAY = 192.168.166.2 as follows
3. Then enter the following command on the terminal to edit the/etc/sysconfig/network-scripts/ifcfg-eth0 File
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
Modify as follows:
DEVICE = "eth0" # BOOTPROTO = "dhcp" comment out the original dhcp # --- Add the following --- BOOTPROTO = "static" IPADDR = 192.168.166.175NETMASK = 255.255.255.0GATEWAY = 192.168.166.2 # --- add the above --- HWADDR =" 00: 0C: 29: 56: 8F: AD "IPV6INIT =" no "# --- NM_CONTROLLED changed to no --- NM_CONTROLLED =" no "ONBOOT =" yes "TYPE =" Ethernet "UUID =" ba48a4c0-f33d-4e05-98bd-248b01691c20 "# --- add DNS1, don't write the DNS---DNS1 = 192.168.166.2
4. Restart the service
# service network restart
5. Auxiliary matters
- If the Restart service does not take effect, restart centOS
- If the restart of centOS does not take effect, disable centOS, manually modify the IP address of the NAT virtual Nic, and then start centOS (replace the IP addresses in the preceding steps ).
6. The reason why Device eth0 does not seem to be present and delaying initialization is wrong is displayed in the clone Vm of VMware: linux Nic bound to the original mac address causes 1. Use ifconfig-a to view the mac address of the current host
Run the following command to modify HWaddr:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
2. Delete the 70-persistent-net.rules file.
rm -rf /etc/udev/rules.d/70-persistent-net.rules
4. restart the system.
reboot -h now