Quick Ways to test remote machine port availability

To be aware is that in nowadays, most of remote servers drop unexpected packets instead of giving a refuse response. Hence, the port is not available to you.

Also, in this article, I'm try to just use most common tools available on linux, I know there are a lot more tools available, for example nmap, netcat etc..

Telnet

Very popular tool in old days, people don't use it seriously, but should be ok for this type of test.

$ telnet yahoo.ca 80
Trying 98.139.102.145...
Connected to yahoo.ca.
Escape character is '^]'.

Curl

$ curl http://yahoo.ca:80
<!-- rc2.ops.sp1.yahoo.com uncompressed/chunked Sat Nov  9 05:16:33 UTC 2013 -->

wget

$ wget http://yahoo.ca:80
--2013-11-08 21:56:04--  http://yahoo.ca/
Resolving yahoo.ca... 68.180.206.184, 98.139.102.145
Connecting to yahoo.ca|68.180.206.184|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://ca.yahoo.com/ [following]
.... 
2013-11-08 21:56:05 (3.35 MB/s) - “index.html” saved [195921]

NC

$ nc yahoo.ca 80 </dev/null ; echo $?
<HEAD><TITLE>Invalid HTTP Request</TITLE></HEAD>
<BODY BGCOLOR="white" FGCOLOR="black">
<FONT FACE="Helvetica,Arial"><B>
 Bad request syntax</B></FONT>
<!-- default "Invalid HTTP Request" response (400) -->
</BODY>
0

$nc -t yahoo.ca 80
Connection to yahoo.ca 80 port [tcp/http] succeeded!
0 -- port available, 1 -- not available

BASH

$cat </dev/tcp/yahoo.ca/80
^C


Theory seems good, but doesn't work with the example above(yahoo drops the packet)

/dev/tcp/host/port
    If host is a valid hostname or Internet address, and port is an integer port number
    or service name, bash attempts to open a TCP connection to the corresponding socket.
/dev/udp/host/port
    If host is a valid hostname or Internet address, and port is an integer port number
    or service name, bash attempts to open a UDP connection to the corresponding socket.