Verifying Connectivity - Testing Port Connectivity
Netcat (Linux and macOS)
- Purpose: Tests connectivity at the transport layer.
- Command:
nc - Mandatory arguments:
host: The target host.port: The target port.
- Example:
nc google.com 80 attempts to establish a connection on port 80 to google.com.- If the connection fails, the command exits.
- If the connection succeeds, a blinking cursor appears, allowing you to send application layer data.
- Flags:
-z (zero input/output mode):- Checks the status of a port without sending data.
-v (verbose):- Provides human-readable output.
- Useful for determining if a connection to the port is possible.
- Example with flags:
nc -z -v <host> <port>
Test-NetConnection (Windows)
- Purpose: Similar functionality to Netcat.
- Basic Usage:
Test-NetConnection <host>- Defaults to using ICMP echo request, similar to
ping. - Displays more data than
ping, including the data link layer protocol.
- Port Connectivity Testing:
Test-NetConnection <host> -Port <port>- Tests connectivity to a specific port.
Additional Notes
- Both Netcat and Test-NetConnection have functionalities beyond simple port connectivity tests.
- Further reading is recommended to explore their full capabilities.