Fundamentals and Practical Configuration of Linux Networking

Introduction

In enterprise-level Linux operations, “networking” is always one of the core foundations. From IP address configuration, network interface management to checking connectivity and troubleshooting, you will inevitably encounter a large number of network-related tools. This article will systematically guide you through the network configuration methods and common commands in RHEL9, laying a solid foundation for subsequent server management.

1. Overview of Network Configuration Files

In Linux, network settings are typically managed through configuration files and the NetworkManager service. Common network configuration contents include:

  • IP Address
  • Gateway
  • DNS Server
  • Subnet Mask
  • Hostname

Different distributions may use different locations for network configuration, but RHEL/CentOS systems are usually managed uniformly by NetworkManager.

Common network configuration file directories:

Configuration Content Path Description
Network Interface Configuration <span>/etc/NetworkManager/system-connections/</span> Default network configuration file location for RHEL9 (nmconnection file)
Hostname <span>/etc/hostname</span> System hostname
Hosts Mapping <span>/etc/hosts</span> Local DNS mapping
DNS Configuration <span>/etc/resolv.conf</span> Automatically generated by NetworkManager

Note: After RHEL9, the traditional <span>/etc/sysconfig/network-scripts/</span> is no longer used by default.

2. Network Interface Names

RHEL9 uses Predictable Network Interface Names to avoid the confusion of old names like eth0, eth1, etc.

Common naming conventions:

Name Example Description
<span>ens160</span> PCI-E interface (most common on servers)
<span>enp0s3</span> Common name for virtual machines (based on bus number)
<span>wlp3s0</span> Wireless network card (wlp = wireless LAN)
<span>lo</span> Local loopback interface

To view system network interfaces:

ip link show

Or shorthand:

ip a

3. Introduction to NetworkManager

NetworkManager is the default network management service in RHEL9, responsible for unified management of:

  • Network card configuration
  • IP addresses
  • DNS
  • Routing
  • Connections such as Wi-Fi and VPN

Related commands:

Command Description
<span>nmcli</span> Command-line tool for NetworkManager
<span>nmtui</span> Graphical text tool, suitable for beginners
<span>systemctl restart NetworkManager</span> Restart the network management service

4. RHEL9 Network Configuration Files

Network configuration files in RHEL9 typically end with <span>.nmconnection</span> and are stored in:

<span>/etc/NetworkManager/system-connections/</span>

Example file: <span>ens160.nmconnection</span>

[connection]
id=ens160
type=ethernet
interface-name=ens160

[ipv4]
method=manual
address1=192.168.1.100/24,192.168.1.1
dns=8.8.8.8;

After modification, the configuration must be reloaded:

nmcli connection reload
nmcli connection up ens160

5. Common Network Commands (Ping, traceroute, netstat, ss, ip)

Below is a summary of the most commonly used network tools in daily operations.

(1) Ping — Test Network Connectivity

ping xxx.xxx.xxx.xxx
ping www.baidu.com

Common parameters:

Parameter Function
<span>-c</span> Specify count
<span>-i</span> Specify interval
<span>-W</span> Specify timeout

(2) traceroute — Route Tracing

traceroute www.google.com

Used to diagnose where delays or packet loss occur in the request.

(3) netstat — View Network Status (Gradually Replaced by ss)

netstat -tunlp

Commonly used to view listening ports:

Parameter Description
<span>-t</span> TCP
<span>-u</span> UDP
<span>-n</span> Display in numeric form
<span>-l</span> Listening state
<span>-p</span> Show process

(4) ss — Next Generation Socket Viewing Tool (Recommended)

A modern tool that replaces netstat.

ss -tulnp

To view TCP connections:

ss -tn

(5) ip — Modern Network Management Command (Replaces ifconfig)

Function Command
View IP <span>ip a</span>
View Routing <span>ip r</span>
Activate Network Card <span>ip link set ens160 up</span>
Set Temporary IP <span>ip addr add 192.168.1.10/24 dev ens160</span>

Network Configuration Practical Case: Troubleshooting Website Access Issues

Below is a practical case demonstrating the combined application of multiple network commands.

✔️ Case Objective: Server Cannot Access the Internet, Troubleshoot the Cause

Step 1: Check if the local IP is normal

ip a  # Check if the network card has an IP

Step 2: Ping the Gateway

ping -c 4 192.168.1.1  # If the gateway is unreachable, it is not an external network issue

Step 3: Check DNS

cat /etc/resolv.conf

Or:

ping www.baidu.com  # If the domain cannot be resolved, it is a DNS issue

Step 4: Check the Routing Table

ip r  # Check if the default route exists

Step 5: Check Port or Process Occupation

ss -tulnp  # Check if any application occupies port 80

Step 6: Use traceroute to check the external network path

traceroute www.baidu.com

Conclusion

This article systematically covers the fundamental knowledge of Linux network management, from network configuration files, NetworkManager, interface naming conventions, to actual network configuration files in RHEL9, and the most common network troubleshooting commands. Mastering these contents will enable you to independently complete server network configuration and basic troubleshooting tasks.

Leave a Comment