当没有安装Telnet来检查端口时,用户使用什么是开放的和可达的? 例如,我曾经使用telnet <destination>技术,并知道它在那里,即使telnet无法与另一端的系统交互。
随着Windows 2008的远程login不安装,所以我有点失落。 那么我可以用什么来代替。 还有一些东西,如果它不在Linux或Solaris,也请。
我是一个在不同的网站工作的顾问。 出于许多原因(访问权限,更改控制时间,如果我安装它明年有人使用它,我们有一些责任等),我不能安装在别人的服务器上。 但是,USB或其他自包含的,未安装的工具将是美好的…
$ipaddress = "4.2.2.1" $port = 53 $connection = New-Object System.Net.Sockets.TcpClient($ipaddress, $port) if ($connection.Connected) { Write-Host "Success" } else { Write-Host "Failed" }
[CmdletBinding()] Param( [Parameter(Mandatory=$True,Position=1)] [string]$ip, [Parameter(Mandatory=$True,Position=2)] [int]$port ) $connection = New-Object System.Net.Sockets.TcpClient($ip, $port) if ($connection.Connected) { Return "Connection Success" } else { Return "Connection Failed" }
然后,在PowerShell或cmd提示符中使用命令,如下所示:
PS C:\> telnet.ps1 -ip 8.8.8.8 -port 53
要么
PS C:\> telnet.ps1 8.8.8.8 53
这里有几种不用telnettestingTCP端口的方法。
BASH ( 手册页 )
# cat < /dev/tcp/127.0.0.1/22 SSH-2.0-OpenSSH_5.3 ^C # cat < /dev/tcp/127.0.0.1/23 bash: connect: Connection refused bash: /dev/tcp/127.0.0.1/23: Connection refused
curl
# curl -v telnet://127.0.0.1:22 * About to connect() to 127.0.0.1 port 22 (#0) * Trying 127.0.0.1... connected * Connected to 127.0.0.1 (127.0.0.1) port 22 (#0) SSH-2.0-OpenSSH_5.3 ^C # curl -v telnet://127.0.0.1:23 * About to connect() to 127.0.0.1 port 23 (#0) * Trying 127.0.0.1... Connection refused * couldn't connect to host * Closing connection #0 curl: (7) couldn't connect to host
python
# python Python 2.6.6 (r266:84292, Oct 12 2012, 14:23:48) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import socket >>> clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> clientsocket.connect(('127.0.0.1', 22)) >>> clientsocket.send('\n') 1 >>> clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> clientsocket.connect(('127.0.0.1', 23)) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<string>", line 1, in connect socket.error: [Errno 111] Connection refused
Perl的
# perl use IO::Socket::INET; $| = 1; my $socket = new IO::Socket::INET( PeerHost => '127.0.0.1', PeerPort => '22', Proto => 'tcp', ); die "cannot connect to the server $!\n" unless $socket; print "connected to the server\n"; ^D connected to the server