When a machine “has no network”, the instinct is to fire off commands at random until one of them prints something odd. That works sometimes, but it burns time. Going bottom-up is faster: check that the interface has a link, then that it has an address and a route, then that names resolve, that the target answers, that the port is open and finally that the application responds. The moment one layer fails, you know where to dig and can ignore everything above it.
This article follows that order. It isn’t a list of sixty tools, just the ones you really reach for at each step, with the options worth knowing. Every example was tested on Debian 13 (iproute2 6.15, BIND 9.20, curl 8.14, nftables 1.1.3) inside a container. That’s why the interface is called eth0@if401 and the addresses come from Docker’s internal network; on real hardware you’ll see names like enp3s0 or wlp2s0.
Before you start: net-tools is no longer the reference
ifconfig, route, netstat and arp come from the net-tools package, which was sidelined years ago. Debian, Fedora and Arch no longer install it by default; its replacement is iproute2, which ships ip and ss. This isn’t just about being modern: ifconfig doesn’t show secondary addresses added with ip addr add, and netstat is far slower than ss on a box with tens of thousands of connections.
| net-tools (obsolete) | iproute2 | Purpose |
|---|---|---|
ifconfig |
ip addr / ip -br addr |
Show addresses |
ifconfig eth0 up |
ip link set eth0 up |
Bring an interface up |
ifconfig eth0 192.0.2.10/24 |
ip addr add 192.0.2.10/24 dev eth0 |
Add an address |
route -n / netstat -rn |
ip route |
Routing table |
route add default gw 192.0.2.1 |
ip route add default via 192.0.2.1 |
Default gateway |
arp -n |
ip neigh |
ARP / neighbour table |
netstat -tulpn |
ss -tulpn |
Listening ports |
netstat -i |
ip -s link |
Per-interface counters |
netstat -g |
ip maddr |
Multicast groups |
iwconfig |
iw |
Wi-Fi |
mii-tool |
ethtool |
Link speed and physical state |
One caveat applies to everything below: changes made with ip are temporary. They vanish on reboot, or as soon as the network manager reapplies its own configuration. There’s a section further down on which layer actually owns the config.
1. Link and interface: ip link, ethtool, iw
The first question is whether the interface is up and has carrier:
$ ip -br link show eth0
eth0@if401 UP ae:6e:e9:47:4d:59 <BROADCAST,MULTICAST,UP,LOWER_UP>
UP means the interface is enabled; LOWER_UP means there’s a physical signal (cable plugged in, Wi-Fi associated). If you see NO-CARRIER, the problem is the cable, the switch port or the access point, and there’s no point looking at routes or DNS yet. The -br (brief) flag works with most ip subcommands, and -c adds colour.
Error counters tell you a lot about a link that “works, but badly”:
$ ip -s link show eth0
11: eth0@if401: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65535 qdisc noqueue state UP mode DEFAULT group default
link/ether ae:6e:e9:47:4d:59 brd ff:ff:ff:ff:ff:ff link-netnsid 0
RX: bytes packets errors dropped missed mcast
25338239 2283 0 0 0 0
TX: bytes packets errors dropped carrier collsns
91476 1169 0 0 0 0
If errors or carrier climb between two readings, suspect a bad cable or connector; a growing dropped count usually means the machine can’t keep up with what it receives.
For the physical side of an Ethernet card there’s ethtool. ethtool eth0 shows the negotiated speed, duplex and the Link detected line; ethtool -i eth0 gives the driver and firmware; ethtool -S eth0 dumps the NIC’s own counters, which are far more detailed than ip -s link. The textbook case: a link that should run at 1000 Mb/s but has fallen back to 100 because one pair in the cable is damaged. In the test container ethtool does answer, but the interface is virtual and its numbers look nothing like a real card’s, so I’m not reproducing them here.
On Wi-Fi, the equivalent is iw. iw dev lists wireless interfaces, iw dev wlp2s0 link tells you which network you’re associated with, the signal strength (in dBm) and the bitrate, and iw dev wlp2s0 scan (as root) lists nearby networks. A container has no Wi-Fi to inspect: iw dev just replies nl80211 not found.
2. Addresses and routes: ip addr, ip route get
With a link in place, check the address and the route. ip route prints the whole table:
$ ip route
default via 172.17.0.1 dev eth0
172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.2
The command that saves the most time, though, is ip route get. It asks the kernel what it would do with a packet to a given destination: which interface, which gateway and which source address.
$ ip route get 1.1.1.1
1.1.1.1 via 172.17.0.1 dev eth0 src 172.17.0.2 uid 0
cache
With several addresses, a VPN or specific routes, reading the table by eye is easy to get wrong. ip route get doesn’t get it wrong, because it runs the same lookup real packets go through. Here’s an example with a secondary address and a manually added route:
$ ip addr add 192.0.2.10/24 dev eth0
$ ip -br addr show eth0
eth0@if401 UP 172.17.0.2/16 192.0.2.10/24
$ ip route add 198.51.100.0/24 via 172.17.0.1 dev eth0
$ ip route get 198.51.100.7
198.51.100.7 via 172.17.0.1 dev eth0 src 172.17.0.2 uid 0
cache
$ ip route get 192.0.2.99
192.0.2.99 dev eth0 src 192.0.2.10 uid 0
cache
The second destination sits on the new address’s subnet, so it goes out directly, with no gateway, and with 192.0.2.10 as the source. If a remote server only lets you in from one specific IP, this is how you find out why a connection sometimes leaves from the wrong one.
ip neigh completes the picture: if the gateway shows up as FAILED or INCOMPLETE instead of REACHABLE, the problem is on the local network, not out on the internet. For scripts, ip -j returns JSON:
$ ip -j route get 1.1.1.1
[{"dst":"1.1.1.1","gateway":"172.17.0.1","dev":"eth0","prefsrc":"172.17.0.2","flags":[],"uid":0,"cache":[]}]
3. Name resolution: getent, dig, resolvectl
A classic: ping server works, dig server says it doesn’t exist, and someone decides DNS is broken. Not necessarily. Normal applications (ping, curl, browsers, ssh) resolve names through the C library, which follows the order in /etc/nsswitch.conf. dig doesn’t: it talks straight to a DNS server and skips everything else.
$ grep hosts /etc/nsswitch.conf
hosts: files dns
$ echo "192.168.1.50 nas.internal" >> /etc/hosts
$ getent hosts nas.internal
192.168.1.50 nas.internal
$ ping -c1 -W1 nas.internal | head -1
PING nas.internal (192.168.1.50) 56(84) bytes of data.
$ dig nas.internal | grep status
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 49945
nas.internal only exists in /etc/hosts. ping finds it because files comes first; dig asks DNS and gets NXDOMAIN. The same happens with names resolved by mDNS (.local), systemd-resolved or LDAP. Rule of thumb: getent hosts answers what an application will see; dig answers what DNS says. When they disagree, that’s your clue.
dig is still the tool for querying DNS itself:
$ dig +short debian.org
151.101.194.132
151.101.2.132
151.101.130.132
151.101.66.132
$ dig +short MX debian.org
0 muffat.debian.org.
0 mitropoulos.debian.org.
0 mailly.debian.org.
$ dig @1.1.1.1 debian.org A +noall +answer
debian.org. 254 IN A 151.101.66.132
debian.org. 254 IN A 151.101.130.132
debian.org. 254 IN A 151.101.194.132
debian.org. 254 IN A 151.101.2.132
With @server you can compare your resolver’s answer with a public one; if they differ, the issue is your resolver or a stale cache. The second column is the TTL left on that cached answer, handy for knowing how long a change will take to spread. dig +trace walks the delegation down from the root servers, although on networks that block outbound port 53 it won’t get anywhere.
On Ubuntu, Fedora and anything else running systemd-resolved, /etc/resolv.conf points at 127.0.0.53, a local stub, and the real servers are set per interface. There, cat /etc/resolv.conf misleads you. What you want is resolvectl status, which lists the DNS servers for each link, and resolvectl query name, which resolves the way the system does and tells you which interface the query went out on. resolvectl flush-caches empties the cache. The test container doesn’t run systemd, so those three commands appear here without output.
4. Reachability and path: ping, tracepath, mtr
$ ping -c 4 -q 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
--- 1.1.1.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3014ms
rtt min/avg/max/mdev = 3.766/4.580/5.327/0.734 ms
Ping an IP before a hostname: that separates a DNS failure from a network one. And don’t read too much into silence, because plenty of servers and firewalls simply drop ICMP.
ping is also good for catching MTU problems, the cause of connections that open fine and then hang as soon as something large goes through (a git push, a heavy page over a VPN). -M do forbids fragmentation, and 1472 bytes of payload plus 28 bytes of IP and ICMP headers add up to exactly 1500:
$ ping -c2 -M do -s 1472 172.17.0.1
PING 172.17.0.1 (172.17.0.1) 1472(1500) bytes of data.
1480 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.031 ms
1480 bytes from 172.17.0.1: icmp_seq=2 ttl=64 time=0.060 ms
If some hop along the way has a smaller MTU, you’ll get message too long or, worse, nothing at all. Shrink the size until it gets through.
tracepath traces the route hop by hop and discovers the path MTU without needing root. mtr combines traceroute and ping continuously, and its report is what you should attach when you open a ticket with a provider:
$ mtr -n -r -c 5 -m 6 1.1.1.1
Start: 2026-11-03T08:53:12+0000
HOST: 4b530301c2dc Loss% Snt Last Avg Best Wrst StDev
1.|-- 172.17.0.1 0.0% 5 0.1 0.1 0.0 0.1 0.0
2.|-- 1.1.1.1 0.0% 5 4.8 5.7 3.6 11.6 3.3
The container only shows two hops because Docker’s virtual network hides the ones in between; on an ordinary machine you’ll see many more. When reading an mtr report, remember that loss at an intermediate hop which doesn’t carry through to the last one isn’t real loss: routers rate-limit the ICMP replies they generate. Only loss that persists all the way to the destination counts. If ICMP is filtered, mtr -T -P 443 does the same walk with TCP packets to whatever port you choose (usually as root).
5. Ports and sockets: ss, nc
The host answers but the service doesn’t. First, on the server, check that something is listening, and where:
$ ss -tulpn
Netid State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
tcp LISTEN 0 1 0.0.0.0:8080 0.0.0.0:* users:(("nc",pid=4017,fd=3))
tcp LISTEN 0 4096 *:5201 *:* users:(("iperf3",pid=4015,fd=3))
The flags are easy to remember: TCP, UDP, listening, process, numeric. The column that matters is the local address. 0.0.0.0 or * means it accepts connections on any interface; 127.0.0.1 means local only. Half of all “I can’t reach the database from outside” tickets end right here: the service is fine, it’s just bound to loopback.
ss has its own filter language, which is very handy for live connections:
$ ss -tnp state established '( dport = :443 )'
Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
30046 0 172.17.0.2:37762 151.101.134.132:443 users:(("curl",pid=4160,fd=4))
A high, sustained Recv-Q on an established connection means the application isn’t reading what arrives. ss -s prints a summary of sockets by state.
From the client side, nc -zv tests whether a port accepts connections without sending any data:
$ nc -zv 127.0.0.1 8080
Connection to 127.0.0.1 8080 port [tcp/http-alt] succeeded!
$ nc -zv -w 2 127.0.0.1 22
nc: connect to 127.0.0.1 port 22 (tcp) failed: Connection refused
Pay attention to the two kinds of failure. Connection refused comes back instantly: the host replied that nothing is listening there (or a firewall sent an explicit reject). A timed out, on the other hand, means nobody replied at all: the packet got lost on the way or a firewall silently dropped it. You’ll see exactly that in the firewall section below, with a drop rule. With UDP, nc -u isn’t reliable, because an open port that sends nothing back looks exactly like a filtered one.
6. HTTP: curl -v and -w timings
If the port opens but the site “doesn’t work”, curl -v shows the whole exchange: which IP it connected to, the TLS handshake, the certificate and the headers.
$ curl -sv -o /dev/null https://curl.se/ 2>&1 | grep -E '^\* (Connected to|SSL connection|ALPN: server)|^> (GET|Host)|^< (HTTP|server)'
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / X25519MLKEM768 / RSASSA-PSS
* ALPN: server accepted h2
* Connected to curl.se (151.101.129.91) port 443
> GET / HTTP/2
> Host: curl.se
< HTTP/2 200
< server: nginx/1.31.3
Along the way you can see that the key exchange was X25519MLKEM768, the post-quantum hybrid OpenSSL 3.5 now negotiates by default, and that the connection used HTTP/2.
When the problem is slowness, -w breaks down where the time goes:
$ curl -s -o /dev/null -w 'dns: %{time_namelookup}s\nconnect: %{time_connect}s\ntls: %{time_appconnect}s\nfirst byte: %{time_starttransfer}s\ntotal: %{time_total}s\ncode: %{http_code}\n' https://curl.se/
dns: 0.002216s
connect: 0.005842s
tls: 0.012757s
first byte: 0.017423s
total: 0.018539s
code: 200
The timings are cumulative from the start, so subtract: the TCP connection took about 3.6 ms, TLS about 6.9 ms, and the server needed around 4.7 ms after the handshake to start answering. If dns runs into seconds, resolution is the culprit; if the big jump is between tls and first byte, it’s the server-side application, not the network.
Two more options you’ll use daily: curl -sI fetches headers only (via a HEAD request, which some servers handle differently from GET), and --resolve name:443:IP pins the target IP without touching /etc/hosts. That’s perfect for testing a new server before switching DNS, or for hitting one specific backend behind a load balancer. If you run web servers, being able to read this output also helps make sense of bugs like the HTTP/2 Bomb.
7. Bandwidth and per-process traffic: iperf3, nethogs, iftop
To measure real throughput between two machines, with no disks or applications in the way, iperf3 runs as a server on one end and a client on the other:
# on the server
iperf3 -s
# on the client
iperf3 -c 192.0.2.20 # client → server
iperf3 -c 192.0.2.20 -R # reverse direction
iperf3 -c 192.0.2.20 -P 4 # four parallel streams
The final summary looks like this (here, against the machine itself):
$ iperf3 -c 127.0.0.1 -t 3
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-3.00 sec 30.4 GBytes 86.9 Gbits/sec 1 sender
[ 5] 0.00-3.00 sec 30.4 GBytes 86.9 Gbits/sec receiver
Those 86.9 Gbit/s measure memory, not a network: that’s the loopback interface. Between two machines the figure should approach the link speed; if it falls well short, look at the Retr column (TCP retransmissions). Remember to open port 5201 on the server’s firewall, and close it again when you’re done.
When the network is saturated and you don’t know who’s saturating it, nethogs groups traffic by process and iftop by connection. Both are interactive and need root. nethogs has a text mode that’s useful for logging:
$ nethogs -t -c 3 eth0
Refreshing:
curl/4148/0 0.601562 40.4096
unknown TCP/0/0 0 0
Refreshing:
curl/4148/0 0.808789 94.3975
unknown TCP/0/0 0 0
Each line is program/PID/UID, KB/s sent and KB/s received. iftop -n -i eth0 shows, live, the address pairs moving the most traffic, without resolving names.
8. Packet capture: tcpdump
When none of that is enough, it’s time to look at the packets. tcpdump captures what crosses an interface and filters with BPF syntax. A handful of filters covers most cases:
tcpdump -ni eth0 port 53 # DNS queries
tcpdump -ni eth0 host 192.0.2.20 and port 443 # traffic with one server
tcpdump -ni eth0 'tcp[tcpflags] & tcp-syn != 0' # connection attempts only
tcpdump -ni any icmp # ICMP on every interface
tcpdump -ni eth0 -w capture.pcap port 80 # save for Wireshark
tcpdump -nr capture.pcap # read a saved capture
-n skips name resolution (otherwise tcpdump generates DNS traffic of its own and slows down) and -c N stops after N packets. Here’s a captured DNS query:
$ tcpdump -ni eth0 -c 2 'udp port 53'
08:54:26.447875 IP 172.17.0.2.48727 > 192.168.65.7.53: 18094+ [1au] A? debian.org. (51)
08:54:26.449554 IP 192.168.65.7.53 > 172.17.0.2.48727: 18094 4/0/0 A 151.101.194.132, A 151.101.2.132, A 151.101.130.132, A 151.101.66.132 (132)
And the start of an HTTP connection, with the three-way TCP handshake followed by the request:
$ tcpdump -nqi eth0 -c 4 'tcp port 80'
08:54:24.430949 IP 172.17.0.2.56248 > 172.66.147.243.80: tcp 0
08:54:24.484298 IP 172.66.147.243.80 > 172.17.0.2.56248: tcp 0
08:54:24.484315 IP 172.17.0.2.56248 > 172.66.147.243.80: tcp 0
08:54:24.484375 IP 172.17.0.2.56248 > 172.66.147.243.80: tcp 75
-q keeps the output short; without it you’d see each packet’s flags (S, S., .). If you send a SYN and nothing comes back, the problem lies between the two hosts. If an R (reset) comes back, the server is there but refusing the connection. For more comfortable analysis, save with -w and open the .pcap in Wireshark on your own machine.
9. Firewall: nft list ruleset
The last usual suspect. On Debian 13, Ubuntu, Fedora and RHEL, packet filtering is done by nftables, and the command that shows everything is:
nft list ruleset
Run it and you’ll also see the rules created by firewalld, ufw or Docker, which are all layers on top of the same engine. A minimal example: one table, one chain hooked into input and a rule that drops port 8080.
$ nft add table inet myfilter
$ nft add chain inet myfilter inbound '{ type filter hook input priority 0; policy accept; }'
$ nft add rule inet myfilter inbound tcp dport 8080 drop
$ nft list ruleset
table inet myfilter {
chain inbound {
type filter hook input priority filter; policy accept;
tcp dport 8080 drop
}
}
$ nc -zv -w 2 172.17.0.2 8080
nc: connect to 172.17.0.2 port 8080 (tcp) timed out: Operation now in progress
There’s the timed out mentioned earlier: a process is listening on the port, but drop throws the packet away without a word. With reject, the client would get an immediate refusal instead. nft -a list ruleset adds each rule’s handle number, which is what you need to delete a single rule with nft delete rule. For a sense of how delicate this part of the kernel is, the CVE-2026-23111 bug in nf_tables is a good example.
What about iptables? It’s still around, but on almost every current distribution it’s iptables-nft, a compatibility layer that translates into nftables:
$ iptables -V
iptables v1.8.11 (nf_tables)
$ iptables -A INPUT -p tcp --dport 2222 -j DROP
$ nft list ruleset
table ip filter {
chain INPUT {
type filter hook input priority filter; policy accept;
tcp dport 2222 counter packets 0 bytes 0 drop
}
}
The rule looks the same from either side. What you shouldn’t do is edit the same tables with both tools at once, because each expects to find its own format. That’s exactly what Docker does with its NAT rules, and it’s why an nft flush ruleset sometimes leaves containers without a network.
Who owns the configuration
Everything above is for diagnosis and live testing. Persistent configuration is handled by another layer, which depends on the distribution:
- NetworkManager, driven by
nmcli, on desktops and on Fedora and RHEL servers.nmcli device statusshows which interfaces it manages andnmcli connection showlists the profiles. - systemd-networkd, with
.networkfiles in/etc/systemd/network/andnetworkctl statusto query it. Common on minimal servers, containers and VMs. - netplan on Ubuntu: YAML in
/etc/netplan/that gets rendered for NetworkManager or systemd-networkd.netplan tryapplies a change and rolls it back unless you confirm it, a safety net well worth using when you’re working over SSH. - ifupdown, with
/etc/network/interfaces, is still found on plenty of Debian server installs.
If you change something with ip and it reverts a little later, it’s almost always one of these managers reapplying its config. Before touching anything on a server, find out which one is in charge. That’s part of why Linux dominates servers: everything can be inspected and automated from a terminal, as long as you know which piece is in control.
The cheat sheet
ip -br link # is there a link?
ip -s link show eth0 # errors and drops
ip -br addr # is there an address?
ip route get 1.1.1.1 # which way would it go out?
ip neigh # does the gateway answer?
getent hosts example.com # what an application sees
dig +short example.com # what DNS says
resolvectl status # per-interface DNS (systemd-resolved)
ping -c4 1.1.1.1 # reachability, without DNS
mtr -rn example.com # path and loss
ss -tulpn # what's listening, and where
nc -zv host 443 # does the port open?
curl -sv -o /dev/null https://... # HTTP and TLS exchange
iperf3 -c host # real throughput
tcpdump -ni eth0 port 443 # the packets themselves
nft list ruleset # the firewall
How we tested this
Everything ran as root in a Docker container from the debian:13 image (Debian 13.7) on the default bridge network, using Debian’s packages: iproute2 6.15, BIND 9.20 (dig), curl 8.14 with OpenSSL 3.5, and nftables 1.1.3. Adding addresses and routes with ip, or loading rules with nft, needs the NET_ADMIN capability; without it, ip addr add answers Operation not permitted. What couldn’t be tested in the container, and so appears without output, is anything that depends on hardware or systemd: ethtool on a real NIC, iw and resolvectl. The getent versus dig screenshot comes from a repeat run on 3 November in a fresh container.
To reproduce it:
docker run --rm -it --name lab-red --cap-add NET_ADMIN debian:13 bash
apt-get update && apt-get install -y iproute2 iputils-ping iputils-tracepath \
bind9-dnsutils mtr-tiny netcat-openbsd curl iperf3 tcpdump nftables ethtool
Make route, address and firewall changes in a container or a VM: on a remote server, one wrong rule locks you out.
Sources: the manual pages for ip(8), ip-route(8), ss(8), tracepath(8), ping(8), nsswitch.conf(5), resolvectl(1), ethtool(8) and tcpdump(8); the iproute2 repository; the nftables wiki and its page on iptables-nft; curl’s --write-out documentation; the iperf3 documentation; and the netplan reference.
