l86u1q
Last Updated: February 25, 2016
·
1.167K
· carlosescri

Check if a port is reachable inside a host

If you find yourself going crazy because some service in your server is not responding as expected you can try the NetCat tool.

In your server, stop the service if possible and use the nc command this way:

$ sudo nc -l xxx.xxx.xxx.xxx yy

where xxx.xxx.xxx.xxx is the IP your service is attached to and yy is the port number. This will create a temporal listener in that port and IP.

For example, to test the HTTP port of a server inside a LAN you can use:

$ sudo nc -l 192.168.1.34 80

This is a one-use-only command. If it receives a request in that IP address and port number then exits immediately.

To test the port, from your client host, use the same tool with this syntax:

$ nc -vc 192.168.1.34 80

If everything is ok you will get a message like this:

Connection to 192.168.1.34 80 port [tcp/http] succeeded!

If not, then you will have no response.

I hope you find it useful.