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
Draft — not checked yet. This question was written from the published exam objectives and cites the clause it comes from, but nobody has yet read it against that clause and signed for it.
It is kept out of search results and out of mock exams until they have. Read the source below before you take the answer as settled.
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 set from objective 109 and space the ones you get wrong.