• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
  • YouTube
  • MakerWorld
  • Instagram
  • Threads
  • Bluesky
  • Mastodon
  • Facebook
makerhacks-logo

Maker Hacks

Ideas, news & tutorials for makers and hackers – Arduino/Raspberry Pi, 3D printing, robotics, laser cutting, and more

  • Home
  • About
  • 3D Printing
  • Laser Cutting
  • CNC
  • Programming
  • Free Arduino Course
  • Free Robotics Course
  • Recommendations

Detect (and list) Raspberry Pi and other boards on your network

You are here: Home / Software and Programming / Detect (and list) Raspberry Pi and other boards on your network
Author: Chris Garrett

I am in the fun position of having a Raspberry Pi project to build for my day job. It brought to light a familiar challenge of how to trouble-shoot and connect to headless Raspberry Pi boards when you don’t necessarily know the host or IP address.

Instead of grabbing a HDMI cable (and converter), monitor, and keyboard, run this Python script from a familiar command line (might need to run as sudo) to get a color-coded output:

Code

You will need python-nmap module installed.

Get the full code here at this gist.

The bulk of the heavy lifting is in these lines:

nm = nmap.PortScanner()
nm.scan('10.0.1.0/24', '22')

There we are scanning my local IP addresses and the SSH port, port 22.

Once done (can take a few seconds, depending on the size of your network), you can go ahead and iterate over the results:

for host in nm.all_hosts():

(I sort the results but as the IP addresses are not padded with 0, the order is not exactly numerical even after sorting.)

All that is left is to output the info we want, along with a sprinkle of ANSI color coding for good measure:

print(u"\u001b[37m" + "{} ({}) {}\u001b[0m".format(nm[host].hostname(), host, mac))

This sets the forecolor to white, outputs the hostname, IP, and MAC address, then resets the text color.

Extending the code

Of course, this is useful for more than just seeing what your Pi is called or the IP address. Gathering hostnames and mac address could be used for logging the devices on your wifi network over time, or even announce your entry to the building (example previously using Bluetooth).

Category: Software and ProgrammingTag: esp8266, Hacks, python, raspberry pi

About Chris Garrett

Marketing nerd by day, maker, retro gaming, tabletop war/roleplaying nerd by night. Co-author of the Problogger Book with Darren Rowse. Husband, Dad, 🇨🇦 Canadian.

Check out Retro Game Coders for retro gaming/computing.

☕️ Support Chris on Ko-Fi to get exclusive content and rewards!

Previous Post:USB Keyboard Emulation with the Raspberry Pi Zero
Next Post:Build a Macro Keyboard “Stream Deck” with Raspberry Pi Zero and Hyperpixel 4.0 Graphical Touch Screen

Sidebar

  • Facebook
  • Instagram
  • YouTube

Featured Posts

  • CyberBrick Review + Getting Started
  • xTool M2 Review
  • xTool F2 Ultra Review
  • xTool F2 Review
  • xTool S1 Review
  • Anycubic Kobra S1 Combo Review
  • Makera Z1 Pro Review
  • CNC Buyer's Guide
  • eufyMake E1 UV Printer Review
  • eufyMake Purifier P1
  • Z80 on a Breadboard
  • OpenSCAD MakerWorld Customizer

30 Days to Arduino

Arduino Tutorials
  • 3D Printing
  • CNC
  • Electronics and Hardware
  • Laser Cutting
  • News and Reviews
  • Software and Programming

arduino budget cad cnc diode laser glowforge Hacks Ideas laser cutter linux Makes making python raspberry pi Reviews technology tips xtool xTool Lasers

  • YouTube
  • MakerWorld
  • Instagram
  • Threads
  • Bluesky
  • Mastodon
  • Facebook

.

Maker Hacks Blog Copyright © 2026 · All Rights Reserved · Privacy Policy