Home >Operation and Maintenance >CentOS >How to set ip in centos
How to set IP in centos:
Before configuring the network, we must first know what the network card name of centos is. Centos7 no longer uses the ifconfig command. You can use the command IP addr view.
1. Obtain IP dynamically (provided that your router has enabled DHCP)
Modify the network card configuration file vi /etc/sysconfig/network-scripts /ifcfg-ens32 (The last one is the network card name)
You need to modify two places to dynamically obtain the IP address
(1)bootproto=dhcp
(2)onboot =yes
After modification, restart the network service. systemctl restart network
[root@mini ~]# systemctl restart network
2. Configure static IP address
Set static IP The address is similar to the dynamic iIP. You also need to modify the network card configuration file vi /etc/sysconfig/network-scripts/ifcfg-ens32 (the last one is the network card name)
(1) bootproto=static
(2) onboot=yes
(3) Add a few lines at the end, IP address, subnet mask, gateway, dns server
IPADDR=192.168.1.160 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 DNS1=119.29.29.29 DNS2=8.8.8.8
(4) Restart the network service
[root@mini ~]# systemctl restart network
Recommended tutorial: centos tutorial
The above is the detailed content of How to set ip in centos. For more information, please follow other related articles on the PHP Chinese website!