【转载】测试端口通不通(四种方法)

【转载】测试端口通不通(四种方法)

准备环境

启动一个web服务器,提供端口.

[wyq@localhost ~]$ python -m SimpleHTTPServer 8080 Serving HTTP on 0.0.0.0 port 8080 ...

用其它web服务器提供端口也一样,由于python比较方便,这里就用它

1、使用telnet判断

telnet是windows标准服务,可以直接用;如果是linux机器,需要安装telnet.

用法:telnet ip port

1)先用telnet连接不存在的端口

[root@localhost ~]# telnet 10.0.250.3 80

Trying 10.0.250.3... telnet: connect to address 10.0.250.3: Connection refused

#直接提示连接被拒绝

2)再连接存在的端口

[root@localhost ~]# telnet localhost 22

Trying ::1... Connected to localhost.

#看到Connected就连接成功了

Escape character is '^]'. SSH-2.0-OpenSSH_5.3 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 10.0.250.3 -p 80

ssh: connect to host 10.0.250.3 port 80: Connection refused

[root@localhost ~]# ssh 10.0.250.3 -p 80 -v OpenSSH_5.3p1,

OpenSSL 1.0.1e-fips 11 Feb 2013 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to 10.0.250.3 [10.0.250.3] port 80. debug1: connect to address 10.0.250.3 port 80: Connection refused ssh: connect to host 10.0.250.3 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判断(curl同理)

wget是linux下的下载工具,需要先安装.

用法:wget ip:port

1)连接不存在的端口

[root@localhost ~]# wget ...: ---- ::--

http://.../ Connecting to ...:... failed: Connection refused.

2)连接存在的端口

[root@localhost ~]# wget ...: ---- ::--

http://...:/ Connecting to ...:... connected. HTTP request sent, awaiting response...

相关推荐

【英语单词】彻底解释“prepare”! 含义、用法、例句、如何记忆
用正确的姿势喷京东,但那依然不是重点 这两天 京东 被骂惨了,盼了好久盼到王者归来,结果画饼画出了天际,实际又是无止境的沉默与延期。物资现状在足不出户的情况下...
iphone录音可以录多久
365现在还能安全提款吗

iphone录音可以录多久

📅 07-10 👁️ 4393
【PC游戏】20款多人联机生存沙盒开放类游戏推荐
365现在还能安全提款吗

【PC游戏】20款多人联机生存沙盒开放类游戏推荐

📅 07-15 👁️ 630
美瞳没带护理液怎么办
Bet体育365怎么提款

美瞳没带护理液怎么办

📅 07-16 👁️ 4759
为什么机械硬盘容易坏?擦写次数不容忽视
365现在还能安全提款吗

为什么机械硬盘容易坏?擦写次数不容忽视

📅 07-16 👁️ 5583
摩拜单车如何举报?举报方法介绍
365bet体育存款

摩拜单车如何举报?举报方法介绍

📅 08-02 👁️ 8197
纯干货:净宅安灶常规流程【含咒语表文】
365现在还能安全提款吗

纯干货:净宅安灶常规流程【含咒语表文】

📅 08-31 👁️ 198
如何线上购买卧铺票?软卧能线上选铺吗?
365现在还能安全提款吗

如何线上购买卧铺票?软卧能线上选铺吗?

📅 08-30 👁️ 9579