1. Enter the network configuration file directory
First, make sure you are operating under the root user. Enter the network configuration file network-scripts directory.
[root@localhost /]# cd /etc/sysconfig/network-scripts/
Second, find the configuration file we need to modify
Use the ls command to list the files in this directory. The " ifcfg-ens33 " file is the network configuration file we need to modify.
3. Modify the configuration file
Use the vim command (vi command is also available) to configure the file,
We need to modify BOOTPROTO="static "that is, change dhcp to static,
Modifying ONBOOT="yes" means setting the network card to be enabled on boot,
Also add below 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
ESC :+WQ, save and exit!
Fourth, restart the network service
Run the service network restart command to restart the network service.
5. View the effect of our changes
Because it is Centos7 now, we use a new command, and we enter ip addr to view it .