skip to content

Networking & firewall

Configuring and debugging a host's networking from the command line, together with the firewall that decides what reaches it. Interviewers ask because the service is up but unreachable is a daily problem, and the cause is nearly always a route, a listening socket, or a firewall rule.

on this pageshow

questions

21

A monitoring check reports a Linux server as unreachable because `ping` gets no reply, yet the HTTPS service on that same host is serving traffic normally. What does a failed ping actually prove, and how would you test reachability instead?

level: juniorimportance: must knowfreq 62%

answer

  1. ICMP is a separate protocol
  2. policy decision, not a health signal
  3. security groups deny echo by default
  4. alive host, dead application
  5. test the real port with nc or curl

basics

~20 s

A failed ping proves only that ICMP echo replies are not coming back, which is usually firewall or security-group policy rather than a dead host. Test the port the service actually listens on, using nc -zv or curl -v.

solid answer

~50 s

`ping` sends an ICMP echo request and waits for an echo reply, so it exercises the remote kernel's IP stack and nothing above it. Silence therefore has several innocent explanations: a cloud security group or firewall that never allows ICMP echo, a host with `net.ipv4.icmp_echo_ignore_all` set, or a device on the path dropping ICMP by policy. It says nothing about whether a TCP listener is healthy — and the reverse is equally true, since a host can answer ping while the application is wedged. To test what you actually care about, connect to the real port: `nc -zv api.example.com 443` for a bare TCP handshake, or `curl -v https://api.example.com/health` to walk connect, TLS and HTTP in one go. Use ping for what it is genuinely good at: sampling round-trip time and loss to a device you know replies to it.

go deeper

for a junior

Be ready to say plainly that ping only exercises ICMP echo and that many hosts and firewalls drop it, so no reply is not proof a machine is down.

for a middle

Explain what each alternative actually exercises: nc -zv completes a TCP handshake on one port, while curl -v walks connect, TLS and HTTP and prints where it stopped.

for a senior

Show judgment about monitoring design. A check that pages on ICMP loss alone generates false alarms; probe the service port and a real health endpoint, and treat ping as a latency and loss sample rather than an availability verdict.

for a principal

Own the policy tradeoff: blanket ICMP blocking inside your own network buys little and costs you traceroute and path-MTU discovery, so decide deliberately what your operators are allowed to measure.

