Skip to content

Instantly share code, notes, and snippets.

@gilangvperdana
Last active June 8, 2024 16:49
Show Gist options
  • Save gilangvperdana/6e8b4e224c58f553dba370f9a06c4448 to your computer and use it in GitHub Desktop.
Save gilangvperdana/6e8b4e224c58f553dba370f9a06c4448 to your computer and use it in GitHub Desktop.
Test Port Lisen on Linux & Windows

General

If you want to test connection (port listen) to another server you can use netcat. On linux will be ncat command & on windows will be ncat command.

Linux

  • Installation
apt install -y netcat
  • Usage
#### for TCP
nc -vz localhost 80
#### for UDP
nc -vzu localhost 80

for Windows

#### for TCP
ncat -v -n localhost 80
#### for UDP
ncat -v -n -u localhost 80

Goals of Connected

C:\Users\Administrator>ncat -v -n -u 10.0.3.140 12530
Ncat: Version 7.92 ( https://nmap.org/ncat )
Ncat: Connected to 10.0.3.140:12530.

Goals of not Connected

C:\Users\Administrator>ncat -v -n 10.0.3.140 12530
Ncat: Version 7.92 ( https://nmap.org/ncat )
Ncat: No connection could be made because the target machine actively refused it. .

You will receive blank message on Linux netcat, this ussually appear on Linux with UDP not connection case.

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment