Just installed CentOS, the default configuration is dynamic IP, if the virtual machine restarted (although not often), the IP address switched, and then use the Remote tool connection to re-change the address, laborious.
Today, a static address is set and recorded.
Environment: VMware 10.0.0 + CentOS 6
First, set up VMware's network settings
- Edit > virtual Network Editor
- VMnet8 > Nat Mode (IP address of shared host with virtual machine)
- Select "Nat Settings" and remember "Gateway IP" (set to use later)
- Uncheck the "Use local DHCP service to assign IP addresses to virtual machines" check box
- Right-click installed systems > Settings > Network adapters > select NAT Mode
- By the way, click "Advanced", note the MAC address (set to use later)
Modifying a Linux configuration file
As the following configuration file needs to be modified, modify the information after the file for the example below, it is recommended to pre-modify the backup:
- /etc/sysconfig/network
- /etc/sysconfig/network-scripts/ifcfg-eth0
- /etc/resolv.conf
This case hypothesis data:
- Gateway ip:192.168.116.2
- The static ip:192.168.116.130 to be set
- MAC Address: XX:XX:XX:XX:XX:XX
networking=yeshostname=localhost.localdomaingateway=192.168.116.2
/etc/sysconfig/network
Device= "eth0"# Bootproto= "DHCP"bootprote= "Static"ipaddr=192.168.116.130 NETMASK =255.255.255.0HWADDR= "XX:XX:XX:XX:XX:XX"ipv6init= "No"nm_controlled= "Yes" Onboot= "Yes"TYPE= "Ethernet"UUID= "948bedc9-f08f-49cd-8c06-4a7a9fcd2e4e"DNS1= 192.168.116.2
/etc/sysconfig/network-scripts/ifcfg-eth0
192.168.116.2
/etc/resolv.conf
Restart Network after modification
Service Network restart
View Code
Test
The last ping is successful.
Configuring static IP addresses in Linux