查看远程服务器的某一端口是否开启

查看远程服务器的某一端口是否开启,第1张

工具/原料

nc

telnet

方法/步骤

1、首先端口分tcp、udp之分,所以同一个端口号还有tcp协议和udp协议之分。

2、最常见的工具是telnet,但是telnet使用的是tcp协议,换句话说telnet只能检测tcp的这个端口打开了没。

3、假设要看192192193211这个IP的tcp 22端口是否打开,则运行telnet 192192193211 22 来查看,如果出现下列信息,则表示该端口已打开。

4、如果出现下面信息,表是该端口未打开。

5、除了telnet以外,还有一个命令nc也可查看端口是否打开。

6、同样查看tcp 22端口是否打开,可以运行nc  -z 192192193211 22,打开着就会出现下列信息:

7、那如果想要查看udp 22 端口是否打开,运行 nc –uz 192192193211 22, 打开这就会出现这些信息:

8、如果查询的端口没有打开,会出现以下输出:

8、nc 还可以一次性查看多了端口,例如:

1、使用telnet判断
telnet是windows标准服务,可以直接用;如果是linux机器,需要安装telnet
用法: telnet ip port
1)先用telnet连接不存在的端口
[root@localhost ~]# telnet 1002503 80
Trying 1002503
telnet: connect to address 1002503: Connection refused #直接提示连接被拒绝
2)再连接存在的端口
[root@localhost ~]# telnet localhost 22
Trying ::1
Connected to localhost #看到Connected就连接成功了
Escape character is '^]'
SSH-20-OpenSSH_53
a
Protocol mismatch
Connection closed by foreign host
2、使用ssh判断
ssh是linux的标准配置并且最常用,可以用来判断端口吗?
用法: ssh -v -p port username@ip
-v 调试模式(会打印日志)
-p 指定端口
username可以随意
1)连接不存在端口
[root@localhost ~]# ssh 1002503 -p 80
ssh: connect to host 1002503 port 80: Connection refused
[root@localhost ~]# ssh 1002503 -p 80 -v
OpenSSH_53p1, OpenSSL 101e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for
debug1: Connecting to 1002503 [1002503] port 80
debug1: connect to address 1002503 port 80: Connection refused
ssh: connect to host 1002503 port 80: Connection refused
2)连接存在的端口
[root@localhost ~]# ssh -p
a
^]
^C
[root@localhost ~]# ssh -p -v
OpenSSH_p, OpenSSL e-fips Feb
debug: Reading configuration data /etc/ssh/ssh_config
debug: Applying options for
debug: Connecting to [] port
debug: Connection established
debug: permanently_set_uid: /
debug: identity file /root/ssh/identity type -
debug: identity file /root/ssh/identity-cert type -
debug: identity file /root/ssh/id_rsa type -
debug: identity file /root/ssh/id_rsa-cert type -
debug: identity file /root/ssh/id_dsa type -
debug: identity file /root/ssh/id_dsa-cert type -
a
^C
不用-v选项也可以咯
3、使用wget判断
wget是linux下的下载工具,需要先安装
用法: wget ip:port
1)连接不存在的端口
[root@localhost ~]# wget :
---- ::-- >

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/13103777.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-30
下一篇 2023-05-30

发表评论

登录后才能评论

评论列表(0条)

保存