CompTIA Linux+ (XK0-004) — Question 207
A Linux administrator is checking connectivity between two servers in separate subnets:
Server A: 10.1.2.20 (source)
Server B: 10.2.1.10 (destination on port 8080)
The administrator tried to run the curl 10.2.1.10:8080 command on server A and received the following output: curl: (7) Failed to connect to 10.2.1.10 port 8080: Connection refused.
The administrator checked on server B and confirmed nothing is listening on port 8080.
Which of the following commands, when run on server B, would have allowed the administrator to test the connection successfully?
Answer options
- A. tcpdump 'tcp port 8080'
- B. ss -l -p dport=8080 dst 10.2.1.10
- C. nc -l -p 8080 10.2.1.10
- D. nmap -v -p 8080 10.2.1.10
Correct answer: C
Explanation
The correct answer is C because running 'nc -l -p 8080 10.2.1.10' sets up a listener on Server B for connections on port 8080, allowing the administrator to test connectivity. Options A and B do not establish a listening service; tcpdump captures packets and ss displays socket statistics, but neither will respond to connection attempts. Option D uses nmap for port scanning, which does not create a listening service either.