Centos 7 Network Config Files

admin14 April 2024Last Update :

Understanding CentOS 7 Network Configuration

CentOS 7, a popular server operating system, relies on a set of configuration files to manage network settings. These files are critical for system administrators who need to ensure that network interfaces are correctly configured to communicate within networks and across the internet.

Location of Network Configuration Files

In CentOS 7, network configuration files are primarily located in the /etc/sysconfig/network-scripts/ directory. Each network interface has its own configuration file named ifcfg-interface_name, where interface_name corresponds to the specific network interface, such as eth0 or ens33.

Main Configuration Files Explained

The primary network configuration files include:

  • ifcfg-*: Contains individual interface configurations.
  • network: Global network settings.
  • resolv.conf: Resolver configurations including DNS servers.
  • route-*: Static route configurations for specific interfaces.

Anatomy of an Interface Configuration File (ifcfg)

A typical ifcfg file contains directives that define how an interface should behave. Key directives include:

  • DEVICE: The name of the physical or virtual network interface.
  • BOOTPROTO: The boot protocol used, such as dhcp or static.
  • ONBOOT: Whether the interface is activated at boot time.
  • IPADDR: The IP address assigned to the interface when using static IP.
  • NETMASK: The network mask associated with the IP address.
  • GATEWAY: The default gateway for the interface.
  • DNS1 and DNS2: Primary and secondary DNS servers.
  • UUID: A unique identifier for the network interface.
  • TYPE: The type of connection, often Ethernet.

Configuring Static IP Addresses

To configure a static IP address, you would edit the ifcfg file with parameters like the following example:


Managing Network Services

Network services in CentOS 7 are managed by the NetworkManager service and the traditional network service. Commands such as systemctl start, stop, restart, and enable are used to control these services.

Using nmcli for Network Management

The nmcli command-line tool provides a powerful interface for managing NetworkManager. It allows administrators to view, enable, disable, and edit network connections and interfaces directly from the terminal.

Advanced Network Configuration

For more complex networking setups, additional files and directives may be used:

  • BONDING_OPTS: Options for configuring network bonding.
  • BRIDGE: Parameters for setting up a network bridge.
  • TEAMING: Configuration options for network teaming.

Network Scripts Utilities

CentOS 7 includes utilities such as ifup and ifdown to bring network interfaces up or down, respectively. These scripts read the ifcfg configuration files to apply the specified settings.

Troubleshooting Network Issues

Common tools for troubleshooting network issues in CentOS 7 include ping, netstat, traceroute, and ip. Log files, such as /var/log/messages, can also provide valuable information regarding network-related events.

Securing Network Configuration Files

Security best practices dictate that access to network configuration files should be restricted. Permissions should be set so that only root or users with sudo privileges can modify these critical files.

Case Studies and Examples

Case Study: Setting Up a Web Server with a Static IP

Imagine setting up a CentOS 7 web server that requires a static IP address for reliable DNS resolution. The administrator would edit the ifcfg file corresponding to the server’s main network interface, specifying the desired IP address, netmask, gateway, and DNS servers as shown in the previous static IP configuration example.

Example: Configuring Network Teaming

Network teaming involves combining multiple network interfaces for redundancy or increased throughput. CentOS 7 supports this through special configuration directives in the ifcfg files and separate teaming configuration files.

Frequently Asked Questions

How do I restart network services after changing configuration files?

Use the systemctl command to restart the NetworkManager or network service:

sudo systemctl restart NetworkManager


sudo systemctl restart network

Can I use both NetworkManager and traditional network service?

It’s recommended to use one or the other to avoid conflicts. NetworkManager is generally preferred for desktops and laptops, while the traditional network service may be better suited for servers.

What is the difference between ‘ifup’ and ‘nmcli’?

‘ifup’ is a script that reads the ifcfg files to bring an interface up, while ‘nmcli’ is a command-line client for NetworkManager that can perform a wider range of tasks, including bringing interfaces up or down.

How do I assign multiple IP addresses to a single interface?

You can create alias interfaces within the ifcfg file or create separate ifcfg files for each additional IP address, incrementing the interface name (e.g., eth0:0, eth0:1).

Network-related logs can typically be found in /var/log/messages. You can use commands like grep to filter for specific entries related to networking.


For further reading and external resources, consider the following:

Leave a Comment

Your email address will not be published. Required fields are marked *

Comments Rules :

Breaking News