On this page

This chapter covers the essential tools for checking and working with a network. Almost all of them work identically across distros.

ping — is the host reachable?

ping sends ICMP echo packets to a host and reports replies and round-trip time. It is the first tool to reach for when something is unreachable.

$ ping -c 3 1.1.1.1
64 bytes from 1.1.1.1: icmp_seq=1 ttl=57 time=8.7 ms
3 packets transmitted, 3 received, 0% packet loss

-c limits the number of pings; without it, ping runs forever (stop with Ctrl+C). You can ping a domain too:

$ ping -c 3 example.com

ip — addresses, routes, interfaces

ip is the modern replacement for the old ifconfig and route. It has subcommands for different aspects of networking.

Show your addresses (ip a for short):

$ ip addr
1: lo: <LOOPBACK,UP> ...
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,UP> ...
    inet 10.0.0.5/24 brd 10.0.0.255 ...

Show interfaces (ip link):

$ ip link
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...

Show the routing table (ip r):

$ ip route
default via 10.0.0.1 dev eth0
10.0.0.0/24 dev eth0 ...

The default via ... line is your gateway — the router that carries traffic to the internet.

curl — transfer data from URLs

curl is the Swiss Army knife of HTTP. Download a URL’s contents to the terminal:

$ curl https://example.com
<!doctype html>...

Save to a file with -o:

$ curl -o page.html https://example.com

Fetch only the response headers with -I:

$ curl -I https://example.com
HTTP/2 200
content-type: text/html

Run quietly with -s (useful in scripts):

$ curl -s -o page.html https://example.com

Graphical alternative: any web browser downloads the same content, but curl is scriptable and works on servers without a GUI.

wget — download files

wget downloads files and is better suited than curl for simple downloads of large files (it resumes partial downloads with -c).

$ wget https://example.com/file.tar.gz
$ wget -c https://example.com/file.tar.gz   # continue an interrupted download

wget is preinstalled on Ubuntu and Fedora desktops; on Arch install it with sudo pacman -S wget.

dig — DNS lookups

dig queries DNS servers and shows the records. It is part of the bind9 tools; on Ubuntu install bind9-dnsutils if missing, on Fedora it ships with bind-utils.

Short answer (just the IP addresses):

$ dig +short example.com
93.184.215.14

Full output with all record details:

$ dig example.com
;; ->>HEADER<<- opcode: QUERY, status: NOERROR ...
;example.com.            IN    A

Query a specific DNS server with @:

$ dig @1.1.1.1 +short example.com

ss — sockets and ports

ss shows network sockets — which ports are open, and what is connected. It replaces the old netstat.

Show listening TCP sockets with process names:

$ ss -lntp
State   Recv-Q Send-Q Local Address:Port  Peer Address:Port  Process
LISTEN  0      4096   127.0.0.53:53       0.0.0.0:*         users:(("systemd-resolve",...))
Flag Meaning
-l only listening sockets
-t TCP only
-u UDP only
-n numeric (no name resolution)
-p show the owning process

To see if a service is listening on port 443:

$ ss -lntp | grep :443

traceroute — where does the path break?

When ping succeeds but a site is slow or unreachable, traceroute shows the path a packet takes and how long each hop needs:

$ traceroute example.com

Hops that time out (* * *) are often firewalls dropping packets — not necessarily a problem.

nmcli — network settings from the terminal

nmcli talks to NetworkManager, the network service most desktops use. On a headless server it is the way to manage Wi-Fi and connections.

$ nmcli device status
$ nmcli device wifi list        # scan for Wi-Fi networks

Graphical alternative: the desktop network settings app (Settings → Wi-Fi / Network) does the same for a GUI user.

A note on firewalls

If you run a server, remember that your distro ships a firewall: Ubuntu ships ufw (off until enabled), Fedora ships firewalld (active by default). “My server is running but I can’t reach it from outside” is very often a firewall rule. Configuring firewalls is beyond this guide’s scope — see the firewall section of your distro’s documentation.