is the NC test port open in Linux?

Source: Internet
Author: User
Tags unix domain socket domain name server

NC Test Port is open

There is a powerful network tool in Linux Netcat, which is not installed by default, now describes the installation process
In fact the installation is very simple

First, installation and use

1. Just enter the command yum install:

Yum Install -y NC
[Email protected] ~]#Yum Install-y ncloaded plugins:fastestmirror, refresh-PackageKit, securitysetting up Install processdetermining fastest mirrorscentos.6. base.x86_64 |4.1Kbxx:xxCentOS.6. extras.x86_64 |2.9Kbxx:xxCentOS.6. extras.x86_64/primary_db | theKbxx:xxCentOS.6. updates.x86_64 |2.9Kbxx:xxCentOS.6. updates.x86_64/primary_db | -Kbxx:xxResolving Dependencies-Running Transaction Check---> Package nc.x86_640:1.84- -. El6 'll be installed-finished Dependency resolutiondependencies resolved=============================================================================================================== =============================================================================================================== ===============Package Arch Version Repository size=============================================================================================================== =============================================================================================================== ===============INSTALLING:NC x86_64 1.84- -. el6 CentOS.6. base.x86_64 $ktransaction Summary=============================================================================================================== =============================================================================================================== ===============Install1Package (s) Total Download size: $kinstalled Size:109kdownloading PACKAGES:NC-1.84- -. el6.x86_64.rpm | $Kbxx:xxRunning rpm_check_debugrunning Transaction testtransaction Test succeededrunning transactionwarning:rpmdb altere D Outside ofYum. INSTALLING:NC-1.84- -. el6.x86_641/1VERIFYING:NC-1.84- -. el6.x86_641/1Installed:nc.x86_640:1.84- -. el6 Complete!

2. Test use:

Enter NC-LK 9999 on the terminal

Enter Telnet IP 9999 on the other terminal

What is entered on this terminal can be seen on the other terminal, indicating that the port is already in pass.

Second, the NC command detailed

-g< Gateway >: Set up a router hop communication gateway with a maximum of 8, -g< number of pointers > : Sets the source route to a multiple of 4, -h: Online help; -i< delay seconds >-L: Monitor incoming data using listening mode; -n: Use the IP address directly, not through the domain name server; -o< output file > : Specify the name of the file to dump the data transferred to the file in 16 loadline to save; -p< communication port >: Sets the communication port used by the local host; -r: Specifies the source port and destination port are randomly selected; -s< source address >: Set the IP address of the local host to send packets ; -u: Using the UDP transport protocol; -v: Displays the instruction execution process; - Span style= "COLOR: #0000ff" >w  < timeout seconds >: Set the time to wait for the connection; -Z: use 0 input/ output mode, only used when scanning communication ports. 

NetCat, a "Swiss Army Knife" in Web tools, has a version of Windows and Linux. Because it is short and short (the 1.84 version is 25k, the old version or the reduced version is even smaller), functional, is designed as a simple, reliable network tool, can transmit read and write data through TCP or UDP protocol. At the same time, it is a network application debug parser, because it can create a variety of different types of network connections as needed.


The usual version of the Linux distribution is Netcat (NC), even in the rescue mode CD, which is provided by BusyBox with a simple version of the NC tool. But different versions, the use of their parameters slightly different. NetCat Official Address: http://netcat.sourceforge.net/

references [[email protected] ~]# cat/etc/asianux-release asianux Release 2.0 (Trinity SP2) [[email protected] ~]# CAT/ETC/REDFLA G-release Red Flag DC Server Release 5.0 (Trinity SP2) [[email protected] ~]# type-a NC NC is/usr/bin/nc [email Protect ED] ~]# rpm-q NC nc-1.10-22

It is recommended to use man NC to see help before using. Here is a brief description of the 1.10 version on red Flag DC Server 5.0. Assume two server information:

Reference server1:192.168.228.221 server2:192.168.228.222

Iii. Common use 1, remote copy files from Server1 copy files to Server2. Need to first on the Server2, with NC activation monitoring, Server2 run:

references [[email protected] tmp]# NC-LP 1234 > Install.log

Run on Server1:

references [[email protected] ~]# ll install.log-rw-r--r--1 root root 39693 December install.log [[email protected] ~]# NC -W 1 192.168.228.222 1234 < Install.log

2, clone hard disk or partition operation and the above copy is identical, only need to get the hard disk or partition data by DD, and then transfer. Cloning the operation of a hard disk or partition should not take place on a system already on mount. Therefore, after booting with the installation disc, enter rescue mode (or use the Knoppix tool CD) to boot the system and perform a similar listening action on the Server2:

# nc-l-P 1234 | DD OF=/DEV/SDA

Perform the transfer on Server1 to complete the task of cloning the SDA hard drive from Server1 to Server2:

# DD IF=/DEV/SDA | NC 192.168.228.222 1234

※ The prerequisite for completing the above work is to implement the CD rescue mode to support the network card on the server and properly configure the IP.
3. Port scan
can be performed:

Ref # NC-V-W 1 192.168.228.222-z 1-1000 hatest2 [192.168.228.222] (SSH) Open

4. Save the Web page

# while true; Do Nc-l-P 80-q 1 < somepage.html; Done

5. Analog HTTP Headers

