Using Telnet to detect if a remote port is open under Linux

Source: Internet
Author: User

Tag: Telnet detects whether the remote port is open

Method one. Common Telnet 118.10.6.128 88 way to test whether the remote host port is open.

Method Two. Nmap ip-p Port test ports

Nmap IP shows all open ports

Determines whether the port is open according to the display Close/open.

Method Three. NC-V Host Port

Port not open return status is not 0


One: Telnet
This method is often used to detect whether a remote port is unobstructed.

Test domain name: # telnet baidu.com 80Trying 123.125.114.144...Connected to Baidu.com (123.125.114.144).             #==> appeared connected, indicating that Baidu's 80 port open escape character is ' ^] '. #==> Press "CTRL +]" to exit the area. ^]telnet> quitconnection closed. Test IP Address: # telnet 108.5.16.139 7506Trying 108.5.16.139...Connected to    Static-108-5-16-139.nycmny.fios.verizon.net (108.5.16.139).        #==> appears connected indicates connectivity, explaining 108.5.16.139 's 7506 Port open escape character is ' ^] '. #==> Press "CTRL +]" to exit ^]telnet> Quitconnection closed.

If the write script checks the port via Telnet, the following method can be used:

# echo-e "\ n" |telnet baidu.com 80|grep connectedconnection closed by foreign host. Connected to Baidu.com (123.125.114.144).


Second: through Nmap to check whether the port is unobstructed

# Nmap Etiantian.org-p starting Nmap 4.11 (http://www.insecure.org/nmap/) at 2012-07-22 17:22 pdtinterest ing ports on 211.100.98.99:port State service80/tcp open Httpnmap finished:1 IP address (1 host up) scanned in 0.417 s Econds

If you write a script through Nmap Check port can use the following method:

Port_count= ' Nmap $ip _add-p $port |grep open|wc-l ' [[$PORT _count-ge 1]] && echo "$ip _add $port is ok." | | echo "$ip _add $port is unknown."


Three: Check by NC command

# nc-w 8.8.8.8 && echo OK | | Echo No OK


This article is from "Operation and maintenance record Mei Ling" blog, please be sure to keep this source http://meiling.blog.51cto.com/6220221/1982402

Using Telnet to detect if a remote port is open under Linux

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.