Network Configuration
Configure network interfaces, manage IP addresses, and troubleshoot connectivity.
Network Commands
Networking issues are among the most common production incidents. The fastest way to debug is to follow a consistent checklist: link β IP β route β DNS β ports β firewall.
$ ip addr # Show IP addresses
$ ip route # Show routing table
$ ip link # Interface state (UP/DOWN)
$ ss -tuln # Show listening ports
$ ping google.com
$ traceroute google.com
$ dig google.com # DNS lookup
$ ip route # Show routing table
$ ip link # Interface state (UP/DOWN)
$ ss -tuln # Show listening ports
$ ping google.com
$ traceroute google.com
$ dig google.com # DNS lookup
Quick Connectivity Tests
# Is DNS the problem?
$ ping -c 1 8.8.8.8
$ ping -c 1 google.com
# Can we reach a port?
$ nc -vz example.com 443
$ curl -I https://example.com
# What is listening locally?
$ ss -tulpn | head
$ ping -c 1 8.8.8.8
$ ping -c 1 google.com
# Can we reach a port?
$ nc -vz example.com 443
$ curl -I https://example.com
# What is listening locally?
$ ss -tulpn | head
DNS on Modern Linux
DNS can involve multiple layers (systemd-resolved, NetworkManager, resolvconf). If name resolution is flaky, inspect the active resolver.
$ cat /etc/resolv.conf
$ resolvectl status | head -60 # systemd-resolved
$ dig @1.1.1.1 google.com # query a specific DNS server
$ resolvectl status | head -60 # systemd-resolved
$ dig @1.1.1.1 google.com # query a specific DNS server
Capturing Traffic (when youβre stuck)
When symptoms donβt match what you expect, capture packets. This confirms whether packets leave/arrive and what DNS/IP is actually used.
$ sudo tcpdump -i eth0 -nn port 53
$ sudo tcpdump -i any -nn host 8.8.8.8
$ sudo tcpdump -i any -nn host 8.8.8.8
Configuration Files
/etc/hosts- Local DNS entries/etc/resolv.conf- DNS servers/etc/netplan/*.yaml- Ubuntu network config/etc/sysconfig/network-scripts/- RHEL network config
Example: Netplan (Ubuntu)
Netplan config is YAML and typically applied via netplan apply. Example for a static IP:
# /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
eth0:
dhcp4: no
addresses: [\"192.0.2.10/24\"]
gateway4: \"192.0.2.1\"
nameservers:
addresses: [\"1.1.1.1\", \"8.8.8.8\"]
$ sudo netplan try
$ sudo netplan apply
network:
version: 2
ethernets:
eth0:
dhcp4: no
addresses: [\"192.0.2.10/24\"]
gateway4: \"192.0.2.1\"
nameservers:
addresses: [\"1.1.1.1\", \"8.8.8.8\"]
$ sudo netplan try
$ sudo netplan apply
β Practice (15β20 minutes)
- Run
ip addrandip route, then explain how your machine reaches the internet. - Use
digto query DNS directly (try different resolvers like 1.1.1.1 and 8.8.8.8). - Check open ports with
ss -tulpnand map each to a service/process.