Top 30 Nmap Commands for Network Admins
Top 30 Nmap Commands for Network Admins
nixCraft
Linux Tips, Hacks, Tutorials, And Ideas In Blog
The purpose of this post is to introduce a user to the nmap command line
tool to scan a host and/or network, so to find out the possible vulnerable
points in the hosts. You will also learn how to use Nmap for offensive and
defensive purposes.
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 1 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
nmap in action
It was originally written by Gordon Lyon and it can answer the following
questions easily:
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 2 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
+---------+
+---------+ | Network | +-----
---+
| server1 |-----------+ swtich +---------
|server2 |
+---------+ | (sw0) | +-----
---+
+----+----+
|
|
+---------+----------+
| wks01 Linux/OSX |
+--------------------+
Where,
See:
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 3 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
Sample outputs:
nmap 192.168.1.1-20
nmap 192.168.1.*
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 4 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
nmap 192.168.1.0/24
The -iL option allows you to read the list of target systems using a text file.
This is useful to scan a large number of hosts/networks. Create a text file
as follows:
Sample outputs:
server1.cyberciti.biz
192.168.1.0/24
192.168.1.1/24
10.1.2.3
localhost
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 5 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
nmap -A 192.168.1.254
nmap -v -A 192.168.1.1
nmap -A -iL /tmp/scanlist.txt
nmap -6 IPv6-Address-Here
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 6 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
nmap -6 server1.cyberciti.biz
nmap -6 2607:f0d0:1002:51::4
nmap -v A -6 2607:f0d0:1002:51::4
Sample outputs:
nmap -F 192.168.1.1
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 7 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
nmap --iflist
Sample outputs:
**************************ROUTES**************************
DST/MASK DEV GATEWAY
10.0.31.178/32 ppp0
209.133.67.35/32 eth0 192.168.1.2
192.168.1.0/0 eth0
192.168.121.0/0 vmnet1
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 8 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
192.168.179.0/0 vmnet8
169.254.0.0/0 eth0
10.0.0.0/0 ppp0
0.0.0.0/0 eth0 192.168.1.2
Sample outputs:
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 9 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
You can identify a remote host apps and OS using the -O option:
nmap -O 192.168.1.1
nmap -O --osscan-guess 192.168.1.1
nmap -v -O --osscan-guess 192.168.1.1
Sample outputs:
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 10 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 11 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
Sample outputs:
#19: Scan a host using TCP ACK (PA) and TCP Syn
(PS) ping
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 12 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
This scan bypasses firewalls and filters that only screen TCP:
### Find out the most commonly used TCP ports using TCP c
onnect scan (warning: no stealth scan)
### OS Fingerprinting ###
nmap -sT 192.168.1.1
### Find out the most commonly used TCP ports using TCP AC
K scan
nmap -sA 192.168.1.1
### Find out the most commonly used TCP ports using TCP Wi
ndow scan
nmap -sW 192.168.1.1
### Find out the most commonly used TCP ports using TCP Ma
imon scan
nmap -sM 192.168.1.1
Most popular services on the Internet run over the TCP protocol. DNS,
SNMP, and DHCP are three of the most common UDP services. Use the
following syntax to find out UDP services:
Sample outputs:
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 13 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
This type of scan allows you to determine which IP protocols (TCP, ICMP,
IGMP, etc.) are supported by target machines:
The following scan types exploit a subtle loophole in the TCP and good for
testing security of common attacks:
See how to block Xmas packkets, syn-floods and other conman attacks
with iptables.
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 14 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
The -f option causes the requested scan (including ping scans) to use tiny
fragmented IP packets. The idea is to split up the TCP header over
several packets to make it harder for packet filters, intrusion detection
systems, and other annoyances to detect what you are doing.
nmap -f 192.168.1.1
nmap -f fw2.nixcraft.net.in
nmap -f 15 fw2.nixcraft.net.in
The -D option it appear to the remote host that the host(s) you specify as
decoys are scanning the target network too. Thus their IDS might report
5-10 port scans from unique IP addresses, but they won’t know which IP
was scanning them and which were innocent decoys:
nmap -n -Ddecoy-ip1,decoy-ip2,your-own-ip,decoy-
ip3,decoy-ip4 remote-host-ip
nmap -n -D192.168.1.5,10.5.1.2,172.1.2.4,3.4.2.1
192.168.1.5
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 15 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
Sample outputs:
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 16 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
$ sudo zenmap
Sample outputs
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 17 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
1. How to use psad tool to detect and block port scan attacks in real
time.
2. Debian / Ubuntu Linux: Install and Configure Shoreline Firewall
(Shorewall).
3. CentOS / Redhat Iptables Firewall Configuration Tutorial.
4. Linux: 20 Iptables Examples For New SysAdmins.
5. 20 Linux Server Hardening Security Tips.
References:
The nmap command has many more options, please go through man
page or the documentation for more information. What are some of your
favorite nmap command-line tricks? Share your favorite tips, tricks, and
advice in the comments below.
25 comment
With
WIRESHARK – I’m able to define the IP-address
NMAP – I’m able to define the MAC-addres (ping doesn’t work yet)
ARP – I get the IP-address and MAC-address
but I’ve to put my interface in the same netmask range as the host, before
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 18 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
Any suggestions.
Thks
What is the best way to go about finding all ports being used by MySQL
for clustering purposes?
I am on Linux platform with MySQL NDB 5.7. I am trying to monitor all
traffic related to MySQL clustering – between data nodes, management
node and sql nodes. To that end, I used netstat to list all open ports
listening on my machine before starting MySQL cluster. Then, I started
MySQL cluster and ran netstat again. I assumed that the ports that were
listening the second time around, but not the first time, were related to
MySQL clustering.
But there are two problems with this. First, there could be ports opened
by other processes between the two netstat runs. Second, MySQL might
open other ports after I ran the netstat command the second time.
What is the best way to go about finding all ports being used by MySQL
for clustering purposes?
I believe ephemeral ports are picked dynamically, so perhaps if I knew all
the MySQL clustering related processes that would be running, I can
figure out every port that they are using. Pointers will be very welcome.
I found this article very helpful. I’m definitely saving this Bookmark for
future reference. I’ve been using “nmap -sP 192.168.1.0/24” for a very long
time just to see which clients are online. OS Detect is also very useful in
Armitage and Metasploit. Long live Linux!
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 19 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
very interreting
The question is how to monitor people who use/run NMAP and create a
report about it …
Thanks
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 20 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
One of the uses for nmap, as stated above, is to “find out if the system is
infected with malware or virus.” How is this accomplished? Are you
referring to using the script, http-malware-host?
Several places mentioned the -PN switch, but this is depreciated, use -Pn
instead.
-Pn (No ping) .
This option skips the Nmap discovery stage altogether. Normally, Nmap
uses this stage to determine active machines for heavier scanning. By
default, Nmap only performs heavy probing such as port scans, version
detection,
or OS detection against hosts that are found to be up. Disabling host
discovery with -Pn causes Nmap to attempt the requested scanning
functions against every target IP address specified. So if a class B target
address
space (/16) is specified on the command line, all 65,536 IP addresses are
scanned. Proper host discovery is skipped as with the list scan, but
instead of stopping and printing the target list, Nmap continues to
perform
requested functions as if each target IP is active. To skip ping scan and
port scan, while still allowing NSE to run, use the two options -Pn -sn
together.
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 21 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
and -PN..
Hi,
Thanks again
Nice Info,,,
hello pleas i have download nmap and install , but idnt know wher to
even run it
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 22 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
Wow ! Pretty good and easy. Thank you so much for the great topic, I’m a
huge fan of nmap/zenmap
GET
NIXC
RAFT
IN
YOUR
INBO
X IT’S
FREE
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 23 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
FEATURED
ARTICLES:
Top 30 Nmap
Command Examples
For Sys/Network
Admins
20 Linux System
Monitoring Tools
Every SysAdmin
Should Know
20 Linux Server
Hardening Security
Tips
Linux: 20 Iptables
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 24 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
Top 20 OpenSSH
Server Best Security
Practices
Top 20 Nginx
WebServer Best
Security Practices
20 Examples: Make
Sure Unix / Linux
Configuration Files
Are Free From Syntax
Errors
15 Greatest Open
Source Terminal
Applications Of 2012
My 10 UNIX
Command Line
Mistakes
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 25 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
First 64 bit
Raspberry P
How to chec
port is in us
HowTo: Find
Fin
DNS Server
30 Cool Ope
Source
Software...
dstat: Moni
Linux System
Syste
Linux: Chec
Speed and T
nmap Comm
Scan A Sing
FOLLOW US
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 26 of 27
Top 30 Nmap Command Examples For Sys/Network Admins – nixCraft 4/21/17, 09:01
Google+
DONATIONS
Hosted by Linode DNS & CDN by Cloudflare and StackPath Designed and Developed by Prospect One
https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/ Page 27 of 27