How to test the connections between Linux hosts/servers?

How to easily and quickly test the connection between two nodes on Linux? This should be specific to protocol and port.

asked Jan 19, 2013 by forum (2,150 points)
edited Jan 24, 2013 by SA

1 Answer

Best answer

We can use nc (netcat) to test the connection between two servers.

For example, to test whether TCP port 1048 can be used on the server (IP as an example) side:

On the server:

$ nc -l 1048

On the client

$ nc 1048

If it can connect to the server, type something into it. If the server can also see it, the connection has no problem.
For testing UDP connection, we can simply add the '-u' option to nc:
On server:

$ nc -u -l 1048

On client:

$ nc -u 1048

To check the ports which have programs listening to:

$ netstat -putln

More using examples of nc in "TCP/IP connection testing with nc (netcat)":

answered Jan 20, 2013 by SA (14,760 points)
edited Jan 24, 2013 by SA

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost