Addresses: ip a
ip a
ip -br a
ip a (short for ip address) lists every interface with its IPv4 and IPv6 addresses. -br prints one short line per interface. Interface names vary, such as eth0, ens3, or enp1s0; use the name you see here in the other commands. The old ifconfig is missing on many current systems; ip replaces it.
Routes: ip r
ip r
ip route get 203.0.113.10
The line starting with default via is the gateway. ip route get shows which interface and source address the server uses to reach one destination, which helps on servers with several addresses.
Open Ports: ss
sudo ss -tulpn
The flags mean TCP, UDP, listening, process, and numeric. An address of 0.0.0.0, [::], or * means the service accepts connections from anywhere; 127.0.0.1 means local only. ss -s prints totals. To find one port's owner in detail, see the lsof command.
Reachability: ping, traceroute, and mtr
ping -c 4 example.com
traceroute example.com
mtr -rwc 100 example.com
ping tests whether a host answers and how long it takes; -c 4 stops after four packets. Some hosts do not answer ping on purpose. traceroute lists each router on the way. mtr combines both and repeats the test, so it shows where packet loss starts; -rwc 100 prints a wide report after 100 rounds of one second each. Install them if missing:
sudo apt install traceroute mtr-tiny # Debian and Ubuntu
sudo dnf install traceroute mtr # AlmaLinux and Rocky Linux
To test the path in the other direction, toward your server, use a provider's looking glass: see what is a looking glass.
DNS: dig
dig example.com
dig +short example.com A
dig example.com MX
dig -x 203.0.113.10
+short prints only the answer. -x looks up the reverse (PTR) record, which mail servers check. The resolver the server itself uses is in /etc/resolv.conf; where systemd-resolved runs, as on Ubuntu, resolvectl status shows the DNS servers actually in use. Install dig with sudo apt install bind9-dnsutils on Debian and Ubuntu or sudo dnf install bind-utils on AlmaLinux and Rocky Linux.
Services: curl
curl -I https://example.com
curl -v https://example.com -o /dev/null
-I fetches only the response headers, enough to see the status code and redirects. -v shows the connection, the TLS handshake, and the headers, which helps with certificate problems. Downloads are covered in how to download a file with curl. For a raw port test without HTTP, use nc.
Host Name and Link
hostname -I
hostname -f
sudo ethtool eth0
hostname -I lists the server's addresses on one line, and -f prints the full host name. ethtool shows link speed, duplex, and whether a cable is detected; it matters most on dedicated servers, while a virtual interface may report little. Install it with apt or dnf under the name ethtool.
Where netplan and nmcli Fit
The commands above read the network state, and changes made with ip are lost at reboot. Permanent settings live in the distribution's network tool. A wrong network change cuts off SSH: before you change anything, open the console in your provider's control panel, so you can still reach the server if the network goes down.
- Ubuntu: netplan, with YAML files in
/etc/netplan/. Apply changes withsudo netplan try, which rolls back by itself if you do not confirm within 120 seconds. - AlmaLinux and Rocky Linux: NetworkManager.
nmcli device statusandnmcli connection showlist the setup. - Debian: often
/etc/network/interfaces.
Quick Reference
| Question | Command |
|---|---|
| My addresses | ip -br a |
| My gateway | ip r |
| Open ports | ss -tulpn |
| Packet loss | mtr |
| DNS answer | dig +short |
| Web status | curl -I |