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?

LPIC-1 Exam 102-500, objective 109. Networking fundamentals medium

Machine-checked — no person has signed for it. This question was read against the source cited below by an automated pass, which found no contradiction. That is a weaker claim than it sounds: the same kind of process wrote the question, so it can confirm its own mistake.

Treat it as a good draft rather than as settled fact, and read the source below before you rely on it. It is not used in mock exams here — only questions a person has signed for are.

How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.

The options

Not correct ping -p 22 10.0.0.8

Wrong. ping uses ICMP echo, which has no concept of ports. Its -p option supplies a pattern of pad bytes for the payload, nothing to do with port numbers.

Not correct traceroute -p 22 10.0.0.8

Wrong for this purpose. -p sets the base destination port of traceroute's probes, but the tool maps a route; it does not report whether a service accepted a connection.

Correct nc -z 10.0.0.8 22

Correct. -z puts netcat in zero-I/O scan mode: it completes the connection attempt, reports success or failure and exits without transferring data. Add -v to see the result on stderr.

Not correct ss -tn 10.0.0.8:22

Wrong. ss reports on the local machine's own socket table, and its address arguments are filters over that table. Nothing it prints tells you whether a remote host accepts a connection on port 22.

Why

`nc -zv HOST PORT` is the scriptable port check: the exit status is zero when the connection succeeded. `telnet HOST PORT` does the same interactively and is still a common quick test, but it leaves you inside a session and its exit status is less useful. Neither distinguishes a firewalled port that drops packets (the attempt hangs until it times out) from one that is refused (an immediate TCP reset) unless you watch the timing.

Where this comes from

Cited
manual page nc(1)

Practise this

Reading one question is not practice. The trainer will draw a short set from objective 109 and space the ones you get wrong.

Practise LPIC-1 Exam 102-500

More questions on this objective

All questions on Networking fundamentals

Practise LPIC-1 Exam 102-500