Linux Networking Commands: A Practical Guide for Support Engineers

·

·

Reading time:

8 minutes

“The app can’t connect” is one of the most common tickets in production support. The fix is usually quick once you know which layer is broken. This guide groups the essential Linux networking commands by the question they answer, and starts with a simple ladder for working through any connectivity problem.

Originally published March 2021, rewritten November 2026.

Jump to

The troubleshooting ladder

Work from the bottom up. Each step rules out a layer, so you stop guessing and can tell the network team exactly where it fails.

StepQuestionCommand
1Does this host have the right IP and a route?ip -br a, ip route get 10.20.30.40
2Does the name resolve to the right address?dig +short dbhost, getent hosts dbhost
3Can I reach the host at all?ping -c 3 dbhost, traceroute dbhost
4Is the port open from here?nc -zv dbhost 1521
5Is the service listening on the server?ss -ltnp | grep 1521 (on the server)
6Does TLS / the application handshake work?openssl s_client, curl -v
7What is actually on the wire?tcpdump

A tip: ping failing doesn’t prove a host is down. Many corporate networks block ICMP, so always test the real port with nc before escalating.

Old commands vs. new

The net-tools package (ifconfig, netstat, route) is deprecated and often missing on newer servers. Know both: older bank estates still run them.

TaskLegacyModern
Show IP addressesifconfigip a
Show routing tableroute -n / netstat -rip route
Listening portsnetstat -tulnpss -tulnp
Interface statisticsnetstat -iip -s link
ARP / neighbour tablearp -nip neigh
DNS lookupnslookupdig
Test a porttelnet host portnc -zv host port

1. Interfaces, addresses and routes

ip (from the iproute2 package) replaces ifconfig and route. The pattern is ip [object] [action], where the object is link, addr, route or neigh.

ip -br link                      # interfaces and whether they're UP, one line each
ip -br a                         # interfaces and their IPs, one line each
ip addr show dev eth0            # full details for one interface
ip -s link show eth0             # packet, error and drop counters
ip route                         # routing table
ip route get 10.20.30.40         # which interface and gateway this host would use
ip neigh                         # ARP table: IP to MAC mappings
ifconfig -a                      # legacy equivalent of ip a

Example output of ip -br a:

lo      UNKNOWN  127.0.0.1/8
eth0    UP       10.20.1.15/24
eth1    UP       192.168.50.15/24

Rising errors or dropped counters in ip -s link point to a NIC, cable or switch problem rather than the application.

2. Is it reachable?

ping -c 3 dbhost                 # 3 ICMP echo requests, then stop
ping -c 100 -i 0.2 -q dbhost     # quick packet-loss test, summary only
traceroute dbhost                # each hop on the path (UDP by default)
traceroute -T -p 443 api.internal
                                 # trace over TCP to a real port (gets past ICMP blocks)
mtr -rw -c 50 dbhost             # traceroute + ping combined, report mode

Reading the results:

  • Gaps in icmp_seq in ping output mean lost packets.
  • A * on one hop in traceroute is usually a router deprioritising replies, not a fault.
  • Every hop * after a point suggests a firewall or a down link at that hop.
  • Latency jumping at one hop and staying high afterwards points to congestion at that hop.

3. DNS

dig api.internal                 # full answer, TTL, which server replied
dig +short api.internal          # just the IP(s)
dig -x 10.20.30.40               # reverse lookup: IP to name
dig @10.0.0.53 api.internal      # ask a specific DNS server
dig api.internal +trace          # follow resolution from the root down
nslookup api.internal            # legacy, still common on Windows and older boxes
getent hosts api.internal        # resolve the way applications do, incl. /etc/hosts
cat /etc/resolv.conf             # which DNS servers this host uses

dig queries DNS directly, but applications use the system resolver, which checks /etc/hosts first. If dig and getent disagree, look for a stale entry in /etc/hosts. It’s a classic cause of “it works from my box but not from the server”.

4. Ports and connections

From the client: can I reach the port?

nc -zv dbhost 1521               # "succeeded" = open; "refused" = nothing listening;
                                 # timeout = firewall dropping traffic
nc -zv -w 3 dbhost 8000-8010     # check a range of ports with a 3-second timeout
telnet dbhost 1521               # legacy check; Ctrl+] then "quit" to exit
curl -v telnet://dbhost:1521     # works where nc and telnet aren't installed

On the server: what’s listening and who’s connected?

ss -ltnp                         # listening TCP ports and the owning process
ss -lunp                         # listening UDP ports
ss -tanp                         # all TCP connections with state
ss -tn state established '( dport = :1521 )'
                                 # established connections to the database
