2.19.3.8. NetCat

NetCat (or nc) is a utility that allows you to create TCP and UDP connections. By functionality it is similar to telnet. It is available by default in Unix and macOS, and is not provided for Windows.

  1. Open terminal in macOS or Linux.
  2. Run command:
    nc -v example.com 80

    In command: example.com is site IP or address to connect to (specify without http:// or https:// at start and / at end); 80 is port to use for connection. Utility has several useful flags:

    • -v — verbose output during operation.
    • -t — enable compatibility with Telnet protocol.
    • -u — connect using UDP protocol. TCP is used by default.
  3. Wait for connection results:
    • If connection is successful, this message appears:
      Connection to example.com 80 port [tcp/http] succeeded!

      Instead of http protocol used for connection is displayed.

    • If connection fails, an error message appears:
      connect to example.com port 80 (tcp) failed: Connection refused
      The error in response may differ depending on connection termination reason.

To exit nc press Ctrl+C.

Content