Port Testing Tools Overview

Jul 18, 2025

Overview

This guide explains how to test port connectivity using the netcat command on Linux/MacOS and Test-NetConnection in Windows PowerShell.

netcat (Linux/MacOS)

  • Use nc <host> <port> to attempt a TCP connection to a host and port.
  • <host> can be a domain or IP address; <port> can be a specific number or range.
  • nc -u <host> <port> opens a UDP connection for protocols using UDP.
  • nc -z <host> <port> scans for open ports without sending data.
  • nc -v <host> <port> provides verbose output for debugging and troubleshooting.
  • nc -vv <host> <port> gives even more detailed output than -v.
  • nc -p <localport> <host> <port> specifies the local source port for the connection.
  • nc -e <program> <host> <port> runs a program after a connection, not supported in all netcat versions.
  • nc -n <addr> <port> bypasses DNS lookup, using only numeric address and port.
  • Options can be combined for more complex tasks, such as nc -v -z <host> <port> to check for open ports with verbose output.

Test-NetConnection (Windows PowerShell)

  • Use Test-NetConnection <host> <port> to test connectivity to a host and port.
  • Capitalization matters for Test-NetConnection.
  • Adding -InformationLevel "Detailed" provides a detailed connectivity report.
  • Test-NetConnection -ComputerName <host> checks connectivity to a remote host.
  • Combine -Port <port> to specify the target port.
  • -DiagnoseRouting runs route diagnostics to the host, sometimes requiring admin rights.
  • -ConstrainInterface <number> restricts the test to a specific network interface.
  • Multiple options can be combined for detailed diagnostics, e.g., -InformationLevel Detailed with routing diagnostics.

Key Terms & Definitions

  • Port — A communication endpoint for connecting to services on a networked device.
  • TCP (Transmission Control Protocol) — A reliable, connection-based protocol for sending data.
  • UDP (User Datagram Protocol) — A faster, connectionless protocol used where speed is more important than reliability.
  • netcat (nc) — A command-line utility for reading or writing data across network connections.
  • Test-NetConnection — A Windows PowerShell cmdlet for testing network connectivity and diagnosing issues.
  • DNS (Domain Name System) — The service that resolves domain names to IP addresses.

Action Items / Next Steps

  • Practice using nc and Test-NetConnection with different options to test port connectivity on your systems.
  • Review which commands work for your operating system (Linux/MacOS vs. Windows).
  • Try combining options for more advanced diagnostics as described in examples.