references [[email protected] ~]# NC www.linuxfly.org get/http/1.1 Host:ispconfig.org Referrer:mypage.com User-agent:my-bro Wser
http/1.1 date:tue, Dec 07:23:24 GMT server:apache/2.2.6 (Unix) dav/2 mod_mono/1.2.1 mod_python/3.2.8 Pyth on/2.4.3 mod_perl/2.0.2 perl/v5.8.8 Set-cookie:phpsessid=bbadorbvie1gn037iih6lrdg50; path=/expires:0 Cache-control:no-store, No-cache, Must-revalidate, post-check=0, pre-check=0 Pragma:no-cache Cache-Co Ntrol:private, Post-check=0, pre-check=0, max-age=0 Set-cookie:own_sid=xrutay; Expires=tue, 23-dec-2008 07:23:24 GMT; path=/vary:accept-encoding transfer-encoding:chunked content-type:text/html [...]

After the NC command, enter the contents of the Red section and press ENTER two times to get the HTTP headers content from the other side.
6, Chat NC can also be used as a simple word hyphenating chat tool, the same, server2 need to start monitoring:

[Email protected] tmp]# NC-LP 1234

Server1 on transfer:

[[Email protected] ~]# NC 192.168.228.222 1234

In this way, the two sides can communicate with each other. Use Ctrl+d to exit normally.
7, the transmission directory from Server1 copy nginx-0.6.34 directory contents to Server2. Need to first on the Server2, with NC activation monitoring, Server2 run:

references [[email protected] tmp]# nc-l 1234 |tar XZVF-

Run on Server1:

references [[email protected] ~]# ll-d nginx-0.6.34 drwxr-xr-x 8 + 4096 12-23 17:25 nginx-0.6.34 [[email protected] ~]# TA R CZVF-NGINX-0.6.34|NC 192.168.228.222 1234

8, Parameter introduction This is only a simple 1.10 version of the description, the detailed parameters to use or need to look at the man:

References want to connect to somewhere: NC [-options] hostname port[s] [ports] ... Bind port Waiting for connection: Nc-l-P Port [-options] [hostname] [port] Parameter:-G gateway source-routing Hop Point[s], up to 8-g num Source-rou Ting Pointer:4, 8, ...-H help information-i secs time-out interval-l listening mode, for inbound connection-n Specifies the IP address of the number, cannot be transmitted with the Hostname-o file 16-in-port port local port number -R arbitrarily specify local and remote port-S addr Local Source address-u UDP mode-v Verbose output--with two-V to get more detailed content----secs timeout time

-Z turns the input and output off-when used for scanning, where the port number can specify one or a specified range of Lo-hi.

9, 1.84 version of the parameters introduction

1. NC [ -46DDHKLNRSTUUVZC] [-I interval] [-P Source_port]2. [-S source_ip_address] [-T ToS] [-WTimeout] [-X proxy_protocol] [-x3. proxy_address[:p ORT] [hostname] [Port[s]]1. -4Force the use of IPv42. -6Force the use of IPv63. -D allow socket communication to return debug information4. -d not allowed to read from standard input5. -h display NC Help documentation6. -I interval7. Specifies that the content is delayed sent and accepted between each line, or that the connection between multiple ports can be delayed8. -K forces the NC to listen for another connection at the end of a connection. Must and-l Use together9. -L is used to listen for incoming data links and cannot be used with-p-z-S. -WTimeout for parameters is also ignoredTen. -n Do not execute any address, hostname, port or DNS query One. -p Specifies the source port used by the NC, restricted by permissions and not redundant-l Use together A. -r Specifies the source and destination ports that are used by the NC and cannot use those ports that the system originally specified13. -S allow TCP MD5 signature option in RFC 2385 -. -s source_ip_address the. Specifies the IP address of the interface used for the package, cannot and-l Use together -. -T ToS -. Specify the IP service type of the link (TOS) -. -C Wrap Line +. -T enables NC to interact with Telnet -. -U use UNIX domain socket +. -u use UDP instead of default TCP option A. -v Output detailed report at. -WTimeout -. A link has no action for a period of time, then automatically disconnects, default no timeout -. -X proxy_version -. Specifies the protocol used by the NC to use the proxy, with optional SOCKSV4,SOCKS5 and HTTPS. Default SOCKS5 -. -x proxy_address[:p ort] -. Specifies the proxy address and port used by the NC. Default settings: the(SOCKS),3128(HTTPS) in. -Z only listens for no packets sent

Iv. Version Differences the NC version provided on the system will be different, and the parameters used by it may vary slightly. For example, the red Flag Asianux 3.0 SP1 Rescue CD version is available for use with only a subset of the parameters:

Ref # Nc-h BusyBox v1.2.0 (2008.04.14-01:35+0000) multi-call binary
USAGE:NC [OPTIONS] [IP] [port]
Netcat opens a pipe to Ip:port
Options:-L Listen mode, for inbound connects-p port local port number-          I SECS delay interval for lines SENT-E PROG program to exec after connect (dangerous!) -W SECS timeout for connects and final net reads

The NC version provided in the Asianux 3.0 SP1 system is 1.84, which is not executed according to the above parameter usage:

references [[email protected] ~]# rpm-q NC nc-1.84-10 [[email protected] ~]# NC-LP 1234 USAGE:NC [ -46DDHKLNRSTUUVZC] [-I Interva l] [-P source_port] [-S source_ip_address] [-t ToS] [-w timeout] [-X proxy_version] [-X Proxy_addres s[:p ORT] [hostname] [port[s]]

To view the man document, it is visible in this version,-L is not used with-s,-P,-Z, and the-w parameter is ignored, so the correct usage is:

[Email protected] tmp]# nc-l 1234

PS: Recommended detailed link: http://man.linuxde.net/nc_netcat

is the NC test port open in 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.