Mastering Configuration Settings: A Comprehensive Guide to Setup, Best Practices, and Examples

Network configuration settings are the backbone of any Linux system, defining how it communicates with other devices, accesses the internet, and manages network resources. Whether you're setting up a static IP for a server, configuring DNS resolution, or troubleshooting connectivity issues, understanding Linux network configuration is essential for system administrators, DevOps engineers, and developers.

This guide dives deep into Linux network configuration settings: what they are, where they live, how to view and modify them, and best practices to ensure your systems remain connected, secure, and easy to maintain. We cover modern tools like ip, nmcli, netplan, and systemd-networkd, as well as legacy approaches still in use today.

Table of Contents#

  1. What Are Network Configuration Settings?
  2. Viewing Current Network Settings
  3. Network Configuration Methods
  4. Configuring with ip Commands
  5. Configuring with NetworkManager (nmcli)
  6. Configuring with Netplan (Ubuntu)
  7. Configuring with systemd-networkd
  8. Legacy Configuration: /etc/network/interfaces
  9. DNS Configuration Settings
  10. Routing Configuration
  11. Advanced Settings: Bonding, Bridges, and VLANs
  12. Best Practices for Network Configuration
  13. Troubleshooting Network Settings
  14. Conclusion
  15. References

What Are Network Configuration Settings?#

Network configuration settings control how a Linux system interacts with networks. These settings include:

  • IP addresses: Unique identifiers for network interfaces (e.g., 192.168.1.10/24)
  • Default gateway: The router that forwards traffic to other networks (e.g., 192.168.1.1)
  • DNS servers: Servers that resolve domain names to IP addresses (e.g., 8.8.8.8)
  • Interface states: Whether a network interface is up or down
  • Routes: Rules that determine where network traffic is directed
  • MTU (Maximum Transmission Unit): The largest packet size allowed on the interface

Why Network Configuration Matters#

  • Connectivity: Proper settings ensure your system can reach other hosts and the internet.
  • Security: Correct firewall rules and DNS settings protect against threats.
  • Performance: Optimized MTU, routing, and bonding settings improve throughput.
  • Reliability: Redundant configurations (bonding, multiple DNS servers) prevent downtime.
  • Manageability: Consistent, documented settings simplify troubleshooting and scaling.

Viewing Current Network Settings#

Before making changes, always inspect your current configuration.

Using ip Commands#

The ip command (from the iproute2 package) is the modern standard for viewing and configuring network settings.

# List all network interfaces with IP addresses
ip addr show
ip a    # Short form
 
# Show a specific interface
ip addr show eth0
 
# Display the routing table
ip route show
ip r    # Short form
 
# Show link-layer information (MAC addresses, states)
ip link show
 
# Display interface statistics (packet counts, errors)
ip -s link show eth0

Viewing DNS Settings#

# Show DNS resolver configuration
resolvectl status
 
# View the resolv.conf file
cat /etc/resolv.conf
 
# Query a specific DNS server
dig @8.8.8.8 example.com
nslookup example.com

Checking Active Connections#

# Show listening TCP and UDP ports
ss -tuln
 
# Show established connections
ss -tun
 
# Display connection statistics
ss -s

Network Configuration Methods#

Linux distributions use different tools for network configuration. The method you use depends on your distribution and environment.

ToolPrimary UseDistributions
ip commandTemporary changes, troubleshootingAll Linux
NetworkManager (nmcli, nmtui)Desktops, laptops, RHEL/FedoraRHEL, Fedora, CentOS, Ubuntu Desktop
NetplanServer and desktop configUbuntu 17.10+, Debian 10+
systemd-networkdServers, minimal installsArch, Ubuntu Server, container hosts
/etc/network/interfacesLegacy Debian/Ubuntu configOlder Debian/Ubuntu systems
/etc/sysconfig/network-scripts/Legacy RHEL/CentOS configRHEL 7 and older

Configuring with ip Commands#

The ip command makes immediate changes that are lost on reboot. Use it for testing or temporary fixes.

Managing Interface State#

# Bring an interface up
sudo ip link set eth0 up
 
# Bring an interface down
sudo ip link set eth0 down

Assigning IP Addresses#

# Add an IP address to an interface
sudo ip addr add 192.168.1.100/24 dev eth0
 
# Add a secondary IP address
sudo ip addr add 192.168.1.101/24 dev eth0
 
# Remove an IP address
sudo ip addr del 192.168.1.100/24 dev eth0
 
# Flush all addresses from an interface
sudo ip addr flush dev eth0

Managing Routes#

# Add a default gateway
sudo ip route add default via 192.168.1.1
 
