Commands to check if a port is open on our PC / server or other remote

Sometimes we need to know if X port is open on your computer (or server) remote, then we have quite a few options or tools to use:

nmap

The first solution that many think is nmap

In case you do not wish to scan a whole, but simply want to know if X computer / server is open a particular port, it would be:

nmap {DOMAIN] -p {PORT} | grep -i tcp

Example:

nmap localhost -p 22 | grep -i tcp

Or:

nmap 127.0.0.1 -p 22 | grep -i tcp

What this does is simple, Question given IP or Host if the port is open or not, filter and then grep the line only shows they want to read, which tells them if open (open) or closed (closed) that port:

nmap1

NC

nc or netcat, is a much simpler option to see if a port is open or not:

nc -zv {DOMAIN} {PORT}

That is:

nc -zv 192.168.2.88 80

telnet

This is the version used a while ago (due to ignorance of the above), telnet turn helps us much more than just whether a port is open or not.

telnet {IP_OF_HOST} {PORT}

Here’s an example:

telnet 192.168.122.88 80

The problem with telnet is closing the connection. That is, in some cases we can not close the telnet request and we will have to close the terminal, or else make another terminal killall telnet or something similar. That’s why I avoid using telnet unless I be very necessary.

End!

Anyway, I hope you found it interesting that, if anyone knows any other way to know if a port is open or not on another computer you leave it in the comments.

Regards

Leave a Reply

%d bloggers like this: