Interview Prep/Networking/Command-Line Tools & Diagnostics

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.

All Networking questions Roadmap: Networking for DevOps

More on Command-Line Tools & Diagnostics