Set fixed IP for VMware 15 Pro virtual machine Centos

After using VMware to build a local CentOS virtual machine, connect to the virtual machine through Xshell, and use the bridged network connection method to reconnect the virtual machine, the virtual machine IP address may change continuously. This is very inconvenient for the management of virtual machines, especially the management of cluster applications. Therefore, the dynamic IP in the virtual machine needs to be changed to a fixed IP.

1. Check the local IP (windows10)

Check the local IP address, enter ipconfig in the console , the virtual machine settings need to be in the same network segment as the local host
Local IP

2. Set the IP address of the virtual machine VMnet8

 IP address of VMnet8

VMnet8 and host IP are in the same network segment

3. Set up the VMware virtual network editor

 VMware Virtual Network Editor

4. Change settings

Change settings
Click on the bottom right corner to change configuration

5. Set NAT mode

Set NAT mode

6. NAT gateway settings

NAT gateway settings

7. Log in to the Centos virtual machine

Use the root account, enter the directory: /etc/sysconfig/network-scripts/, set up the virtual network card

Set up virtual network card

8. Configure a fixed IP

[root@elktest4 network-scripts]# cd /etc/sysconfig/network-scripts/
[root@elktest4 network-scripts]# vim ifcfg-ens33 

Configure a fixed IP

Note: pay attention to the mask address (NETMASK) not to be wrong

9. Restart the network card and check if you can access the Internet normally

[root@elktest4 network-scripts]# vim ifcfg-ens33 
[root@elktest4 network-scripts]# service network restart
[root@elktest4 network-scripts]# ping -c 5 baidu.com
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=128 time=58.0 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=128 time=39.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=128 time=40.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=128 time=42.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=5 ttl=128 time=40.0 ms

10. View the virtual machine IP

View virtual machine IP
As shown in the figure, it has been configured as a custom IP address.

Guess you like

Origin blog.csdn.net/qq_36148847/article/details/113103816