Archive · Linux

Networking Basics: ip, ss, dig and Netplan

Inspect addresses, routes, ports and DNS from the command line.

1 min read

  • Ubuntu 18.04.3 LTS
  • netplan
  • iproute2 4.15
  • CentOS 7.7

ifconfig and netstat belong to the older net-tools package. Current systems use ip and ss from iproute2.

ip addr show                 # addresses per interface
ip route                     # routing table, default gateway
ss -tulpn                    # listening TCP/UDP ports and their processes
ping -c 3 8.8.8.8            # reachability
dig +short example.com       # DNS lookup (package dnsutils)
flowchart LR
  A[Application] --> B[DNS lookup]
  B --> C[Routing table]
  C --> D[Default gateway]
  D --> E[Remote host]

Ubuntu 18.04 configures networking with Netplan: files in /etc/netplan/*.yaml, applied with sudo netplan apply. CentOS 7 still uses /etc/sysconfig/network-scripts/ifcfg-* files. If a name resolves in dig but not in an application, check /etc/resolv.conf and /etc/nsswitch.conf.