How do you check if a remote port is open?
BeginnerConceptCommand-Line Tools & Diagnostics
Answer
nc -zv db.internal 5432 # TCP connect test
nc -zvu 10.0.0.2 53 # UDP (less reliable)
timeout 3 bash -c '</dev/tcp/db.internal/5432' && echo open
curl -sv telnet://db.internal:5432 --max-time 3
Interpret: "succeeded" means a handshake completed; "refused" means the host answered RST; a hang means filtering or no route.
More on Command-Line Tools & Diagnostics
How do you list listening ports and the processes that own them?BeginnerWhat does `ping` tell you and what does it not?BeginnerHow does traceroute work and how do you read the output?BeginnerWhat is mtr and why is it better than traceroute?IntermediateHow do you query DNS with dig and read the answer?BeginnerHow do you use curl to debug an HTTP problem?Beginner