Linux Network Configuration and Troubleshooting Guide

Linux network configuration has evolved significantly over the years. Modern RHEL systems use NetworkManager with the nmcli command-line tool, while older RHEL 6 systems use traditional ifconfig and network scripts. RHCA candidates must be proficient with both approaches and understand the underlying networking concepts that make troubleshooting possible.

Linux Networking Fundamentals

The OSI Model and Linux Networking

Understanding where tools operate in the network stack is essential for effective troubleshooting:

LayerNameLinux Tools/FilesProtocols
7Applicationcurl, wget, dig, nslookupHTTP, DNS, SMTP, FTP
4Transportss, netstatTCP, UDP
3Networkip route, ping, tracerouteIP, ICMP, ARP
2Data Linkip link, ethtoolEthernet, 802.11 (WiFi)
1Physicalethtool, mii-toolCables, wireless signals

Network Interface Naming

# Traditional names (still used in some systems):
# eth0, eth1       = Ethernet interfaces
# lo               = Loopback (127.0.0.1)
# wlan0            = Wireless

# Predictable Network Interface Names (RHEL 7+):
# enp3s0    = en(ethernet) p(PCI bus 3) s(slot 0)
# ens192    = en(ethernet) s(192, VMware virtual slot)
# em1       = em(embedded NIC) 1
# wlp2s0    = wl(wireless) p(PCI bus 2) s(slot 0)

# The advantage: names never change even if hardware is reordered
# Old eth0 could become eth1 after adding a NIC; enp3s0 stays enp3s0

Network Configuration Files (RHEL 6/7)

# Interface configuration:
/etc/sysconfig/network-scripts/ifcfg-eth0     # RHEL 6
/etc/sysconfig/network-scripts/ifcfg-ens192   # RHEL 7

# DNS and hostname:
/etc/resolv.conf         # DNS servers
/etc/hosts               # local hostname resolution
/etc/hostname            # system hostname

# Routing:
/etc/sysconfig/network   # default gateway, hostname (RHEL 6)

# NSS (Name Service Switch) — lookup order:
/etc/nsswitch.conf       # hosts: files dns (check /etc/hosts first, then DNS)

# Typical ifcfg file (static IP):
DEVICE=eth0              # or DEVICE=ens192
TYPE=Ethernet
BOOTPROTO=static         # static, dhcp, or none
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.11
DNS2=8.8.8.8
ONBOOT=yes               # bring up at boot
NM_CONTROLLED=yes        # managed by NetworkManager

# DHCP configuration:
BOOTPROTO=dhcp
ONBOOT=yes

NetworkManager and nmcli

NetworkManager is the modern network management daemon on RHEL 7+. It provides dynamic network management — automatically connecting to known networks, handling wired/wireless transitions, and managing VPNs.

# Check NetworkManager status:
# systemctl status NetworkManager

# nmcli — the command-line NetworkManager interface

# ── SHOWING INFORMATION ──────────────────────────────────────
# Show all connections (configured):
# nmcli con show
# nmcli con show --active            # only active

# Show device status:
# nmcli dev status
# nmcli dev show ens192              # detailed info for specific device

# Show general status:
# nmcli general status

# ── CONFIGURING STATIC IP ───────────────────────────────────
# Method 1: Modify existing connection
# nmcli con mod "System ens192" ipv4.method manual
# nmcli con mod "System ens192" ipv4.addresses "192.168.1.100/24"
# nmcli con mod "System ens192" ipv4.gateway "192.168.1.1"
# nmcli con mod "System ens192" ipv4.dns "192.168.1.11 8.8.8.8"
# nmcli con up "System ens192"       # apply changes

# Method 2: Create new connection
# nmcli con add type ethernet con-name "static-eth0" ifname ens192 \
    ip4 192.168.1.100/24 gw4 192.168.1.1
# nmcli con mod "static-eth0" ipv4.dns "192.168.1.11"
# nmcli con up "static-eth0"

# ── CONFIGURING DHCP ──────────────────────────────────────────
# nmcli con mod "System ens192" ipv4.method auto
# nmcli con up "System ens192"

# ── MANAGING CONNECTIONS ─────────────────────────────────────
# Connect/disconnect:
# nmcli con up "System ens192"
# nmcli con down "System ens192"

# Delete a connection:
# nmcli con delete "old-connection"

# Reload configuration files:
# nmcli con reload

The ip Command — Modern Network Management

# ip replaces ifconfig, route, arp — the old net-tools commands

# ── ADDRESSES ───────────────────────────────────────────────
# Show all interfaces and addresses:
# ip addr show                       # or: ip a
# ip addr show ens192                # specific interface

# Add address (temporary):
# ip addr add 192.168.1.200/24 dev ens192

# Remove address:
# ip addr del 192.168.1.200/24 dev ens192

# ── LINKS (Interface State) ─────────────────────────────────
# Show interface statistics:
# ip link show
# ip -s link show ens192             # with stats (tx/rx bytes, errors)

# Bring interface up/down:
# ip link set ens192 up
# ip link set ens192 down

# Change MAC address (temporary):
# ip link set ens192 address 00:11:22:33:44:55

# ── ROUTING ─────────────────────────────────────────────────
# Show routing table:
# ip route show                      # or: ip route, ip r
# ip route show table all            # all routing tables

# Add default route:
# ip route add default via 192.168.1.1

