Network command-NC (ii)

Source: Internet
Author: User

Keep Netcat the order.

1: Remote Copy file

On-Premises output file debian.img to 192.168.5.40 host 12345 port monitoring

Nc-v 192.168.5.40 12345 < debian.img

On 192.168.5.40 host 12345 Port Listener, designate the file as Debian-copy.img

Nc-l-V 12345 > debian-copy.img

2. Clone the hard disk or partition (

This command really likes, the previous backup operation made a good Debian system, especially with DD backup disk, for example, you can use the DD, and then the NC network transmission, do not need to operate two times

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. So, after booting with the installation disc, such as the LIVEUSB mode,

Perform a similar listening action on the Server2:

# nc-l-P 1235 | DD OF=/DEV/SDA (You can not specify as/DEV/SDA, can be any format, such as Debian.image, so the SERVER1/DEV/SDA disk copy to Debian.image)

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

# dd IF=/DEV/SDA bs=1m | NC 192.168.5.40 12345

3: Batch detection server specifies port opening:

A: If we want to monitor a bunch of specified IP and ports, you can create a new file (1th server IP, 2nd column to monitor the port).
# Vim/scripts/ip-ports.txt
192.168.5.100 80
192.168.5.101 80
192.168.5.102 80
192.168.5.103 80
B: We can write such a script to detect whether the port is open in bulk:
# vim/scripts/ncports.sh
#!/bin/bash
#检测服务器端口是否开放, Success will return 0 value display OK, failure will return 1 value show fail

Cat/scripts/ip-ports.txt | While Read line
Do
Nc-w 10-z $line >/dev/null 2>&1
If [$?-eq 0]
Then
echo $line: OK
Else
echo $line: Fail
Fi
Done

It's cool. Hey, this is online to see someone else write (http://huangrs.blog.51cto.com/2677571/967512)

Network command-NC (ii)

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.