Home >Operation and Maintenance >Linux Operation and Maintenance >How to set ip address in centos7
vi /etc/sysconfig/network-scripts/ifcfg-enpos3
In the file, change
BOOTPROTO to static,
At the same time add
IPADDR=192.168.1.150
NETMASK= 255.255.255.0
GATEWAY=192.168.1.1
If ONBOOT=no, change it to yes.
When modifying, make sure the IP address and gateway are in the same network segment.
Restart the service, service network restart
Set the DNS server,
vi /etc/resolv.conf
Add nameserver 8.8.8.8
ip addr to view the IP address Whether the setting is successful
Then execute the command and ping www.baidu.com
If the ping succeeds, the setting is successful.
END
The above is the detailed content of How to set ip address in centos7. For more information, please follow other related articles on the PHP Chinese website!