# Delete the default gateway
sudo ip route del default
 
# Add a static route to a specific network
sudo ip route add 10.0.0.0/8 via 192.168.1.254
 
# Show routes for a specific interface
ip route show dev eth0

Changing the MAC Address#

sudo ip link set eth0 down
sudo ip link set eth0 address 00:11:22:33:44:55
sudo ip link set eth0 up

Configuring with NetworkManager (nmcli)#

NetworkManager is the default network management tool on RHEL, Fedora, CentOS, and Ubuntu Desktop. The nmcli command-line tool provides full control over connections.

Viewing Connections#

# List all connections
nmcli connection show
 
# Show active connections
nmcli connection show --active
 
# List network devices and their states
nmcli device status
 
# Show detailed info about a connection
nmcli connection show "Wired connection 1"

Creating a Static IP Connection#

nmcli connection add \
    con-name "static-eth0" \
    type ethernet \
    ifname eth0 \
    ipv4.addresses "192.168.1.100/24" \
    ipv4.gateway "192.168.1.1" \
    ipv4.dns "8.8.8.8,8.8.4.4" \
    ipv4.method manual

Creating a DHCP Connection#

nmcli connection add \
    con-name "dhcp-eth0" \
    type ethernet \
    ifname eth0 \
    ipv4.method auto

Modifying Connections#

# Change the IP address
nmcli connection modify "static-eth0" ipv4.addresses "192.168.1.101/24"
 
# Add a DNS server
nmcli connection modify "static-eth0" +ipv4.dns "1.1.1.1"
 
# Remove a DNS server
nmcli connection modify "static-eth0" -ipv4.dns "8.8.4.4"
 
# Change the gateway
nmcli connection modify "static-eth0" ipv4.gateway "192.168.1.254"

Activating and Deactivating Connections#

# Bring up a connection
nmcli connection up "static-eth0"
 
# Bring down a connection
nmcli connection down "static-eth0"
 
# Restart a connection
nmcli connection down "static-eth0" && nmcli connection up "static-eth0"

Using nmtui (Text User Interface)#

For interactive configuration without memorizing commands:

nmtui

This launches a menu-driven interface where you can edit connections, activate/deactivate them, and set the system hostname.

Configuring with Netplan (Ubuntu)#

Netplan is the default network configuration tool for Ubuntu 17.10 and later. It uses YAML files in /etc/netplan/ and generates configuration for either systemd-networkd or NetworkManager backends.

Configuration File Location#

ls /etc/netplan/
# Common files: 00-installer-config.yaml, 01-netcfg.yaml

Static IP Configuration#

# /etc/netplan/01-static.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 192.168.1.100/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 8.8.4.4
        search:
          - example.com
      mtu: 1500

DHCP Configuration#

# /etc/netplan/01-dhcp.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true
      dhcp6: false
      dhcp4-overrides:
        use-dns: true
        use-routes: true
        route-metric: 100

Applying Netplan Configuration#

# Validate the YAML syntax
sudo netplan generate
 
# Test the configuration (auto-reverts after 120 seconds if not confirmed)
sudo netplan try
 
# Apply permanently
sudo netplan apply
 
# Apply with debug output
sudo netplan --debug apply

Choosing a Renderer#

  • Use renderer: networkd for servers (lightweight, no GUI dependencies).
  • Use renderer: NetworkManager for desktops (supports WiFi, VPNs).
# Check the current renderer
netplan get network.renderer

Configuring with systemd-networkd#

systemd-networkd is a system daemon that manages network configurations. It is the default on Arch Linux and suitable for servers and minimal installations on other distributions.

Configuration Files#

Configuration files are stored in three locations (processed in order):

  1. /usr/lib/systemd/network/ — system defaults
  2. /run/systemd/network/ — runtime configuration
  3. /etc/systemd/network/ — local administration (highest priority)

Files use three types:

  • .network — network configuration for matched interfaces
  • .netdev — virtual network device definitions
  • .link — link-layer configuration

Enabling systemd-networkd#

sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkd
 
# Optional: enable systemd-resolved for DNS
sudo systemctl enable systemd-resolved
sudo systemctl start systemd-resolved
 
# Link resolv.conf to systemd-resolved
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

Static IP Configuration#

# /etc/systemd/network/10-static.network
[Match]
Name=eth0
 
[Network]
Address=192.168.1.100/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4
Domains=example.com
 
[Route]
Destination=10.0.0.0/8
Gateway=192.168.1.254

DHCP Configuration#

# /etc/systemd/network/20-dhcp.network
[Match]
Name=eth*
 
[Network]
DHCP=yes
IPv6AcceptRA=yes
 
