CentOS 7 on Servers
Go to the location of the network-scripts file
# cd /etc/sysconfig/network-scripts
Check network card device
# ifconfig
Check network files
# ls
Open the network configuration file or Create a new network file based on the card network name
# vi ifcfg-enp0s3
TYPE="Ethernet"
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=192.168.31.211
NETMASK=255.255.255.0
GATEWAY=192.168.31.1
DNS1=192.168.2.254
DNS2=8.8.8.8
DNS3=8.8.4.4
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens011
DEVICE=enp0s3
ONBOOT=yes
# Button [i] to edit file and [esc] to exit edit [:wq] save and exit vi
Verify information from network device files
# cat ifcfg-enp0s3
Restart network card
# systemctl restart NetworkManager
# Static IP address does not change
Turn off/on the network card to change the IP address configuration
# ifdown enp0s3
# ifup enp0s3
# ifconfig
# IP address has changed
Use the ping command to check if the destination host is reachable