• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
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
  • YouTube
  • Free Arduino Course
  • Recommendations
  • Contact

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
FacebookTweetPin
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
FacebookTweetPin

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 Maker Hacks on Ko-Fi and 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
  • Twitter
  • Instagram
  • YouTube

Join the Newsletter

Sign up and get a free Arduino course + more!

Subscription Form

Recently Popular

  • xTool S1 Review
  • xTool P2 Review (first look)
  • IKIER K1 Pro Max Review
  • Gweike Cloud Review
  • How to choose the right 3D printer for you
  • Glowforge Review – Glowforge Laser Engraver Impressions, Plus Glowforge Versus Leading Laser Cutters
  • Flux Ador
  • Prusa i3 Mk3S Review
  • Best 3D Printing Facebook Groups
  • xTool D1 Pro Laser Cutter Review
  • Elegoo Mars Review – Review of the Elegoo Mars MSLA Resin 3D Printer
  • Glowforge ‘Pass-Through’ Hack: Tricking the Front Flap of the Glowforge with Magnets to Increase Capacity
  • How to Make a DIY “Internet of Things” Thermometer with ESP8266/Arduino
  • Wanhao Duplicator i3 Review
  • IKEA 3D Printer Enclosure Hack for Wanhao Di3
  • Creality CR-10 3d printer review – Large format, quality output, at a low price!
  • 3D Printed Tardis with Arduino Lights and Sounds
  • Anet A8 Review – Budget ($200 or less!) 3D Printer Kit Review
  • Make your own PEI 3D printer bed and get every print to stick!
  • Upgrading the Wanhao Di3 from Good to Amazing
  • How to Install and Set Up Octopi / Octoprint
  • Creality CR-10 S5 Review
  • Glowforge Air Filter Review
  • Thunder Laser Review

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 resin Reviews technology tips xTool Lasers

.

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