Set a fixed IP for CentOS6 in VMware

host win7

vm_12

ctenOS 6.*_x64

Not much to say, the settings directly look at the picture:

1. Virtual machine settings select NAT mode:



 2. Edit>Virtual Network Editor, set the configuration of NAT mode, turn off DHCP dynamic allocation of ip; set the subnet IP and gateway, in order to connect the host function, you need to set the network to the same network segment.

3. Open the virtual machine and set a fixed IP;

Three configuration files are involved, namely:

/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf

 
 
First modify vim /etc/sysconfig/network as follows:

NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.1.2

 Then modify vim /etc/sysconfig/network-scripts/ifcfg-eth0 The last ifcfg-eth0 can be viewed by ifconfig, the specific names are different.

 

DEVICE="eth0"
#BOOTPROTO="dhcp"
HWADDR="00:0C:29:B6:96:23"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="14eb8f11-92b6-4a5b-a597-d337404e9685"
BOOTPROTO="static" #静态
IPADDR=192.168.1.88
NETMASK=255.255.255.0
DNS1=192.168.1.2

 Note : DNS1 must be set here, otherwise domain name resolution cannot be performed.

Finally configure /etc/resolv.conf:

nameserver 192.168.1.2

 In fact, this step can be omitted. After the DNS Server address is set above, the system will automatically modify the configuration file.

4. Enter "service network restart" in the terminal to restart the network service, and you will see that the configured IP is: 192.168.1.88

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326533708&siteId=291194637