How to check if remote port is open?

Once upon a time I wanted to check if some ports are open. The network I wanted to check was at my office, and when I forwarded some ports on my Mikrotik I wanted to be sure if I did it correctly. So I started to find solution in the internet and I found that netcat can do it:

for localhost:

Shell

1

nc127.0.0.1123</dev/null;echo$?

for remote host:

Shell

1

nc194.204.159.1123</dev/null;echo$?

After this command you will get an answer 0 or 1.

0 means port is open

1 means port is closed

If you don’t have netcat on your Ubuntu, you can easy install it by command: