CentOS 7 is a popular Linux distribution used by many system administrators for server management. One of the important tasks in server management is configuring and managing network settings. In this blog, we will go over the steps involved in configuring and managing network settings in CentOS 7.
Step 1: Check the current network configuration
Before making any changes to the network settings, it’s essential to check the current network configuration. This can be done by running the following command in the terminal:
$ ip addr
This command will display the network interfaces and their IP addresses currently configured on the system.
Step 2: Configure network settings
To configure the network settings in CentOS 7, we need to modify the network configuration file. The network configuration file is located in the /etc/sysconfig/network-scripts/
directory and is named ifcfg-<interface>
(where <interface>
is the name of the network interface).
For example, to configure the network settings for the Ethernet interface eth0
, we need to modify the file /etc/sysconfig/network-scripts/ifcfg-eth0
.
To edit this file, run the following command:
$ sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0
This will open the file in the nano text editor. Modify the file as required and save the changes. Here is an example of a basic network configuration:
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=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
ONBOOT=yes
The BOOTPROTO
option can be set to dhcp
if the network is configured to use DHCP.
Step 3: Restart the network service
After modifying the network configuration file, we need to restart the network service for the changes to take effect. To restart the network service, run the following command:
$ sudo systemctl restart network
This will restart the network service and apply the new network configuration.
Step 4: Verify network configuration
To verify the new network configuration, we can run the ip addr
command again to display the updated network settings. We can also test the network connectivity by pinging another device on the network.
$ ping google.com
This command will test the connectivity to the Google website.
Conclusion
Configuring and managing network settings in CentOS 7 is an essential task for system administrators. By following the above steps, you can easily configure and manage the network settings on your CentOS 7 system. Remember to always verify the network configuration after making changes and restart the network service for the changes to take effect.