Automatically monitoring your home network

The practical Nmap network scanner is used not only by the bad boys in exciting thrillers to detect intrusion targets [1], it also tells admins what devices are actually reachable on their home networks. If you regularly launch Nmap on your subnets and compare the output, you can keep track of newly added or removed devices and proactively ward off nasty surprises.

The fact that nmap has a -oX option that tells it to output the results in XML format is something I was unaware of until I read an Nmap manual that was recently released as a Kindle book [2]. Because an Nmap scan across multiple networks can take a few minutes, I got the idea of building a daemon that finds all the nodes once an hour, keeps the data in memory, and sends it via a built-in web server to requesting clients, such as a Nagios script.

Lean Script Defines the Search Space

The script in Listing 1 [3] does this, mainly by resorting to the NmapServer module (which is loaded in line 7 and discussed later on) and its start() method. Before the call, it defines the IP range of the home network that nmap needs to scan in the constructor – in this case the subnets are 192.168.14.x and 192.168.27.x.

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Nmap Workshop

    In "The Matrix Reloaded," Trinity uses Nmap to hack into the power grid to pave Neo's way to the architect of the virtual world. However, the port scanner is also ideal for more mundane purposes – such as discovering vulnerabilities in your domestic network.

  • Nmap Scripting

    Nmap is rolling out a new scripting engine to automatically investigate vulnerabilities that turn up in a security scan. We’ll show you how to protect your network with Nmap and NSE.

  • Scanning with Zenmap

    Discover your network with the user-friendly Zenmap network scanner.

  • Nmap Methods

    How does the popular Nmap scanner identify holes in network security? In this article, we examine some Nmap analysis techniques.

  • Charly's Column

    Many tools keep growing with each new version, but Nmap 4.00 has lost weight thanks to the Diet-Nmap project. The latest incarnation of Nmap is not only quicker, it is also more frugal with memory.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News