[DHCPv4]
UseDNS=yes
UseRoutes=yes
RouteMetric=100

Checking Status#

# View network device status
networkctl status
 
# View specific interface
networkctl status eth0
 
# Restart after configuration changes
sudo systemctl restart systemd-networkd

Legacy Configuration: /etc/network/interfaces#

On older Debian and Ubuntu systems (pre-17.10), network interfaces are configured in /etc/network/interfaces.

Static IP#

# /etc/network/interfaces
auto lo
iface lo inet loopback
 
auto eth0
iface eth0 inet static
    address 192.168.1.100/24
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 8.8.4.4

DHCP#

auto eth0
iface eth0 inet dhcp

Applying Changes#

# Restart networking service
sudo systemctl restart networking
 
# Or bring interfaces up/down individually
sudo ifdown eth0 && sudo ifup eth0

Migrating from ifupdown to Netplan#

If you're upgrading from an older Ubuntu system:

  1. Backup the old config: sudo cp /etc/network/interfaces /etc/network/interfaces.bak
  2. Create a Netplan YAML file in /etc/netplan/
  3. Disable the old service: sudo systemctl mask networking.service
  4. Apply Netplan: sudo netplan apply

DNS Configuration Settings#

DNS settings determine how your system resolves domain names.

Using systemd-resolved#

On systems with systemd-resolved, DNS is managed centrally:

# View current DNS settings
resolvectl status
 
# Set DNS for a specific interface
sudo resolvectl dns eth0 8.8.8.8 8.8.4.4
 
# Set a DNS search domain
sudo resolvectl domain eth0 example.com

Traditional /etc/resolv.conf#

# /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
search example.com
options timeout:2 attempts:3

Note: On systems using systemd-resolved or NetworkManager, /etc/resolv.conf is often a symlink managed automatically. Edit the upstream configuration instead.

Per-Interface DNS with Netplan#

# /etc/netplan/01-dns.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 192.168.1.100/24
      nameservers:
        addresses:
          - 1.1.1.1
          - 1.0.0.1
        search:
          - internal.example.com

Per-Interface DNS with systemd-networkd#

# /etc/systemd/network/10-static.network
[Match]
Name=eth0
 
[Network]
Address=192.168.1.100/24
DNS=1.1.1.1
DNS=1.0.0.1
Domains=internal.example.com

Routing Configuration#

Routing determines the path network traffic takes to reach its destination.

Viewing Routes#

# Show the routing table
ip route show
 
# Show routes for a specific interface
ip route show dev eth0
 
# Show routes to a specific destination
ip route get 8.8.8.8

Adding Static Routes#

# Add a route to a specific network via a gateway
sudo ip route add 10.0.0.0/8 via 192.168.1.254
 
# Add a route with a specific metric
sudo ip route add 10.0.0.0/8 via 192.168.1.254 metric 100

Persistent Routes with Netplan#

# /etc/netplan/01-routes.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 192.168.1.100/24
      routes:
        - to: default
          via: 192.168.1.1
        - to: 10.0.0.0/8
          via: 192.168.1.254
          metric: 100

Persistent Routes with systemd-networkd#

# /etc/systemd/network/10-static.network
[Match]
Name=eth0
 
[Network]
Address=192.168.1.100/24
Gateway=192.168.1.1
 
[Route]
Destination=10.0.0.0/8
Gateway=192.168.1.254
Metric=100

Advanced Settings: Bonding, Bridges, and VLANs#

Network Bonding#

Bonding combines multiple physical interfaces into a single logical interface for redundancy or increased throughput.

Common bonding modes:

ModeNameDescription
0balance-rrRound-robin load balancing
1active-backupFailover (one active, others standby)
4802.3adLACP (requires switch support)

Netplan example (active-backup):

# /etc/netplan/01-bond.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: false
    eth1:
      dhcp4: false
  bonds:
    bond0:
      interfaces:
        - eth0
        - eth1
      addresses:
        - 192.168.1.100/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8
      parameters:
        mode: active-backup
        primary: eth0
        mii-monitoring-interval: 100

Verify bonding status:

cat /proc/net/bonding/bond0

Network Bridges#

Bridges connect multiple network segments, commonly used for virtual machines and containers.

Netplan example:

# /etc/netplan/01-bridge.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: false
  bridges:
    br0:
      interfaces:
        - eth0
      addresses:
        - 192.168.1.100/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8
      parameters:
        stp: true
        forward-delay: 4

VLAN Configuration#

VLANs segment a physical network into isolated logical networks.

Netplan example:

