$linuxjunkies
>

Linux Networking Fundamentals

Master Linux networking from the ground up: interfaces, IP addressing, gateways, DNS, and the essential tools ip, ping, and ss with distro-specific examples.

BeginnerUbuntuDebianFedoraArch9 min readUpdated June 7, 2026

Before you start

  • A running Linux system with at least one network interface
  • sudo or root access
  • iproute2 package installed (present by default on virtually all distros)

Every Linux system communicates with the world through a handful of well-defined concepts: network interfaces, IP addresses, subnet masks, default gateways, and DNS resolvers. Mastering the tools that inspect and configure these pieces gives you a reliable mental model for diagnosing almost any connectivity problem. This guide focuses on the modern ip suite, ping, and ss — the tools you will reach for every day.

Network Interfaces

A network interface is the kernel's abstraction of a network adapter — physical (Ethernet, Wi-Fi) or virtual (loopback, tunnel, bridge). Every interface has a name. On modern kernels with predictable interface naming you will see names like eno1, enp3s0, or wlan0; older-style names (eth0) still appear on some distros and virtual machines.

List all interfaces

ip link show

Each entry shows the interface index, name, flags (UP, LOWER_UP, LOOPBACK), and MAC address. The lo interface is the loopback — always 127.0.0.1 — used for inter-process communication on the same host.

Bring an interface up or down

sudo ip link set enp3s0 up
sudo ip link set enp3s0 down

This is temporary; it survives only until the next reboot or network manager event. For persistent configuration, see the section on network managers below.

IP Addressing

An IPv4 address is a 32-bit number written as four octets: 192.168.1.42. It is always paired with a subnet mask that divides the address into a network portion and a host portion. CIDR notation (/24) is the modern standard and means the first 24 bits identify the network, leaving 8 bits — 254 usable host addresses — for devices.

View assigned addresses

ip address show
# Short form:
ip addr

Typical output for one interface looks like inet 192.168.1.42/24 brd 192.168.1.255 scope global enp3s0. The inet6 lines show IPv6 addresses. A link-local IPv6 address (fe80::/10) is auto-assigned and scoped to the local segment only.

Assign an address manually (temporary)

sudo ip address add 192.168.1.50/24 dev enp3s0

Remove an address

sudo ip address del 192.168.1.50/24 dev enp3s0

Manual assignments vanish on reboot. For persistent static addressing, configure your distro's network manager (see below).

Default Gateway and Routing

The default gateway is the router your system sends traffic to when the destination is outside the local subnet. The kernel maintains a routing table that maps destination prefixes to next-hop addresses and outgoing interfaces.

View the routing table

ip route show

The line beginning with default via is your gateway. For example: default via 192.168.1.1 dev enp3s0 proto dhcp src 192.168.1.42 metric 100.

Add or change the default gateway (temporary)

sudo ip route add default via 192.168.1.1 dev enp3s0

If a default route already exists, delete it first:

sudo ip route del default

DNS Resolution

DNS translates hostnames to IP addresses. On most modern distros, systemd-resolved manages resolution; the classic fallback is /etc/resolv.conf.

Check current DNS servers

# With systemd-resolved:
resolvectl status

# Or inspect resolv.conf directly:
cat /etc/resolv.conf

Test DNS resolution

resolvectl query linux.org
# Or with the classic tool:
nslookup linux.org
# Or with dig (install bind-utils / dnsutils):
dig linux.org

Persistent DNS configuration

