Troubleshooting a network connection
Working out why a connection fails, in the order that isolates the fault fastest: the interface, the gateway, the route, name resolution, then the service itself.
Lesson 3 of 4 in objective 109. Networking fundamentals, part of LPIC-1 Exam 102-500.
Work outwards
Start at the interface: ip addr shows whether it has an address at all, and one in 169.254 means DHCP never answered. Then the local network: ping the default gateway, which ip route names. Then beyond it: ping something by address, such as a public resolver, which tests routing without involving DNS. Then ping the same thing by NAME — if the address works and the name does not, the fault is resolution and nothing else, and dig, host and /etc/resolv.conf are where to look.
traceroute (or tracepath, or mtr) shows each hop and where the path stops, which distinguishes "the packets never leave" from "they leave and nothing comes back". Note that many hosts and routers deliberately do not answer ICMP, so a silent hop in the middle of an otherwise working trace is normal rather than a fault.
When the network is fine and the service is not
ss -tulpn lists what is actually listening, on which addresses, and which process owns it — a service bound only to 127.0.0.1 is invisible from anywhere else, and that is the answer to a surprising number of "the firewall must be blocking it" reports. netcat (nc -zv host port) tests reachability of one port from the client side, which separates a filtered port from a refused one: refused means something answered and nothing is listening, timed out means a firewall silently dropped it.
Once the fault is isolated, the logs say why. journalctl -u SERVICE for the service's own account of itself, and /var/log for anything not in the journal.
The two toolkits, and the names a question will hand you
Half of this objective is recognising which packet a command came out of. net-tools is the legacy set — ifconfig, route, netstat, arp and hostname — and it works by reading /proc. iproute2 is the current set — ip, ss and bridge — and it talks to the kernel over netlink, which is why it can express things the older tools cannot: several addresses on one interface without alias devices, policy routing, multiple routing tables. The pairings are explicitly examinable in both directions: ifconfig to ip addr and ip link, route to ip route, arp to ip neigh, and netstat to ss. Note that tracepath belongs to neither set, and that hostname is the one net-tools command nothing has replaced.
hostname with no options and no arguments prints the name the kernel is currently holding, read through the gethostname call. Given an argument and run as root it SETS that name, but only until the next reboot, since the persistent value is /etc/hostname and, on a systemd machine, hostnamectl. uname -n reports the same kernel value through a different tool. Its address options are the pair worth separating: hostname -i asks the resolver what the host's own name maps to, so it goes through /etc/hosts and very often answers with a loopback address the installer put there, while hostname -I reads the addresses actually assigned to the interfaces and needs no resolution at all. A provisioning script that must not depend on name resolution wants -I, or ip -o addr show when it also needs the interface and the prefix length. -f gives the fully qualified name and -s the short one.
Several of the classic diagnostics ship as an IPv4 and an IPv6 pair, with the IPv6 member carrying a 6 suffix: traceroute6, tracepath6 and ping6. Current distributions usually make these links to a dual-stack binary that picks the family from the address or from -4 and -6, but the separate names are still valid and are named in the objectives — so on an older host whose traceroute rejects -6, traceroute6 is the program to run. The IPv6 variants otherwise take the same options as their IPv4 counterparts.
Worth carrying in
- ip addr / ip route
- Does the interface have an address, and where do packets go by default.
- ping -c 4 address
- Reachability without DNS. Ping the gateway first, then beyond it.
- traceroute / mtr
- Each hop, and where the path stops.
- dig name / host name
- Ask DNS directly. +short for just the answer.
- ss -tulpn
- What is listening, on which address, owned by which process.
- nc -zv host port
- Refused means nothing is listening; timeout means something dropped it.
- hostname / hostname -I
- The running name; -I the addresses on the interfaces. -i goes through the resolver and often says 127.0.0.1.
- traceroute6 / ping6
- The separate IPv6 programs, for hosts whose IPv4 binary has no -6.
- ifconfig, route, netstat, arp
- net-tools. Replaced by
ip addr,ip route,ssandip neigh.
What the exam does with this
- Ping by address, then by name. Which one fails tells you whether the problem is routing or resolution.
- Know the net-tools to iproute2 pairings by name:
ifconfig,route,netstatandarpare the legacy four. - A service bound to 127.0.0.1 is unreachable from other hosts even with no firewall at all.
- Missing ICMP replies in a
tracerouteare common and are not proof of a fault.
- Objective
- 109. Networking fundamentals
- Share of the exam
- 23.33% (the whole objective)
- Questions in this lesson
- 20
- Signed for by a person
- 0
Partly checked. None of the 20 questions here has been read against the cited source by a person. 20 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.
Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.
How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.
Drill this lesson
A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.
Practise Troubleshooting a network connection
Questions in this lesson
- Which statement correctly describes tracepath as compared with traditional traceroute? machine-checked
- From a script you need to check whether TCP port 22 on 10.0.0.8 accepts connections, without sending or expecting any data. Which command is designed for that? machine-checked
- On a workstation, `ping 8.8.8.8` succeeds with normal round-trip times, but `ping www.example.com` fails immediately with a message that the name or service is not known. Which two causes are consistent with these symptoms? (Choose two.) machine-checked
- Before recabling a server you must administratively disable the interface eth0, leaving the device present in the kernel so it can be brought back with a single command afterwards. Which iproute2 command does that? machine-checked
- Users report intermittent packet loss on a server and you suspect a faulty cable or duplex mismatch. Which command displays the per-interface packet, error, drop and collision counters for eth0 using iproute2? machine-checked
- A traceroute across a long provider path ends with rows of asterisks and never reaches the destination, although the host is reachable by other means. You establish that the target is roughly 36 hops away. Which option makes traceroute probe far enough? machine-checked
- A server has two interfaces, eth0 on the office LAN and eth1 on a storage network. You must verify that 203.0.113.9 answers when the echo requests leave through eth1, not through whichever interface routing would normally choose. Which command does that? machine-checked
- A provisioning script must record the non-loopback IP addresses currently configured on the machine's interfaces, and it must not depend on name resolution or on /etc/hosts. Which hostname invocation is appropriate? machine-checked
- A monitoring script calls ping and must never block: it should send exactly four echo requests to 192.0.2.10 and then exit. Which option enforces that? machine-checked
- A host has several routes and two interfaces, and you need to know which route, gateway and source address the kernel would actually select for traffic to 198.51.100.25 without sending any packets to it. Which command answers exactly that? machine-checked
- To move a file between two hosts on an isolated lab network with no SSH or FTP available, you decide to use netcat. On the receiving host, which command makes netcat wait for an inbound TCP connection on port 4242 and write whatever arrives into incoming.tar? machine-checked
- A host's routing table holds exactly these four entries: `default via 192.0.2.1 dev eth0`, `10.0.0.0/8 via 192.0.2.20 dev eth0`, `10.4.0.0/16 via 192.0.2.30 dev eth0` and `10.4.7.0/24 dev eth1 scope link`. How does the kernel forward a packet addressed to 10.4.7.9? machine-checked
- From the host 192.168.1.10, pinging a printer at 192.168.1.60 on the same /24 produces repeated lines reading `From 192.168.1.10 icmp_seq=1 Destination Host Unreachable`. What does this most directly indicate? machine-checked
- A switch advertises the IPv6 link-local address fe80::2e0:81ff:fe12:3456. Running `ping fe80::2e0:81ff:fe12:3456` on a host with several interfaces fails immediately with `connect: Invalid argument`. What is the correct fix? machine-checked
- A traceroute crawls along, pausing for several seconds at each hop before the line appears, and the site's DNS servers are known to be slow. Which option makes traceroute print addresses only and skip the delay? machine-checked
- Which THREE of these commands belong to the legacy net-tools package and have been superseded by iproute2 utilities on modern distributions? (Choose three.) machine-checked
- A border firewall discards the UDP datagrams that Linux traceroute sends by default, so every hop beyond it is shown as asterisks. Which TWO options make traceroute send its probes with a protocol other than UDP? (Choose two.) machine-checked
- Type the command, with no options and no arguments, that prints the system's currently configured host name to standard output. machine-checked
- An interface has accumulated several stale addresses from repeated manual configuration. Type the complete iproute2 command that removes every address currently assigned to eth0 in one step, while leaving the device itself up. machine-checked
- On an older system whose traceroute binary rejects a -6 flag, the IPv6 counterpart of traceroute itself is installed as a separate program under its own name. Type that command name only, with no options or arguments. machine-checked
Practise Troubleshooting a network connection
The rest of objective 109
- Internet protocol fundamentals
- Persistent network configuration
- Troubleshooting a network connection — you are here
- Client side DNS