我试图testing机器A是否可以连接到某些端口上的机器B. 机器A的系统pipe理员已经看到适合删除telnet命令。 什么将是一个方便的替代? 机器A是CentOS。
iirc,telnet不是默认安装在centos 6机器上的。 如果你没有像telnet或nc这样的工具,你可以使用python来与networking套接字进行通信。 (不知道这是否符合你的“方便”的要求,虽然…)
简单地testing是否可以build立连接:
[gryphius@ut ~]$ python Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import socket >>> conn=socket.create_connection(('gmail-smtp-in.l.google.com',25))
如果到目前为止没有发生错误,连接就没问题。 如果您还想testing接收/发送数据,则可以继续如下操作:
>>> input=conn.makefile() >>> print input.readline() 220 mx.google.com ESMTP p2si6911139eeg.7 - gsmtp >>> conn.sendall('HELO example.com\r\n') >>> print input.readline() 250 mx.google.com at your service >>> conn.sendall('QUIT') >>> conn.close() >>>
任何:nc(netcat),nmap,hping。
http://linux.byexamples.com/archives/258/when-netcat-act-as-telnet-client-it-becomes-better/
我想到了一个方法:
$ ssh -f -N machineA -L 10123:machineB:123 $ telnet localhost 10123
它失败了,但我不确定这是否确实是诊断性的。 经过进一步testing,确实是诊断性的。