Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

I am trying to find the live hosts on my network using nmap. I am scanning the network in Ubuntu using the command sudo nmap -sP 192.168.2.1/24. However, i am unable to find the live hosts. I just get the network address and my own PC as alive. When I see the DHCP client list through my browser (my router can be accessed via browser using my network IP), I get around 10 live hosts on the network. Can anyone tell me the reason why this could be happening and how do I find the live hosts on my network?

share|improve this question
2  
I usually do this nmap -sn 192.168.2.0/24, sn= disable port scan. –  HamZa May 19 '13 at 20:21
1  
@HamZaDzCyberDeV Yes, -sn is the new standard argument, but it used to be -sP, so @TheRookierLearner's command should still work. –  bonsaiviking May 20 '13 at 14:21
    
-sn is the same as -sP, as mentioned here: github.com/nmap/nmap/blob/master/docs/nmap.1#L402 –  Shurane Dec 18 '13 at 1:51
add comment

3 Answers 3

up vote 26 down vote accepted

This is the simplest way of performing host discovery with nmap.

nmap -sP 192.168.2.1/24

Why does it not work all the time ?

When this command runs nmap tries to ping the given IP address range to check if the hosts are alive and if ping fails it tries to send syn packets to port 80 (SYN scan). This is not hundred percent reliable because modern host based firewalls block ping and port 80. Windows firewall blocks ping by default. The hosts you have on the network are blocking ping and the port 80 is not accepting connections. Hence nmap assumes that the host is not up.

So is there a workaround to this problem?

Yes. One of the options that you have is using the -P0 flag which skips the host discovery process and tries to perform a port scan on all the IP addresses (In this case even vacant IP addresses will be scanned) . Obviously this will take a large amount of time to complete the scan even if you are in a small (20-50 hosts) network. but it will give you the results .

The better option would be to specify custom ports for scanning. Nmap allows you to probe specific ports with SYN/UDP packets. It is generally recommended to probe commonly used ports e.g. TCP-22 (ssh) or TCP-3389 (windows remote desktop) or UDP-161 (SNMP).

sudo nmap -sP -PS22,3389 192.168.2.1/24 //custom TCP SYN scan
sudo nmap -sP -PU161 192.168.2.1/24 //custom UDP scan

N.B. even after specifying custom ports for scanning you may not get an active host. A lot depends on how the host is configured and which services it is using. So you just have keep probing with different combinations.Remember, do not performs scans on a network without proper authorization.

update: When scanning a network you can never be sure that a particular command will give you all the desired results. The approach should be to start with basic ping sweep and if it doesn't work try guessing the applications that may be running on the hosts and probe the corresponding ports.The Idea of using Wireshark is also interesting. you may want to try sending ACK packets.

nmap -sP -PA21,22,25,3389 192.168.2.1/24 //21 is used by ftp
share|improve this answer
    
Although I believe that this is due the firewall blocking the ping scans, the above commands didn't help. Even the -P0 flag didn't work. –  TheRookierLearner May 19 '13 at 21:59
    
I really don't know what's happening but the command nmap -sP -PS 192.168.2.1/24 is working (the above command is also working; so answer accepted) and that too under Windows. I don't know what's wrong with Ubuntu. May be I need to check the iptables. –  TheRookierLearner May 20 '13 at 4:08
2  
one thing that's worth noting is that when you're in the same broadcast domain as the hosts you're scanning, nmap uses ARP instead of ICMP/SYN scanning –  Rоry McCune May 20 '13 at 11:43
1  
-P0 does not "try to scan all the ports of a system to check if it is up." Instead, it skips host discovery, reporting everything as up, and performing whatever port scans you have requested on every IP. Also, as @RoryMcCune notes, Nmap should send ARP requests for this type of scan. Use nmap --iflist to check what Nmap thinks about your routing table; it's possible that it is confused and not sending the right probes. If you can't get an ARP reply from an IP, you can't send a TCP or UDP packet, either. –  bonsaiviking May 20 '13 at 14:32
1  
I guess what @Mayank-Sharma meant was not -P0 but was -PO which sends a IGMP, ICMP and IP-in-IP packets and not scan all the ports. However, I'm not sure. –  TheRookierLearner May 20 '13 at 18:26
show 2 more comments

