Linux nc/netcat Command Introduction

Source: Internet
Author: User
Tags domain name server

The 1,NC command is the abbreviation for the Netcat command, which is used to set up the router.

2, grammar
Nc/netcat (option) (parameter)

3, Options
-g< Gateway: Set up a router hop communication gateway, set up 8;
The number of-g<: Set the source route-pointing device, which is a multiple of 4;
-H: Online help;
-i< delay seconds;: Set the time interval for transmitting information and scanning the communication port;
-L: Monitor the incoming data using the listening mode;
-N: Use the IP address directly, not through the domain name server;
-o< output file;: Specify the name of the file, the data transmitted by the transfer of 16 binary loadline dumped into the file to save;
-p< communication port;: Set the communication port used by the local host;
-r: Specifies the source port and destination port are randomly selected;
-s<: Set the IP address of the local host to send the packet;
-U: Using UDP transport protocol;
-V: Displays the instruction execution process;
-w< timeout number of seconds;: Set the time to wait for the connection;
-Z: Use 0 input/output mode, only when scanning communication ports.

4, Parameters
Host: Specifies the IP address or host name of the host;
Port number: Can be a single integer or a range

5, examples and applications
(a) remote copy of files
Copy files from Server1 to Server2. You need to activate the listener with NC on the Server2 first.

Run on Server2:

[Email protected] tmp]# NC-LP 1234 > Install.log
Run on Server1:

[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

(b) Cloning a hard disk or partition
The operation is identical to the copy above, only the data of the hard disk or partition must be obtained by DD and then transferred. 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 doing this is to implement the CD rescue mode to support the network card on the server and properly configure the IP.

(c) Port scan
Nc-v-W 1 192.168.228.222-z 1-1000
Localhost2 [192.168.228.222] (SSH) Open

(d) Saving Web pages
While true; Do
Nc-l-P 80-q 1 < somepage.html;
Donen

(e) 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.

(f) Transmission directory

Copy nginx-0.6.34 directory contents from Server1 to Server2. Need to first on the Server2, with NC activation monitoring, Server2 run:

[[email protected] tmp]# NC-L 1234 | Tar XZVF-
Run on Server1:

[Email protected] ~]# ll-d nginx-0.6.34
Drwxr-xr-x 8 4096 12-23 17:25 nginx-0.6.34

[Email protected] ~]# tar czvf–nginx-0.6.34 | NC 192.168.228.222 1234

Linux nc/netcat Command Introduction

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.