Monthly Archives: September 2016

How to Find Your Raspberry Pi in Your Network Using Nmap

Bildschirmfoto 2016-09-09 um 09.01.26

sudo nmap -sn 192.168.1.0/24 | grep -B 2 Raspberry

First you have to find your current IP address and netmask. If you don’t know what a netmask is, chances are you have a 24-bit netmask (which you may have seen in this format: 255.255.255.0).

The -sn option in nmap disables port scanning. This allows for a much faster, host discovery-only scan. After nmap is done, we are piping its output into grep, so that we can filter out our Raspberry Pi devices. The -B option stands for “before”, which means that grep will include the upper two lines of the output too. Without them we would only see the MAC address.

If you put this command in our ~/.bash_profile file with an alias, we can simply type “findpi” into a terminal and are done (see screenshot above)!

alias findpi='sudo nmap -sn 192.168.1.0/24 | grep -B 2 Raspberry'

Store a Semantic Versioning String in a 32-Bit Integer

Semantic Versioning is a specification, which describes how version strings should be handled. It works by having MAJOR, MINOR and PATCH versions in a dot-separated string. Example:

MAJOR.MINOR.PATCH

2.5.3

I needed to store this string in a single 32-bit integer due to system limitations, so I wrote two handy, well-documented functions in ES6. Let’s convert the version string “2.5.3” into an integer:

let numericVersion = convertVersionToInt32('2.5.3'); // 3150850
let version = convertInt32VersionToString(numericVersion); // "2.5.3"