## What ping actually measures `ping` sends an ICMP echo request to a destination address and waits for an echo reply. The reply is generated by the remote machine's kernel networking stack, not by any application. A successful ping therefore proves exactly three things: a route exists in both directions, the remote IP stack is alive enough to answer, and nothing on the path dropped either packet. It proves nothing about whether your service is listening, accepting connections, or returning correct responses. That is a much narrower guarantee than most people assume, and it is why "can you ping it?" is a weak first question during an incident. ## Why silence is usually policy, not death ICMP echo is the single most commonly filtered thing on the internet: - **Cloud security groups** default to denying it. On AWS, allowing TCP 443 does not allow ICMP; you need an explicit rule for echo requests. A brand-new instance that serves HTTPS perfectly will not answer ping. - **Corporate and edge firewalls** drop inbound echo as a reflex, on the theory that it aids scanning. - **The host itself** can refuse: `sysctl net.ipv4.icmp_echo_ignore_all=1` makes a Linux box ignore every echo request while its services keep running. - **Rate limiting** can eat replies under load; the kernel caps outgoing ICMP messages, so a heavily probed device may answer some pings and not others. So "no reply" collapses into a single honest statement: *no ICMP echo reply came back*. Everything beyond that is inference. ## The complementary trap The inverse error is just as common. A host that answers ping can still be useless: the application has crashed, the listener is bound to the wrong address, the disk is full, or the process is alive but not accepting. In front of a load balancer or an anycast address, the thing answering your ping may not even be the machine that would serve your request. Ping is a liveness signal for an IP stack, and availability is a property of a service. ## What to run instead Test the layer you care about, cheapest first: ```bash # does anything accept TCP on the real port? nc -zv api.example.com 443 # does the whole stack work: connect, TLS, HTTP? curl -v --max-time 5 https://api.example.com/health ``` `nc -zv` opens a TCP connection, reports success or failure, and closes it — no data sent. `curl -v` goes further and prints each stage on its own line, so you see which one broke: the address it chose, the connect, the TLS handshake, then the HTTP status. Add `--max-time` so a filtered port fails in seconds instead of the default connect timeout. ## Where ping still earns its place Against a device you control and know answers ICMP, ping is an excellent, low-overhead measure of loss and latency: `ping -c 100 10.0.0.5` gives you a loss percentage and min/avg/max/mdev round-trip times in one line. That is a genuinely useful number when you suspect a flaky link. It is a measurement instrument, not a health check. ## The container-and-cloud footnote On modern Linux, unprivileged `ping` uses ICMP datagram sockets, gated by `net.ipv4.ping_group_range`. Inside a container that lacks `CAP_NET_RAW` and whose group id falls outside that range, ping fails immediately with a permission error rather than a timeout. That failure looks like unreachability to a hurried reader, but the packet never left the container. Read the exact error text before concluding anything about the network. ## How to answer this in an interview State the narrow guarantee, name filtering as the likely cause, then move immediately to a port-level test and say what that test adds. The point being probed is whether you reach for evidence about the actual service rather than treating a single ICMP result as a verdict.

  • Ping succeeds against a load-balanced address. Why might that reassure you less than it appears to?
    The thing answering may not be the thing that would serve your request. A load balancer, an anycast node or an intermediate device can answer echo requests on that address while the backends behind it are unhealthy or unreachable. Only a request to the service port, ideally to a real health endpoint, exercises the same path a user's traffic takes.
  • Ping does come back — which parts of the output are worth reading?
    The loss percentage and the sequence numbers, since gaps reveal drops that an average hides; the round-trip times, where a large spread between min and max signals queueing; and duplicate replies, which usually mean a misconfigured broadcast or a loop. Run enough packets, for example `ping -c 100`, before you treat any of those figures as evidence.
  • Inside a container, ping fails instantly with a permission error rather than timing out. What is that telling you?
    That the packet never left the container. Unprivileged ping needs either CAP_NET_RAW or a group id inside net.ipv4.ping_group_range, and without them the socket cannot be created at all. It is a capability problem, not a network problem — which is why reading the exact error text matters before drawing any conclusion about reachability.

saying these in an interview costs you the question

  • No ping reply means the host is down
  • Firewalls cannot block ping, it is too low-level
  • If ping succeeds, the service must be up
  • Ping tests whether the application is responding
  • Ping connects to a port, so it proves the listener works

context

open as a page

On a Linux host you need to confirm whether anything is listening on TCP port 8080 and, if so, which process owns it. How do you do that with `ss`, what does each letter in `ss -tulpn` select, and why does the process column sometimes come back empty?

level: juniorimportance: must knowfreq 82%

basics

~20 s

Run ss -tulpn as root: t selects TCP, u UDP, l listening sockets only, p the owning process, n numeric ports. The process column is empty for sockets owned by other users unless you are root.

open as a page

In nftables, what does the `inet` family mean when you write `table inet filter`, and what does it change compared with maintaining separate iptables and ip6tables rulesets?

level: juniorimportance: must knowfreq 60%

basics

~20 s

The inet family is nftables' dual-stack address family: one table whose base chains are evaluated for both IPv4 and IPv6 packets. It replaces keeping two parallel rulesets, so each rule is written, reviewed and audited once.

open as a page

On a Linux server you run `iptables -A INPUT -p tcp --dport 443 -j ACCEPT`, but the INPUT chain already ends with a catch-all `-j DROP` rule and port 443 is still unreachable. Explain why the new rule has no effect, and what you would run instead.

level: middleimportance: must knowfreq 72%

basics

~20 s

