Tuesday, June 6, 2017

Quick port connectivity testing with nc and curl/Python

Using netcat 

Quick way to test connectivity between two hosts via nc (concatenate and redirect sockets)
ncat is a feature packed network utility which reads and write data across network from the command line.

Note: hostA is server and hostB is client

hostA# nc -l 80

--> leave it running in a listening status

hostB# nc -vnz 80

OR if you are using any NAT ip address to reach to the internal network from outside world

Using curl and python.

On the server side run the

hostA# python -m SimpleHTTPServer 33101
Serving HTTP on 0.0.0.0 port 33101 ...
[06/Jun/2017 23:33:59] "GET / HTTP/1.1" 200 -

from hostB

hostb# curl -vs :33101

you will see the Rebuilt URL to the IP address of the server via specified port and connecting successfully followed by closing the connection