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)