Reference and guides to build kick ass raspberry pi projects.
View the Project on GitHub codingforentrepreneurs/Pi-Awesome
nmap
Find devices on network with macOS or Linux. Looking for Windows?
Install nmap via homebrew
brew install nmap
sudo apt install nmap -y
HOST_IP=$(ipconfig getifaddr en0)
Run
echo $HOST_IP
to see the result. Mine is192.168.86.20
HOST_IP=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
nmap
to find other hosts/devices on your networkTARGET_HOST=raspberry
nmap -sP $HOST_IP/24 | grep "${TARGET_HOST}"
The | grep "${TARGET_HOST}
is optional but helps narrow our search to raspberry
in this case.
The above command (in my case) maps to:
nmap -sP 192.168.86.20/24 | grep "raspberry"
So you can see the final result without environment variables.
macOS / zshell
sudo nano ~/.zshrc
Linux / bash
sudo nano ~/.bashrc
Add the following line:
alias devices='nmap -sP $(ipconfig getifaddr en0)/24'
Save and close.
Run source ~/.zshrc
/ source ~/.bashrc
or open a new terminal window.
devices