Introduction
As a system administrator, network configuration is one of the critical tasks that you may encounter. One of the most frustrating issues is when the network card configuration is incorrect. In this article, you will learn how to restore and reset the network interface card (NIC) configuration on CentOS operating system.
Determine the Network Interface Card
The first step in restoring the network card settings is by identifying the network interface card name. Use the ip command or ifconfig to list all available network interfaces:
$ ip a
or
$ ifconfig -a
Once you identify the network interface card, you can proceed to restore its configuration or reset it to default.
Restore Network Card Configuration
If you made changes to the network interface card configuration, and something went wrong, you might want to revert the settings to the previous state. CentOS stores network configurations in the /etc/sysconfig/network-scripts/ directory.
To restore the network card settings, navigate to the directory where the configuration file is located:
$ cd /etc/sysconfig/network-scripts/
Then open the configuration file of the network interface card that you want to restore using a text editor such as nano or vi:
$ sudo nano ifcfg-eth0
Replace "eth0" with the name of the network interface card that you want to restore. Once you open the file, remove any changes that you made earlier, and save the file. Finally, restart the network service using the following command:
$ sudo systemctl restart network
The network service will restart, and the network card configuration will be restored to the previous state.
Reset Network Interface Card to Default
Sometimes, you might want to reset the network interface card to its default configuration, especially if the network card is not working correctly, or you encounter network problems after making changes to the configuration. In such a situation, you can reset the network card configuration to its default through the following steps:
First, navigate to the network configuration directory like this:
$ cd /etc/sysconfig/network-scripts/
Then, remove the configuration file of the network interface card to reset to default. For instance, to reset eth0, execute the following command:
$ sudo rm ifcfg-eth0
After removing the configuration file, you need to recreate the configuration file. To create the new configuration file, run the following command:
$ sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0
In the new file, add the following information:
TYPE=Ethernet
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
Save and close the file, then restart the network service using the following command:
$ sudo systemctl restart network
The network service will then restart, and the network interface card will be reset to its default configuration.
Conclusion
Restoring and resetting the network interface card configuration on CentOS is an essential task that every system administrator should know how to perform. With the above steps, you can easily restore the network interface card to its previous settings or reset it to its default configuration.