What are the steps for configuring the network in CentOS 7?
The steps to configure the network on CentOS 7 are as follows:
- Open the terminal and log in as root user.
- Edit the network configuration file. Use the following command to open the network configuration file:
- Open the file ifcfg-eth0 located in the network-scripts directory.
- ifcfg-eth0 is the default network card configuration file, and if you are using a different network card, you need to modify the file name accordingly.
- Configure the IP address. Add or modify the following lines in the file, according to your network configuration.
- BOOTPROTO is set to static with the IP address 192.168.1.100, subnet mask 255.255.255.0, gateway 192.168.1.1, and DNS servers configured as 8.8.8.8 and 8.8.4.4.
- IPADDR is the IP address you want to set, NETMASK is the subnet mask, GATEWAY is the gateway address, and DNS1 and DNS2 are the DNS server addresses.
- Set the network device name. Add or modify the following lines in the file to set the network card device name as eth0:
- Ethernet device=eth0
- If you are using a different network card device, you need to modify the device name accordingly.
- Save and close the file. Hit the Esc key, then type :wq, then press Enter to save and exit the vi editor.
- Restart the network service. Use the following command to restart the network service to apply the configuration:
- Restart the network service using systemctl.
After completing the above steps, the network configuration of your CentOS 7 system will be updated to the specified IP address and other settings.