How does the Centos7 system modify the IP address?

Time:2019-8-11

This article mainly elaborates the method of modifying IP address in Centos7.

I. Enter the Network Profile Directory

First, make sure you operate under the root user. Enter the network-scripts directory of the network configuration file.

Two.Find the configuration file we need to modify

List the files in this directory using the LS command. Among them“ifcfg-ens33(red box) file, for the network configuration file we need to modify.

III. Modification of configuration files

UseVIM command(vi command can also be used). To configure the file, we need to modify it.BOOTPROTO=”static“That is to say, change DHCP to static and modify it.ONBOOT=”yes”This means that the network card is set to boot, and added under the text.

IPADDR=192.168.0.230# Static IP

GATEWAY=192.168.0.1 #Default gateway

NETMASK=255.255.255.0 #Subnet mask

DNS1=192.168.0.1 #DNS configuration

DNS2=8.8.8.8# Google Address

Red boxes are for modifying content, and purple boxes are for adding content.

ESC+WQSave Exit!

IV. Restart Network Services

UseService network restart commandRestart network services. (The red box restarts the network service command and the blue box restarts the network service status)

5. View the effect of our changes

Because it’s now Centos7 so we use the new command, we typeIP addr for viewing。 (Red box is the view command, blue box is the network card status)

Relevant recommendations:

What should centos7 do without the ifconfig command?