Examples of NC commands in Linux

Source: Internet
Author: User
Tags set time domain name server

The NC command in Linux is a powerful network tool, the full name is Netcat.

Grammar:

NC [-hlnruz][-g< Gateway ...>][-g< number of points >][-i< delay seconds >][-o< output file >][-p< communication port >][-s< Source address >][ -V ...] [-w< timeout number of seconds;] [Host name] [Communication port ...]

Parameter description:

-g< Gateway > Set Router Hop communication gateway, the most lost oh can be set to 8. -g< number of pointers > set source route-to-point, with a number of multiples of 4. -H online Help. -i< delay seconds > Set time interval for transmitting information and scanning communication ports. -L Use the monitor mode to control incoming data. -N uses the IP address directly, not through the domain name server. -o< output File > Specify the name of the file, and transfer the data transferred to the file in 16 Loadline to save. -p< Communication port > Set the communication port used by the local host. -R chaos Specifies the communication port between the local and the remote host. -s< Source location > Set the IP address of the local host to send the packet. -U uses the UDP transport protocol. -V Displays the instruction execution process. -w< Timeout seconds > Set the time to wait for the connection. -Z uses 0 in/out mode and is only used when scanning communication ports.


A few simple examples:

1. Scan the specified port

[[email protected] ~]# nc-v-W 5-z 192.168.233.129 8003
Connection to 192.168.233.129 8003 Port [Tcp/mcreport] succeeded!


2. scan the specified port range

[[email protected] ~]# nc-v-W 5-z 192.168.233.129 8000-8005
Nc:connect to 192.168.233.129 Port 8000 (TCP) Failed:connection refused
Connection to 192.168.233.129 8001 Port [Tcp/vcom-tunnel] succeeded!
Connection to 192.168.233.129 8002 Port [Tcp/teradataordbms] succeeded!
Connection to 192.168.233.129 8003 Port [Tcp/mcreport] succeeded!
Nc:connect to 192.168.233.129 Port 8004 (TCP) Failed:connection refused
Nc:connect to 192.168.233.129 Port 8005 (TCP) Failed:connection refused


3. Remote Copy

Open port 1234 on the receive side 192.168.233.128:

NC-L 1234 >test.txt


On the sending side, execute:

NC 192.168.233.128 1234 <test.txt


Note: Run the receive end first, specify a port of 1234, the file is Test.txt, then execute the send side, and the sender must have a file with the same name Test.txt

4. Remote Directory Transfer

Copy the test directory contents from Server1 (192.168.16.233) to Server2 (192.168.48.47). You need to activate the monitor with NC on the Server2 first,

Run on Server2:

# NC-L 1234 | Tar xzv-


Run on Server1:

[Email protected] ~]# tar zcv-test | NC 192.168.233.128 1234



650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/98/BC/wKiom1k_1GuRSalYAAAMBRERq94794.png "title=" Picture 9.png "alt=" Wkiom1k_1gursalyaaambrerq94794.png "/>

5. Simple Chat Tool

On the 192.168.233.128:

NC-L 1234


On the 192.168.233.129:

NC 192.168.233.128 1234



This article is from the "Qing Miao write" blog, please be sure to keep this source http://qingmiao.blog.51cto.com/7286083/1935128

Examples of NC commands in Linux

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.