The CentOS is created in the VM, and the IP address always changes after each reboot.
1. Modify the configuration in the VM
Edit----> virtual Network Editor
Turn on NAT settings
Remember this Gateway IP
2. Go to the CentOS modification configuration file
Mainly involves 3 documents
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resoly.conf
First modify the network file
Networking=yes
Hostname=localhost.localdomain
gateway=192.168.113.2
Specify the gateway address:
Modify the Ifcfg-eth0 file
Device= "Eth0"
#BOOTPROTO = "DHCP"
bootproto= "Static"
ipaddr=192.168.113.113
netmask=255.255.255.0
Hwaddr= "00:0c:29:56:8f:ad"
Ipv6init= "No"
Nm_controlled= "Yes"
onboot= "Yes"
Type= "Ethernet"
Uuid= "Ba48a4c0-f33d-4e05-98bd-248b01691c20"
dns1=192.168.113.2
Modify the resoly.conf file
NameServer 192.168.113.2
Restarting the client can
Vm CentOS set static IP address