Modify the static IP address of the Linux virtual machine

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/

insert image description here

2. Modify the configuration file:

vim ifcfg-ens33

insert image description here

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

insert image description here
4. View the virtual machine IP:

ip addr

insert image description here

If this address is consistent with what you modified, it means that the modification is successful! ! !

Guess you like

Origin blog.csdn.net/yy12345_6_/article/details/126610319