The following column centos introductory tutorial will introduce to you two ways to modify IP in Centos. I hope it will be helpful to friends in need!
Method 1:
View the current ip address of the system : ip add
##nmtui command brings up the modification window: nmtui
##Restart the network card:
/etc/init.d/network restart
##Or:
service network restart
Method 2:
Enter the network configuration file directory
First, make sure to operate under the
root user. Enter the network configuration filenetwork-scripts directory. cd /etc/sysconfig/network-scripts/
Find the configuration file we need to modify
Use the
ls command to list the files in the directory. Among them, the "ifcfg-ens33" file is the network configuration file we need to modify. Modify the configuration file
Use the
vim command (vi Commands can also be used),Configure the file,
We need to modify itBOOTPROTO="static"That is, change dhcp to static, modify ONBOOT = "yes" means to set the network card to be enabled at boot, and 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!
Restart the network service Use the service network restart command to restart the network service. For more centos related technical articles, please visit the centos system tutorial column!
The above is the detailed content of Share two ways to modify IP in Centos. For more information, please follow other related articles on the PHP Chinese website!