ss -tn state time-wait | wc -l   # TIME_WAIT build-up (connection churn)
ss -s                            # summary counts by state
netstat -tulnp                   # legacy equivalent of ss -tulnp
lsof -i :8443                    # which process has port 8443

Example ss -ltnp output:

State   Recv-Q  Send-Q  Local Address:Port  Peer Address:Port  Process
LISTEN  0       128     0.0.0.0:22          0.0.0.0:*          users:(("sshd",pid=912))
LISTEN  0       100     0.0.0.0:9876        0.0.0.0:*          users:(("java",pid=4321))

A service listening on 127.0.0.1 instead of 0.0.0.0 only accepts local connections, a common misconfiguration after a deployment. A growing Recv-Q on an established connection means the application isn’t reading data fast enough.

5. Packet capture: tcpdump

When the logs disagree about who sent what, the packets settle it. Captures in production usually need approval because they can contain sensitive data, so check your firm’s policy first.

sudo tcpdump -i any -nn host 10.20.30.40
                                 # traffic to/from one host, no name lookups
sudo tcpdump -i eth0 -nn port 9876 -c 50
                                 # first 50 packets on the FIX port
sudo tcpdump -i any -nn 'tcp[tcpflags] & (tcp-rst) != 0'
                                 # only connection resets
sudo tcpdump -i any -nn port 443 -w /tmp/api.pcap
                                 # save to a file for Wireshark
sudo tcpdump -r /tmp/api.pcap -nn | head
                                 # read a saved capture

Useful flags: -nn skips DNS and port-name lookups, -c stops after N packets, -A prints payloads as text (handy for FIX and HTTP), -w writes a file.

6. Throughput: iperf3

Ping tells you a host is alive; iperf3 tells you how much bandwidth is actually available between two machines. Useful when bulk transfers such as end-of-day files or replication are slower than expected.

# on the receiving server
iperf3 -s                        # listens on port 5201

# on the sending client
iperf3 -c 10.20.30.40            # 10-second TCP test
iperf3 -c 10.20.30.40 -P 4       # 4 parallel streams
iperf3 -c 10.20.30.40 -R         # reverse direction (server sends)

7. Network discovery: nmap

nmap discovers which hosts are up and which ports they expose. Never scan without explicit permission. In a bank, an unapproved scan will trigger security alerts and possibly a disciplinary process. For checking a single port, nc is enough.

nmap -p 1521,8443 dbhost         # check specific ports on one host
nmap -sn 10.20.30.0/24           # which hosts in a subnet respond (no port scan)
nmap -sV -p 443 api.internal     # identify the service and version on a port

Port states: open (something is listening), closed (reachable, nothing listening), filtered (a firewall is dropping the probe).

8. Remote access and file transfer

SSH replaced telnet and rlogin because it encrypts everything, including passwords, and verifies the server’s identity with a host key.

ssh user@host                    # interactive login
ssh -J user@jumphost user@prodhost
                                 # connect through a jump/bastion host
ssh user@host 'df -h; uptime'    # run commands remotely without logging in
ssh -L 15210:dbhost:1521 user@jumphost
                                 # local port 15210 tunnels to dbhost:1521
ssh -v user@host                 # verbose: debug key and auth problems

scp app.log user@host:/tmp/      # copy a file to a remote host
scp -r user@host:/app/logs ./    # copy a directory back
sftp user@host                   # interactive transfer (put, get, ls, bye)
rsync -avz --dry-run src/ user@host:/dest/
                                 # preview, then run without --dry-run

If you see “REMOTE HOST IDENTIFICATION HAS CHANGED”, stop. It can mean the server was rebuilt, or that something is intercepting the connection. Confirm with the server owner before removing the old key with ssh-keygen -R host.

Interview questions

Ping fails but the application works. How?

ICMP is blocked by a firewall while the application’s TCP port is allowed. Test the real port with nc -zv instead.

What’s the difference between “connection refused” and a timeout?

Refused means the host is reachable but nothing is listening on that port (it replied with a TCP reset). A timeout means packets are being silently dropped, usually by a firewall, or the host is down.

The app can’t reach the database after a DNS change. What do you check?

Compare dig with getent hosts for a stale /etc/hosts entry, check the record’s TTL, and remember that Java applications cache DNS lookups, so they may need a restart to pick up the new address.

Why is ss preferred over netstat?

It reads socket information directly from the kernel, so it’s much faster on busy servers with thousands of connections, and it supports richer filters by state and port. netstat comes from the deprecated net-tools package.

Keep going

Rakesh Kadukutty

Senior Production Support Engineer in London with 10+ years supporting Fixed Income and FX trading systems at BNP Paribas and Tradeweb.

About LinkedIn

Get the daily brief

One fintech story every morning, with the interview angle. Free, straight to your inbox.