Recently, during the development process, I found that the virtual machine connected by xshell is always disconnected, which is a big headache. After looking at it, the reason is that the IP address of the virtual machine has been changing, because Linux automatically obtains the IP by default, so we only need to automatically Get the IP and set it to a static IP address.
1. Switch directory:
cd /etc/sysconfig/network-scripts/
2. Modify the configuration file:
vim ifcfg-ens33
Change Get IP Address to Static and add the IP address you want to change to.
Save and exit!
3. Restart the network service:
service network restart
4. View the virtual machine IP:
ip addr
If this address is consistent with what you modified, it means that the modification is successful! ! !