1. Mainpage
  2. Knowledge Base
  3. How to configure network interfaces in CentOS

How to configure network interfaces in CentOS


Configuring the network in CentOS is a crucial aspect of preparing your server for operation. It ensures the server’s connectivity with the outside world and sets up interactions with other devices on the network. In this article, we will thoroughly examine the process of configuring network settings through the console, starting from installing the necessary tools to the detailed configuration of network interfaces.

The first step in network configuration on CentOS is to install the net-tools package, which contains important network utilities, including ifconfig. To install this package, execute the following command:

sudo yum install net-tools

This action will grant you access to basic tools for setting up and diagnosing the network. Read more about diagnosing Linux resources.

Next, you need to proceed with configuring the network interfaces. Configuration files for network interfaces are located in the /etc/sysconfig/network-scripts directory. The primary file for editing is ifcfg-eth0 (or another interface depending on your configuration). In this file, you can set parameters such as the IP address (IPADDR), subnet mask (NETMASK), default gateway (GATEWAY), and other settings necessary for the network to function correctly.

An example of the ifcfg-eth0 file content might look as follows:

DEVICE=eth0 
BOOTPROTO=static 
ONBOOT=yes 
IPADDR=192.168.1.10 
NETMASK=255.255.255.0 
GATEWAY=192.168.1.1

If you need to configure multiple IP addresses on a single network interface, you should create additional configuration files, for example, ifcfg-eth0:0 for the first additional address, ifcfg-eth0:1 for the second, and so forth, setting the corresponding settings in them.

After making changes to the configuration files, it is necessary to restart the network service to apply the settings. This can be done with the command:

sudo systemctl restart network

Thus, configuring the network in CentOS through the console is a sequence of actions, starting from installing the necessary tools, editing the configuration files, and ending with applying the settings. By following these steps, you will be able to successfully configure the network on your CentOS server.

Previous article How to setup network in Debian OS
Next article How to read Linux logs and where to find it

Ask a question

We are always ready to answer your questions at any time of day or night.
Please, check our Knowledge base, most likely the answer to your question is already there!
svg--close svg--yes
Your message has been sent
We will definitely consider your message as soon as possible