iptables walks a chain from top to bottom and stops at the first matching rule with a terminating target, so an ACCEPT appended below an existing catch-all DROP is never reached. Insert it above that rule with -I and a position instead of appending with -A.

open as a page

A database on a Linux server is running and `ss -tlnp` shows it in LISTEN state on port 5432, yet remote clients get no connection while a client on the same host connects fine. What in the ss Local Address:Port column explains this, and how do you fix it?

level: middleimportance: must knowfreq 68%

basics

~10 s

The Local Address is almost certainly 127.0.0.1, so the socket is bound to loopback only and is unreachable from any other host. Fix it in the application's own bind configuration, not in the firewall.

open as a page

You create an nftables table, add a chain to it and add a drop rule to that chain, but the traffic is never filtered. What must an nftables chain declare before the kernel evaluates its rules, and how does a base chain differ from a regular chain?

level: middleimportance: must knowfreq 62%

basics

~20 s

Only a base chain is attached to the packet path, and it must declare type, hook and priority — optionally policy. A chain without that header is a regular chain: it runs only when another rule jumps to it, so its rules are never reached on their own.

open as a page

A request to https://api.example.com/v1/health fails from one Linux host. Walk through how you would isolate whether name resolution, the path, the TCP port, TLS, or the HTTP application is at fault, and say what each step rules out.

level: seniorimportance: must knowfreq 68%

basics

~20 s

Work outward one layer at a time: dig for the address, a path probe toward it, nc -zv for the TCP port, then curl -v to watch TLS and the HTTP response. Each step that succeeds removes a layer from suspicion, so the first failure localises the fault.

open as a page

On a Linux host, `iptables -L` takes tens of seconds before it prints anything. Why does listing rules stall like that, and what do the `-n`, `-v` and `--line-numbers` options change about the output?

level: juniorimportance: should knowfreq 48%

basics

~20 s

iptables -L reverse-resolves every address in the ruleset and turns port numbers into service names, so it stalls whenever DNS is slow or dead. Adding -n prints raw numbers, -v adds packet and byte counters plus interface columns, and --line-numbers indexes each rule.

open as a page

iptables rules you added on a Linux server work immediately but are gone after a reboot. Where do those rules actually live, how do you make them persist on a Debian/Ubuntu and on a RHEL-family host, and what is most often forgotten?

level: middleimportance: should knowfreq 58%

basics

~20 s

iptables rules live only in kernel memory, so a reboot clears them. Dump them with iptables-save and reload with iptables-restore, wired to boot by iptables-persistent on Debian/Ubuntu or iptables-services on RHEL. The IPv6 ruleset is separate and is the thing most often forgotten.

open as a page

You run `mtr` toward a server and hop 6 reports 40% loss while the final hop reports 0%. What does that intermediate loss tell you, and what pattern in an mtr or traceroute report indicates loss that is actually hurting your traffic?

level: middleimportance: should knowfreq 50%

basics

~20 s

Loss at a middle hop that does not persist to the hops after it is almost always an artifact: that router deprioritises or rate-limits the replies it generates, while still forwarding traffic fine. Real loss shows at a hop and every hop beyond it, including the destination.

open as a page

In nftables, what is a named set and what is a verdict map, and why would you use them instead of a few hundred separate rules matching addresses or ports?

level: middleimportance: should knowfreq 50%

basics

~20 s

A named set is a typed, addressable collection declared in a table and referenced as @name; a verdict map pairs keys with verdicts and is used with vmap. Both replace long rule lists with one indexed lookup, and a named set can be updated at runtime without reloading the ruleset.

open as a page

You are SSH'd into a remote Linux server that has no console access, and you are about to run `iptables -P INPUT DROP`. What is the risk, and how do you make that change without locking yourself out?

level: seniorimportance: should knowfreq 44%

basics

~20 s

The policy takes effect instantly for every packet that matches no rule, so unless rules already accept your SSH traffic, the session dies and you cannot reconnect. Put those accept rules in first, verify them with a second session, and arm an automatic rollback before changing the policy.