Wireshark is cool too.

You might want to check out Wireshark. It logs all of the traffic on the local network. It will tell you which nodes are broadcasting. You can also see what is being transmitted. It's available in the Ubuntu Software Center.

Additionally here's a link about installing Wireshark on Ubuntu via command line.

In regard to the traffic that shows in your DHCP routing tables remember that a lot of Virtual Machines will show up as separate machines in the list. Anything that's connected to your network usually within the default 24 hour lease time (for most WiFi Routers) will still show in the list. You might want to check for the duration of the leases in the router. It might tell you if someone's on your network overnight. On some devices that have dual NICs or a NIC and a Wireless Card they'll show up twice if both interfaces are enabled.

Other things that a lot of people forget about being on the network:

  • Managed Switches
  • Some printers
  • Server remote management cards
  • Cell Phones
  • Tivo and other DVRs
  • Apple TVs
  • Some Televisions
  • DVD players
  • Network A/V Receivers
  • Playstations, XBox, Etc.
  • Portable Gaming devices
  • Ipads and other tablets
  • Ipods and music players
  • PDAs
  • IP Phones like Magic Jack Plus

About 6 years ago at the office I was working in our little 3mb connection was down to 128k because of all of the excess traffic. The owners wanted to know if it was possible to see what was going on. The old part time IT guy shrugged his shoulders because not all of the traffic was going through their Windows 2000 server. He checked the routing tables and traffic logs in the server and saw nothing. They weren't using a router strangely enough, so anything on the network could get an address from the modem. The routing tables he looked at in the server were only for static mappings that existed a couple of years prior. I noticed they weren't on the same subnet. Then I showed them DHCP wasn't on in the server.

I found all of the traffic coming in after hours on an overnight sweep with Wireshark. One of my coworkers was unknowingly hosting a Japanese sex site on his machine. The attackers had rooted his machine after he installed a backdoor which came along with a cracked version of a high-end video editing software. We also found out they were running Tor, demonoid, and bitTorrent on various machines in different departments at different times. Wireshark found everything. Next day internet was up to full speed... we also installed a router.

If you're not up for Wireshark you might also want to try tcpdump.

share|improve this answer
1  
Although I certainly agree wireshark is an awesome tool, it's far from the best choice to solve this case, especially if there's a substantial amount of traffic it's hard to find all unique hosts. –  Teun Vink May 19 '13 at 21:14
1  
@TeunVink A note on finding unique hosts. ask.wireshark.org/questions/4827/… –  AbsoluteƵERØ May 19 '13 at 21:37
    
@AbsoluteƵERØ - That was a very valuable input indeed. I actually used Wireshark to check if the packets that nmap was trying to send were reaching the network or being blocked by the Windows Firewall. Turns out they weren't being blocked on Windows. I've to try on Ubuntu though. –  TheRookierLearner May 20 '13 at 18:30
add comment

The easiest way to check this is to verify the ARP-tables after doing the ping sweep using nmap:

arp -a -n

This lists all hosts which responded to an ARP query, even the ones which filter ICMP.

share|improve this answer
    
The results of this command will vary depending on the currently existing ARP entries. –  AbsoluteƵERØ May 19 '13 at 21:33
    
This command gets me 5 records on my local network when I have 16 open nodes. –  AbsoluteƵERØ May 19 '13 at 21:39
    
Did you do a ping sweep using nmap before checking your arp tables? If not, hosts might be missing. Every node in the network should at least answer to an ARP request when you generate traffic towards it doing the ping sweep. –  Teun Vink May 19 '13 at 21:48
1  
Devices like Tivo do not respond to pings. Devices like ipads, iphones, and ipods may not respond to a ping sweep if their screens are locked. Additionally devices running something other than TCP/IP will not respond to a ping sweep. Wireshark will still show the traffic (like IPX). Additionally different subnets will also show. –  AbsoluteƵERØ May 19 '13 at 22:27
    
Try using Cain and Able on Windows and use the ARP tools there... –  NULLZ May 19 '13 at 22:50
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.