GCIH · Question #399
Computer 'remus' has traffic coming in on port 53. You want to forward the traffic to system 'romulus' on port 1234. Which command would you run on 'remus' to complete this task?
The correct answer is A. nc -l -p 53 | nc romulus 1234. Netcat can chain a listener and an outbound connection with a pipe to relay traffic from one port to another host.
Question
Computer 'remus' has traffic coming in on port 53. You want to forward the traffic to system 'romulus' on port 1234. Which command would you run on 'remus' to complete this task?
Options
- Anc -l -p 53 | nc romulus 1234
- Bnc romulus 1234 < remus 53
- Cwhile [1]; nc -l -p 53; nc romulus -p 1234; done
- Dnc -l -p remus 153 -e remus 1234
How the community answered
(55 responses)- A76% (42)
- B13% (7)
- C7% (4)
- D4% (2)
Why each option
Netcat can chain a listener and an outbound connection with a pipe to relay traffic from one port to another host.
The command `nc -l -p 53 | nc romulus 1234` starts netcat in listen mode on port 53 and pipes all received data to a second netcat instance that connects outbound to romulus on port 1234, creating a one-way traffic relay. This is the standard netcat port-forwarding idiom using POSIX pipes.
The syntax `nc romulus 1234 < remus 53` attempts to redirect a filename called 'remus' as input, which is not valid for port forwarding between hosts.
The while loop syntax is malformed - netcat invocations are not properly chained and the semicolons cause each command to run sequentially rather than piping data between them.
The flags `-p remus` and `-e remus 1234` misuse netcat options; `-p` expects a port number, not a hostname, making this command syntactically invalid.
Concept tested: Netcat port forwarding and traffic relay
Source: https://nmap.org/ncat/guide/ncat-tricks.html
Topics
Community Discussion
No community discussion yet for this question.