Tuesday 5 October 2010

To test if a port is open on linux

Well I wanted to test if a linux box is ready to receive syslog log files remotely and used netcat / ccat / nc for the purpose.

It is a server/client application whereby you run the server in listen mode and then start the client on a different host and connect to the server, it can create both tcp and udp connections.

I had some trouble with the syntax on Ubuntu 10.04 Lucid Lynx and hence will post the commands that worked for me:

Server:

user@server:~$ sudo nc -l -u 514


-l : is for listen
-u : is for udp

Client:

user@client:~$ nc 192.168.0.1 -u 514


where 192.168.0.1 is the ip of the server
If it connects you can then type anything in the client and it will display in the server window confirming the port is available and no firewall is blocking teh traffic, hence you can move to the application layer.

No comments:

Post a Comment