# /etc/netplan/01-vlan.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: false
  vlans:
    vlan100:
      id: 100
      link: eth0
      addresses:
        - 10.100.0.10/24
      routes:
        - to: default
          via: 10.100.0.1
    vlan200:
      id: 200
      link: eth0
      addresses:
        - 10.200.0.10/24

Best Practices for Network Configuration#

1. Use Persistent Configuration Tools#

Avoid relying solely on ip commands for production systems. Use Netplan, NetworkManager, or systemd-networkd for settings that survive reboots.

2. Test Before Applying Remotely#

When configuring a remote server, use netplan try instead of netplan apply. The try command automatically reverts changes after 120 seconds if you lose connectivity and cannot confirm.

sudo netplan try

3. Backup Configuration Files#

Always back up existing configuration before making changes:

sudo cp /etc/netplan/01-network.yaml /etc/netplan/01-network.yaml.bak

4. Use Version Control#

Store network configuration in Git for change tracking and rollback:

cd /etc/netplan/
sudo git init
sudo git add .
sudo git commit -m "Initial network configuration"

5. Set Proper File Permissions#

Protect configuration files that contain sensitive information:

sudo chmod 600 /etc/netplan/*.yaml

6. Use Consistent Naming#

Name configuration files with numeric prefixes to control processing order:

01-ethernet.yaml
02-wifi.yaml
03-vlans.yaml

7. Document Your Configuration#

Add comments to configuration files explaining the purpose of each setting:

# /etc/netplan/01-static.yaml
# Primary ethernet interface for web server
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      # Static IP for DNS A record
      addresses:
        - 192.168.1.100/24

8. Avoid Storing Secrets in Plain Text#

For WiFi passwords or other secrets, use encrypted storage or proper secret management tools rather than plain-text YAML files.

9. Set Appropriate MTU Values#

Match MTU across the network path to avoid fragmentation:

ethernets:
  eth0:
    mtu: 1500    # Standard Ethernet
    # mtu: 9000  # Jumbo frames (requires switch support)

Troubleshooting Network Settings#

Systematic Diagnosis#

Follow this workflow when troubleshooting connectivity issues:

  1. Is the interface up?

    ip link show eth0
    # Look for "state UP"
  2. Does the interface have an IP address?

    ip addr show eth0
  3. Can you reach the gateway?

    ping -c 3 192.168.1.1
  4. Can you reach an external IP (bypassing DNS)?

    ping -c 3 8.8.8.8
  5. Is DNS resolution working?

    nslookup example.com
    dig example.com

Common Issues and Fixes#

Interface not coming up:

# Check if the network driver is loaded
lspci -k | grep -A 3 -i network
 
# Check kernel messages for errors
dmesg | grep eth0
 
# Verify the interface exists
ip link show eth0

DHCP not assigning an IP:

# Force DHCP release and renewal
sudo dhclient -r eth0
sudo dhclient eth0
 
# Check DHCP client logs
journalctl -u dhcpcd

DNS not resolving:

# Test with a specific DNS server
dig @8.8.8.8 example.com
 
# Check if resolv.conf is a symlink
ls -la /etc/resolv.conf
 
# Verify systemd-resolved is running
systemctl status systemd-resolved

Cannot reach external networks:

# Verify a default route exists
ip route | grep default
 
# Check for firewall rules blocking traffic
sudo iptables -L -n -v
sudo nft list ruleset
 
# Trace the route to a destination
traceroute 8.8.8.8
mtr 8.8.8.8

Duplicate IP address conflict:

# Check for conflicts using ARP
arping -D -I eth0 192.168.1.100

Useful Diagnostic Commands#

# Monitor network traffic on an interface
sudo tcpdump -i eth0 -n
 
# View interface error statistics
ip -s link show eth0
 
# Check for listening services
ss -tuln
 
# View NetworkManager logs
journalctl -u NetworkManager -f
 
# View systemd-networkd logs
journalctl -u systemd-networkd -f

Conclusion#

Linux network configuration has evolved significantly from the days of editing /etc/network/interfaces by hand. Modern tools like ip, nmcli, netplan, and systemd-networkd provide powerful, flexible ways to manage network settings across different distributions and environments.

Key takeaways:

  • Use ip commands for quick, temporary changes and troubleshooting.
  • Use NetworkManager (nmcli/nmtui) on desktops and RHEL-based systems.
  • Use Netplan on Ubuntu for declarative YAML-based configuration.
  • Use systemd-networkd on servers and minimal installations.
  • Always test configuration changes safely, especially on remote systems.
  • Back up and version-control your network configuration.
  • Follow a systematic approach when troubleshooting connectivity issues.

By mastering these tools and following best practices, you can confidently manage Linux network configurations in any environment—from a single workstation to a fleet of servers.

References#