How to regenerate network card configuration files in CentOS 7?

To regenerate the network card configuration file for CentOS 7, follow these steps:

  1. Open a terminal window and log in to the system as an administrator.
  2. Navigate to the directory where the network card configuration file is located and use the following command:
cd /etc/sysconfig/network-scripts/
  1. To check the current network card configuration file, use the following command:
ls ifcfg-*
  1. If you need to regenerate the configuration file for a specific network card, you can first backup the original configuration file and then use the following command (assuming the network card that needs to be regenerated is eth0):
cp ifcfg-eth0 ifcfg-eth0.bak
  1. Delete the existing network card configuration file and use the following command:
rm -f ifcfg-eth0
  1. Create a new network interface configuration file using a text editor (such as vi) by using the following command:
vi ifcfg-eth0
  1. “Enter the new network card configuration information in the editor, for example:”
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

This is an example configuration that automatically obtains an IP address using DHCP. Modify the configuration information according to actual needs.

  1. Save and close the editor.
  2. To restart the network service, use the following command:
systemctl restart network

After regenerating the network card configuration file, the network card will start with the new configuration.

bannerAds