In the previous version of CentOS 7, you can set your own static IP address through Setup, but starting with CentOS 7, it seems that this function has expired, if you want to configure our server a static IP address, we have to modify the configuration file to achieve this requirement
No more nonsense, let's see how to configure the static IP address for CentOS 7
Enter the path of the configuration file to configure the network:
Vim/etc/sysconfig/network-scripts/ifcfg-em1
Then modify the content inside, the content needs to be modified only two:
Bootproto=static # Here is the default DHCP
Onboot=yes # The default here is no
Then add these at the end of the file:
ipaddr=192.168.0.2 #这里配置你所需要配置的静态IP Address
netmask=255.255.255.0 #这里是子网掩码
gateway=192.168.0.1 # Gateway
dns1=202.106.0.20 # DNS Address
Finally, restart the NIC
Service Network restart
Now, check your IP address, have you changed it?
Ifconfig
This article is from the "Ride a Pig to Travel" blog, please be sure to keep this source http://songqinglong.blog.51cto.com/7591177/1786891
CentOS7 IP address configuration