This article provides thought-based usage: about the automatic detection feature, the various ports and the capture function, the project used for Nmap software, Linux operating system, first we want to install NMAP software project used in the nmap-6.40-7.el7.x86_64 version,
The command format is: #nmap [Scan type] [options] < target host >
Scan type:
-SS (TCP SYN scan half-open)
-st (TCP connection scan full open)
-SU (UDP scan)
-SP (ICMP scan)
-A//perform a full analysis of the target host
Options:
-N//Do not resolve host name
-P//Specify Port
Options
-C number//Specify the number of capture packets
-I interface name//Specify the captured NIC
-W file name//store the captured packet in a file
-A//convert to Acsii code display, slightly more readable
-r file name//read the file inside
Tcpdump-c 3-i eth0 (default)-w/a.txt-a
[Filter conditions]
Type: Host
NET Network
Port ports
Portrange Port Range
Direction
SRC: Source Address
DST: Destination Address
Protocol: TCP UDP IP WLAN ARP
Conditions can be combined: and (and) or (or) not (negate)
Example: Nmap-a-i eth0 TCP port and host 172.40.50.123 or host 172.40.50.148
The TCP protocol implemented here for detecting host 172.40.50.123 80 ports and 172.40.50.148 we can use () to raise or priority to implement 80 ports listening on two hosts () cannot be recognized by the system command, we need to use \ backslash to fetch Eliminate its definition
NMAP-A-i eth0 TCP port and \ (host 172.40.50.123 or host 172.40.50.148\)
Here is a simple script, using the location variable, where the shift to skip the previous definition, so our port port is not entered into the definition of IP address, grep-q meaning to block this output if the open field so return value echo $? =0 made a judgment, you can write a script according to your own requirements.
#!/bin/bash
Port=$1
Shift
For IP in $*
Do
Nmap-n-ss-p $port "172.40.58. $ip" | Grep-q Open
If [$?-eq 0];then
echo "172.40.58. $ip Port $port is open"
Else
echo "172.40.58. $ip Port $port is down"
Fi
Do
The shell script realizes the network scan Automatic Packet capture protocol analysis Nmap