How to test Port pass (four methods) _linux shell

Source: Internet
Author: User
Tags openssl ssh

In general, use the "Telnet IP port" to determine the port pass, in fact, testing methods more than this one, there are many ways, the following small series to share several methods, the specific content please look down:

Preparing the Environment

Start a Web server and provide a port.

[Wyq@localhost ~]$ python-m simplehttpserver 8080 serving
HTTP on 0.0.0.0 port 8080 ...

The same can be provided with other Web servers, because Python is convenient, it is used here

1. Use Telnet to judge

Telnet is a Windows standard service that you can use directly, and if you are a Linux machine, you need to install Telnet.

Usage: Telnet IP port

1) First use Telnet to connect the nonexistent port

[root@localhost ~]# telnet 10.0.250.3
trying 10.0.250.3 ...
Telnet:connect to address 10.0.250.3:connection refused #直接提示连接被拒绝

2) connecting the existing ports again

[root@localhost ~]# telnet localhost
trying:: 1 ...
Connected to localhost. #看到Connected就连接成功了
Escape character is ' ^] '.
ssh-2.0-openssh_5.3
a
Protocol mismatch.
Connection closed by foreign host.

2. Use SSH to judge

SSH is the standard Linux configuration and the most common, can be used to determine the port?

Usage: ssh-v-P Port Username@ip

-V debug Mode (log is printed).

-P Specify port

Username is free to

1 connection does not exist port

[root@localhost ~]# ssh 10.0.250.3-p
ssh:connect to host 10.0.250.3 Port 80:connection refused
[Root@localho St ~]# ssh 10.0.250.3-p 80-v openssh_5.3p1 OpenSSL 1.0.1e-fips Feb
-2013 debug1:reading
Data/ Etc/ssh/ssh_config
debug1:applying options for *
debug1:connecting to 10.0.250.3 [10.0.250.3] port.
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 the port where the connection exists

[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
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< C18/>^c

It's OK without the-v option.

3. Use wget judgment

Wget is a download tool under Linux and needs to be installed first.

Usage: wget ip:port

1 connecting ports that do not exist

[Root@localhost ~]# wget.:
----::--http://.../connecting to
... Failed:connection refused.

2 the port where the connection exists

[Root@localhost ~]# wget ...:
----::--http://...:/
connecting to ...: Connected
. HTTP request sent, awaiting response ...

4. Use port Scan Tool

[Root@localhost ~]# Nmap ...-P 
starting nmap. (http://nmap.org) at-: CST
nmap Scan
... The Host is up (. S latency).
PORT State SERVICE
/tcp closed http
MAC address:b:a::cf:fd:d (Unknown)
Nmap Done:ip Address (host up) scanned in. Seconds
[root@localhost ~]# nmap ...-P 
starting nmap. (http://nmap.org) at-: CST
nmap Scan
... The Host is up (. S latency).
PORT State SERVICE
/tcp open http-proxy
MAC address:b:a::cf:fd:d (Unknown)
Nmap Done:ip Address (host up) scanned in. Seconds
[root@localhost ~]# nmap ...
Starting Nmap. (http://nmap.org) at-: CST
nmap Scan
... The Host is up (. S latency).
Not shown:closed ports
PORT State SERVICE
/tcp open ssh
/tcp open rpcbind
/tcp open Http-proxy
/tcp Open Unknown
MAC address:b:a::cf:fd:d (Unknown)
Nmap Done:ip Address (host up) scanned in. Seconds

Summarize

Provides a port service, the TCP protocol is used, as an example of a Web server. If the server is a simpler TCP server, three tools are also available.

The common denominator of three tools is: 1. Based on TCP protocol 2. Can access the specified port. Following these two points, you can find a lot of tools.

Generally in Windows under the use of Telnet more convenient, Linux under the individual is more like to use wget.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.