CentOS 7 Network Configuration Guide
To configure network interfaces and parameters, you can follow the steps below:
- Open the terminal and enter the following command to edit the network configuration file:
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
The eth0 here refers to the network card name and should be replaced with the corresponding network card name based on the actual situation.
- In editing mode, you can add or modify the following parameters to configure the network interface:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
The meanings of the parameters here are as follows:
- Device: Network card name
- BOOTPROTO: IP address acquisition method, can be selected as static or dynamic.
- ONBOOT: Whether to start automatically when the system boots up.
- IPADDR: Internet Protocol Address
- NETMASK: subnet mask
- Gateway: the address of the gateway.
- DNS1 and DNS2: Addresses of DNS servers.
- Save and exit editing mode, then reboot the network service using the following command to apply the configuration changes:
sudo systemctl restart network
By following the steps above, you can successfully configure the network interface and network parameters. Please modify the corresponding configuration information according to the actual situation.