# Add specific route:
# ip route add 10.0.0.0/8 via 192.168.1.254
# ip route add 172.16.0.0/12 via 192.168.1.253 dev ens192

# Delete route:
# ip route del 10.0.0.0/8

# Show route for specific destination:
# ip route get 8.8.8.8              # which route would be used to reach 8.8.8.8

Network Troubleshooting — Systematic Approach

Layer-by-Layer Troubleshooting

# ── LAYER 1: Physical/Link ──────────────────────────────────
# Check if interface is up:
# ip link show ens192                # look for "state UP"
# ethtool ens192                     # check speed, duplex, link detected

# ── LAYER 3: Network (IP) ───────────────────────────────────
# Check IP address:
# ip addr show ens192

# Check routing:
# ip route show                      # default route must exist

# Test gateway:
# ping -c 3 192.168.1.1             # ping default gateway

# ── DNS RESOLUTION ──────────────────────────────────────────
# Check /etc/resolv.conf:
# cat /etc/resolv.conf

# Test DNS:
# dig google.com                     # forward lookup
# nslookup 8.8.8.8                   # reverse lookup test

# Check hosts file:
# cat /etc/hosts

# Test resolution manually:
# getent hosts server9.example.com  # uses NSS (respects /etc/nsswitch.conf)

# ── TRANSPORT/APPLICATION ───────────────────────────────────
# Test TCP connectivity:
# nc -zv server9.example.com 80     # test port 80
# telnet server9.example.com 22     # test SSH port

# Check listening services:
# ss -tulnp                         # who is listening on what port
# ss -an | grep ESTABLISHED         # active connections

Network Diagnostic Tools

# ping — test basic IP connectivity:
# ping -c 4 8.8.8.8                 # 4 pings
# ping -i 0.2 8.8.8.8               # fast ping (0.2 sec interval)
# ping6 ::1                         # IPv6 loopback

# traceroute — path discovery:
# traceroute 8.8.8.8                # show hops to destination
# traceroute -T 8.8.8.8             # TCP traceroute (bypasses UDP filtering)
# mtr 8.8.8.8                       # continuous traceroute with stats

# ss — socket statistics (modern replacement for netstat):
# ss -tulnp                         # listening sockets with process names
# ss -o state established           # established connections
# ss -s                             # socket summary statistics
# ss 'sport = :80'                  # connections on port 80

# netstat (legacy, requires net-tools package):
# netstat -tulnp                    # same as ss -tulnp
# netstat -an                       # all connections
# netstat -rn                       # routing table (like ip route)
# netstat -i                        # interface statistics

# tcpdump — packet capture:
# tcpdump -i ens192                 # all traffic on interface
# tcpdump -i ens192 port 80         # only HTTP
# tcpdump -i ens192 host 192.168.1.100  # traffic to/from IP
# tcpdump -i ens192 -w capture.pcap # save to file
# tcpdump -r capture.pcap           # read from file
# tcpdump -i ens192 -n tcp and port 80 and host 10.0.0.1  # complex filter

Network Bonding (High Availability)

# Bonding combines multiple NICs for redundancy or bandwidth aggregation

# Load bonding module:
# modprobe bonding

# Create bond interface (RHEL 7 with nmcli):
# nmcli con add type bond con-name bond0 ifname bond0 \
    bond.options "mode=active-backup,miimon=100"

# Add slave interfaces:
# nmcli con add type ethernet con-name slave1 ifname ens192 master bond0
# nmcli con add type ethernet con-name slave2 ifname ens224 master bond0

# Configure bond IP:
# nmcli con mod bond0 ipv4.method manual ipv4.addresses 192.168.1.100/24
# nmcli con mod bond0 ipv4.gateway 192.168.1.1
# nmcli con up bond0

# Check bond status:
# cat /proc/net/bonding/bond0        # detailed bond status

# RHEL 6 bonding (config file method):
# vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT=yes
BOOTPROTO=static
BONDING_OPTS="mode=1 miimon=100"    # mode 1 = active-backup

# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
MASTER=bond0
SLAVE=yes
ONBOOT=yes
BOOTPROTO=none

# Bonding modes:
# 0 = balance-rr (round-robin, load balance)
# 1 = active-backup (failover, one active at a time) — most common for HA
# 2 = balance-xor
# 4 = 802.3ad (LACP link aggregation) — requires switch support
# 6 = balance-alb (adaptive load balancing)

VLANs and Sub-interfaces

# Create VLAN interface (RHEL 7):
# nmcli con add type vlan con-name ens192.100 dev ens192 id 100 \
    ip4 10.100.0.10/24

# RHEL 6 VLAN config:
# vim /etc/sysconfig/network-scripts/ifcfg-eth0.100
DEVICE=eth0.100
VLAN=yes
BOOTPROTO=static
IPADDR=10.100.0.10
NETMASK=255.255.255.0
ONBOOT=yes

Hostname Configuration

# RHEL 7+ hostname (hostnamectl):
# hostnamectl                        # show current hostname
# hostnamectl set-hostname server9.example.com  # permanent change
# hostnamectl set-hostname server9              # short hostname

# RHEL 6 hostname:
# hostname server9.example.com       # temporary change
# vim /etc/sysconfig/network         # permanent: HOSTNAME=server9.example.com

# Always update /etc/hosts too:
# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain
192.168.1.11  server9.example.com server9