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?
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
Correct nc -l 4242 > incoming.tar
Correct. -l puts netcat into listen mode on the given port; it accepts an inbound connection and copies everything received on it to standard output, which the shell redirects into the file.
Not correct nc 198.51.100.7 4242 > incoming.tar
Wrong. Without -l netcat is a client: it connects out to 198.51.100.7 on port 4242 rather than waiting for anyone. That is the command for the sending side's peer, not the receiver.
Not correct nc -z -l 4242 > incoming.tar
Wrong. -z is scan mode: netcat reports whether a port is open and sends no data. Combining it with listening defeats the transfer, since no payload is ever relayed.
Not correct nc -u -l 4242 > incoming.tar
Wrong transport. -u switches netcat to UDP, which has no connection and no retransmission, so a file sent this way arrives incomplete or reordered whenever a datagram is lost.
Why
netcat is symmetric: the listener is started with -l and a port, and the client is given a host and a port, with data piped in either direction through standard input and standard output. The sender's half of this transfer is `nc HOST 4242 < outgoing.tar`, and the listener exits once the peer closes the connection. Some builds derived from the original Hobbit netcat require the port to be given as `-l -p 4242`; the OpenBSD netcat shipped by most distributions takes the port as a bare argument.
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.
More questions on this objective
- A subnet is defined as 192.168.10.0/26. How many addresses in it can actually be assigned to hosts? machine-checked
- A host is configured with the address 172.20.35.77/20. What is the network address of its subnet? machine-checked
- In IPv6, which address is the loopback address, equivalent in role to 127.0.0.1 in IPv4? machine-checked
- Which is the correct fully compressed form of the IPv6 address 2001:0db8:0000:0000:0000:ff00:0042:8329? machine-checked
- Which pairing of a service with its default port number is correct? machine-checked
- DNS normally uses UDP port 53. In which situation does a DNS client or server fall back to TCP on port 53? machine-checked