Home >Operation and Maintenance >CentOS >How to configure the network in centos7
Foreword:
In the Linux system, the configuration file of the system network device is saved in the /etc/sysconfig/network-scripts directory, where the file ifcfg-eno16777736 contains Configuration information of a network card. The file ifcfg-lo contains loop IP address information.
Configuration process:
1. Edit the configuration file
vim /etc/sysconfig/network-scripts/ifcfg-enp0s3
The red mark (enp0s3) is the name of the network card. You can view the name of the network card through the ifconfig command, as shown below, The network card name is enp0s3.
(1) You can set the following 4 options for BOOTPRTO (indicating whether the network card is configured with a static or dynamic IP address).
none: Indicates that there is no need to activate the protocol.
bootp: Indicates the use of BOOTP protocol.
dhcp: Indicates using the DHCP protocol to dynamically obtain an IP address.
static: Indicates manually setting a static IP address.
(Recommended tutorial: centos tutorial)
(2) ONBOOT=yes
indicates whether to activate the network card when starting the system, yes indicates activation, no means not activated.
2. Restart the network service
After modifying the service configuration file in the Linux system, it will not have an immediate effect on the service program. If you want the service program to obtain the latest configuration file, you need to manually restart the corresponding service (systemctl restart network), and then you can see that the network is smooth:
systemctl restart network (重启网络服务) systemctl start network (启动网络服务) systemctl stop network (停止网络服务)
The command in CentOS6/RHEL6 system is:
service network restart (重启网络服务) service network start (启动网络服务) service network stop (停止网络服务)
3. Test
ping -c 4 baidu.com
Related video tutorial recommendations: linux video tutorial
The above is the detailed content of How to configure the network in centos7. For more information, please follow other related articles on the PHP Chinese website!