How to easily and quickly test the connection between two nodes on Linux? This should be specific to protocol and port.
如何在Linux上轻松快速地测试两个节点之间的连接 ? 这应该特定于协议和端口。
We can use nc (netcat) to test the connection between two servers.
我们可以使用nc(netcat)来测试两个服务器之间的连接。
For example, to test whether TCP port 1048 can be used on the server (IP 10.0.3.48 as an example) side:
例如,要测试是否可以在服务器端使用TCP端口1048(以IP 10.0.3.48为例):
On the server:
在服务器上:
$ nc -l 1048
On the client
在客户端上
$ nc 10.0.3.48 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:
如果它可以连接到服务器,请在其中输入内容。 如果服务器也可以看到它,则说明连接没有问题。
为了测试UDP连接,我们可以简单地在nc中添加'-u'选项:
在服务器上:
$ nc -u -l 1048
On client:
在客户端上:
$ nc -u 10.0.3.48 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)”: http://www.xinotes.org/notes/note/1080/
在“使用nc(netcat)进行TCP / IP连接测试”中使用nc的更多示例: http : //www.xinotes.org/notes/note/1080/
翻译自: https://www.systutorials.com/how-to-test-the-connections-between-linux-hosts-servers/