Where you set DNS depends on your network manager:

  • NetworkManager (Ubuntu desktop, Fedora, RHEL): Edit a connection with nmcli or nmtui, or set DNS= in the connection's /etc/NetworkManager/system-connections/ file.
  • systemd-networkd (servers, containers): Add a [Network] section with DNS= in /etc/systemd/network/*.network.
  • Netplan (Ubuntu server 18.04+): Edit /etc/netplan/*.yaml and run sudo netplan apply.

Persistent Network Configuration

Modern distros each have a preferred tool for making configuration survive reboots.

Ubuntu / Debian — Netplan

A minimal static IP Netplan file at /etc/netplan/01-netcfg.yaml:

network:
  version: 2
  ethernets:
    enp3s0:
      addresses: [192.168.1.42/24]
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses: [1.1.1.1, 8.8.8.8]
sudo netplan apply

Fedora / RHEL / Rocky — NetworkManager via nmcli

sudo nmcli con mod "Wired connection 1" \
  ipv4.addresses 192.168.1.42/24 \
  ipv4.gateway 192.168.1.1 \
  ipv4.dns "1.1.1.1 8.8.8.8" \
  ipv4.method manual
sudo nmcli con up "Wired connection 1"

Arch Linux — systemd-networkd

Create /etc/systemd/network/20-wired.network:

[Match]
Name=enp3s0

[Network]
Address=192.168.1.42/24
Gateway=192.168.1.1
DNS=1.1.1.1
sudo systemctl enable --now systemd-networkd
sudo systemctl enable --now systemd-resolved

Core Diagnostic Tools

ping — Test reachability

ping sends ICMP echo requests and measures round-trip time. It is the first tool to reach for when something is not reachable.

# Test gateway reachability:
ping -c 4 192.168.1.1

# Test external DNS and routing:
ping -c 4 8.8.8.8

# Test DNS resolution + routing:
ping -c 4 linux.org

Work outward: if the gateway responds but 8.8.8.8 does not, the problem is upstream or in routing. If 8.8.8.8 works but linux.org fails, DNS is broken.

ss — Inspect sockets and open ports

ss replaces the deprecated netstat. It queries the kernel's socket tables directly and is significantly faster on busy systems.

# All listening TCP sockets with port numbers and PID:
sudo ss -tlnp

# All listening UDP sockets:
sudo ss -ulnp

# All established TCP connections:
ss -tn state established

# Filter by port:
ss -tlnp sport = :22

Flag reference: -t TCP, -u UDP, -l listening only, -n numeric (no hostname lookup), -p show process/PID.

Verification Checklist

Run through this sequence after any change or when diagnosing connectivity:

  1. Confirm the interface is UP: ip link show
  2. Confirm a valid IP is assigned: ip addr show
  3. Confirm a default route exists: ip route show
  4. Ping the gateway: ping -c 2 <gateway>
  5. Ping a public IP: ping -c 2 1.1.1.1
  6. Test DNS: resolvectl query linux.org
  7. Check for listening services or port conflicts: sudo ss -tlnp

Troubleshooting

  • No IP address on interface: Check whether DHCP is running — systemctl status NetworkManager or systemctl status systemd-networkd. Verify the cable or Wi-Fi association.
  • Gateway unreachable but interface is UP: Confirm the gateway address is correct and within the same subnet. A wrong subnet mask will cause this.
  • 8.8.8.8 reachable but hostnames fail: DNS is the culprit. Check resolvectl status for per-interface DNS servers. A symlinked /etc/resolv.conf that points nowhere is a common trap after installing systemd-resolved without completing the setup.
  • Port not reachable from another host: Confirm the service is listening (ss -tlnp), then check firewall rules with sudo nft list ruleset, sudo firewall-cmd --list-all (Fedora/RHEL), or sudo ufw status (Ubuntu).
  • Predictable interface names missing: On some minimal installs or containers, net.ifnames=0 in the kernel command line reverts to eth0-style names. Check /proc/cmdline.
tested on:Ubuntu 24.04Fedora 40Arch 2024.05Debian 12

Frequently asked questions

What is the difference between ip addr and ifconfig?
`ifconfig` is from the deprecated net-tools package and is absent on many minimal installs. `ip addr` from the iproute2 package is the modern replacement, supports full IPv6, and is maintained upstream. Use `ip` for all new work.
Why does my /etc/resolv.conf show 127.0.0.53 instead of a real DNS server?
That is systemd-resolved's stub listener. It is correct behaviour; resolved proxies DNS queries on behalf of the system. Run `resolvectl status` to see the actual upstream DNS servers being used per interface.
How do I tell if my interface is getting a DHCP lease?
Check the proto field in `ip route show` — `proto dhcp` confirms the route came from DHCP. You can also inspect the DHCP client logs with `journalctl -u NetworkManager` or `journalctl -u systemd-networkd`.
What is the difference between ss and netstat?
`netstat` (from net-tools) is deprecated and not installed by default on modern distros. `ss` reads kernel socket state directly via netlink, making it faster and more accurate, especially on systems with thousands of connections.
Can I have multiple IP addresses on one interface?
Yes. Run `sudo ip address add <address>/<prefix> dev <iface>` multiple times. Each address is listed separately in `ip addr show`. This is common for virtual hosting, failover, and container networking.

Related guides