Configuring a static IP address for Linux server (virtual machine)

Introduction: The role of the server is undoubtedly to serve our needs. The server is fixed in a certain location. Of course, its IP address also needs to be fixed. If the server's IP address changes all the time, the client will inevitably have a headache.

1. Complete the static IP address settings in the virtual network editor

 

 

 

 2. Enter the CentOS 7 system network configuration directory to modify the configuration file

1. Enter the CentOS 7 system network configuration directory (cd /etc/sysconfig/network-scripts)

 2. View the network card configuration file (ls)

 3. Edit the configuration file corresponding to the network card (vim ifcfg-network card name)

Note: Added and modified content in the red box

Vim editing tips:

                                                     Save and exit
Order operate
:In save document
:w filename Save as filename
:q Exit vim (without saving)
:wq Save and exit vim
:q! Force quit, used to give up saving changes
:wq! Force retention to exit vim

 

3. Restart network service (systemctl restart network)

 At this point, the static IP address configuration is completed

Guess you like

Origin blog.csdn.net/weixin_63037066/article/details/129475556