open as a page

A hostname resolves to an address you know is wrong. Using `dig`, how would you establish whether the bad answer is being served from a caching resolver or is what the authoritative nameservers actually publish?

level: seniorimportance: should knowfreq 45%

basics

~20 s

Compare three answers with dig: your normal resolver, a walk from the root using +trace, and a direct query to the zone's authoritative servers with @ns1.example.com. Matching answers mean the record itself is wrong; a stale answer only at the resolver, with a counting-down TTL, means cache.

open as a page

In `ss -tln` output on Linux, the Recv-Q and Send-Q columns mean something different for a row in LISTEN state than for one in ESTAB. Explain both readings, and what a persistently non-zero Recv-Q on a listening socket tells you about the service.

level: seniorimportance: should knowfreq 40%

basics

~20 s

On an ESTAB row the columns are bytes: unread received data and unacknowledged sent data. On a LISTEN row they are connection counts: Recv-Q is completed connections waiting to be accepted, Send-Q the accept-queue limit.

open as a page

How does loading an nftables ruleset with `nft -f rules.nft` differ from applying the same rules one `nft add` command at a time, and why do production nftables files usually begin with `flush ruleset`?

level: seniorimportance: should knowfreq 42%

basics

~20 s

nft -f submits the whole file as one kernel transaction: it is applied completely or not at all, so there is no window with a half-built firewall. Files start with flush ruleset because loading is additive — reload without it and every rule is duplicated.

open as a page

You have a saved iptables ruleset and need a native nftables ruleset for the same host. What does `iptables-translate` give you, and what does it not do?

level: seniorimportance: should knowfreq 40%

basics

~20 s

iptables-translate prints the nft command equivalent to an iptables command line and applies nothing; iptables-restore-translate -f converts a whole saved dump. Both are mechanical transliterations — you get a first draft to restructure, not an idiomatic nftables ruleset.

open as a page

You log into a modern minimal Linux host and find that `netstat`, `ifconfig` and `arp` are not installed. Which iproute2 commands replace each of them, and why did distributions move away from the net-tools versions?

level: juniorimportance: nice to knowfreq 45%

basics

~20 s

Use iproute2: ss replaces netstat, ip addr and ip link replace ifconfig, ip route replaces route, ip neigh replaces arp, and ip -s link replaces netstat -i. Distributions dropped net-tools because it was unmaintained and never covered modern kernel features.

open as a page

Before repointing DNS for shop.example.com at a new server, how would you use `curl` to send a genuine HTTPS request for that hostname to one chosen IP address, and why is `--resolve` better than sending the URL as an IP with a `Host` header?

level: middleimportance: nice to knowfreq 38%

basics

~20 s

Use curl --resolve shop.example.com:443:203.0.113.10 with the normal https URL. It pins the connection to that address while the URL, Host header, TLS SNI and certificate check all still use the real hostname, so the test matches what a real client will do after cutover.

open as a page

Connections to a service on a Linux host are disappearing with no reply and you suspect the local iptables rules. Using iptables itself, how do you determine which rule is responsible?

level: seniorimportance: nice to knowfreq 34%

basics

~20 s

Every iptables rule carries kernel-maintained packet and byte counters. Zero them with iptables -Z, reproduce the failure, then list with -L -n -v --line-numbers and see which rule's counters moved. Insert a rate-limited LOG rule above the suspect to capture the packets themselves.

open as a page

On a host managed by firewalld or ufw, you add your own rules with `nft add rule`. What happens to those rules, and how should hand-written nftables rules coexist with a firewall frontend?

level: seniorimportance: nice to knowfreq 33%

basics

~20 s

Rules added inside a frontend's own table are erased the next time it rebuilds them; rules in a separate table of your own survive, but then both rulesets are evaluated and a drop anywhere wins. Express the rule through the frontend, or manage the ruleset yourself — do not mix.

open as a page