您的位置:首页 > 其它

判断端口通不通的几种方法

2016-01-14 11:28 176 查看
1、使用telnet判断

telnet是windows标准服务,可以直接用;如果是linux机器,需要安装telnet.用法: telnet ip port1)先用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 10.0.250.3 -p 8080
a

^]
^C
[root@localhost ~]# ssh 10.0.250.3 -p 8080 -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 8080.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/identity-cert type -1
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
a
^C
不用-v选项也可以咯3、使用wget判断

wget是linux下的下载工具,需要先安装.用法: wget ip:port1)连接不存在的端口
[root@localhost ~]# wget 10.0.250.3:80
--2016-01-14 11:03:28--  http://10.0.250.3/ Connecting to 10.0.250.3:80... failed: Connection refused.
2)连接存在的端口
[root@localhost ~]# wget 10.0.250.3:8080
--2016-01-14 11:04:59--  http://10.0.250.3:8080/ Connecting to 10.0.250.3:8080... connected.
HTTP request sent, awaiting response...
4、使用端口扫描工具
[root@localhost ~]# nmap 10.0.250.3 -p 80

Starting Nmap 5.51 ( http://nmap.org ) at 2016-01-14 11:19 CST
Nmap scan report for 10.0.250.3
Host is up (0.00032s latency).
PORT   STATE  SERVICE
80/tcp closed http
MAC Address: B8:2A:72:CF:FD:D2 (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 0.12 seconds
[root@localhost ~]# nmap 10.0.250.3 -p 8080

Starting Nmap 5.51 ( http://nmap.org ) at 2016-01-14 11:19 CST
Nmap scan report for 10.0.250.3
Host is up (0.00036s latency).
PORT     STATE SERVICE
8080/tcp open  http-proxy
MAC Address: B8:2A:72:CF:FD:D2 (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 0.11 seconds
[root@localhost ~]# nmap 10.0.250.3

Starting Nmap 5.51 ( http://nmap.org ) at 2016-01-14 11:16 CST
Nmap scan report for 10.0.250.3
Host is up (0.00024s latency).
Not shown: 996 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
111/tcp  open  rpcbind
8080/tcp open  http-proxy
8090/tcp open  unknown
MAC Address: B8:2A:72:CF:FD:D2 (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 1.21 seconds
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: