如何检查两个Linux服务器之间的端口是否打开?

时间:2021-07-09 07:23:05

How do you check if a port is open when you cannot use telnet or install Cacti? I want to see if a port is open between two Linux servers. Telnet isn't installed. I tried this command:

当您不能使用telnet或安装Cacti时,如何检查端口是否打开?我想看看两个Linux服务器之间是否打开了一个端口。Telnet不安装。我试着这个命令:

cat < /dev/tcp/x.x.x.x/6061

where x.x.x.x was the remote IP address of the Linux server and port 6061 is the port that I want to test. But based on tests of known working and not working ports, this command wasn't conclusive to me. There may be an environmental explanation for that.

. x.x.x的地方。x是Linux服务器的远程IP地址,端口6061是我要测试的端口。但是基于已知的工作和不工作端口的测试,这个命令对我来说不是决定性的。这可能有一个环境上的解释。

2 个解决方案

#1


2  

Install nmap and than:

安装nmap和比:

nmap x.x.x.x

#2


1  

Better use (if installed) : :

更好的使用(如果安装):netcat:

nc -zw3 <host> <port>

If you want to use the feature net redirection :

如果你想使用bash特性,net重定向:

cat < /dev/tcp/x.x.x.x/6061

do it the right way :

用正确的方式:

{ exec 3<> /dev/tcp/127.0.0.1/6061; } &>/dev/null &&
    echo "Connection to socket OK" ||
    echo >&2 "Can't connect"

If it doesn't work, you need to compile with --enable-net-redirections

如果它不起作用,您需要使用—enable-net-redirections编译bash

#1


2  

Install nmap and than:

安装nmap和比:

nmap x.x.x.x

#2


1  

Better use (if installed) : :

更好的使用(如果安装):netcat:

nc -zw3 <host> <port>

If you want to use the feature net redirection :

如果你想使用bash特性,net重定向:

cat < /dev/tcp/x.x.x.x/6061

do it the right way :

用正确的方式:

{ exec 3<> /dev/tcp/127.0.0.1/6061; } &>/dev/null &&
    echo "Connection to socket OK" ||
    echo >&2 "Can't connect"

If it doesn't work, you need to compile with --enable-net-redirections

如果它不起作用,您需要使用—enable-net-redirections编译bash