Skip to content

Checking if a port is open using /dev directory

January 24, 2013

An old but useful tip. You don’t need telnet, nc or other related tool to check if a port is open.

Lets assume you want to check if the port 22 is open at host 192.168.0.2, perform it:

# echo > /dev/tcp/192.168.0.2/22

Check the return code of the command above

# echo $?
0

If “0”, port is open, if “1” the port is closed.

That’s all.

; )

From → Linux

2 Comments
  1. galco permalink

    what command can use I check all port?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: