A full walkthrough guide to building a Raspberry Pi Network Monitor with Status Pages via Uptime Kuma and ARP Monitoring of Smart Home Devices.
Install Raspberry Pi OS 64-Bit Lite (Headless Version) using Raspberry Pi Imager
Alternatively Install Raspian 64-Bit Lite (Debian, Headless Version) using NOOBS
In this guide we recommend using the 1st letter of your first name followed by your last name.
For John Doe, your username would be jdoe.
After setup, the screen will go black. At this point you should restart manually.
Use sudo raspi-config
- Set Network SSID & Password
- Set Hostname
- Set Login Method
- Set Timezone
- Update the Raspberry Pi Configurator
sudo apt update && sudo apt upgrade -y
sudo reboot
Special Thanks to linuxHint: https://linuxhint.com/enable-ssh-server-debian/
sudo apt install openssh-server
sudo systemctl start ssh
Optional: At this point, you can connect over SSH and complete the remainder of the guide.
sudo systemctl enable ssh
sudo systemctl status ssh
sudo nano /etc/ssh/sshd_config
- Uncomment the PORT line set and the port to 2222 Once you’re done, press + X followed by Y and to save the sshd_config file.
sudo systemctl restart ssh
- New command to connect is ssh username@[Your Raspberry Pi IP Address] -p 2222
- Remember: you can find your [Your Raspberry Pi IP Address] by using
hostname -I
Optional: At this point, you will need to reconnect if you are currently connected over SSH.
curl -sSl https://get.docker.com | sh
sudo usermod -aG docker [Your Username]
sudo docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1
sudo docker ps -a
Access the login page at `[Your Raspberry Pi IP Address]:3001'
Remember: you can find your [Your Raspberry Pi IP Address] by using hostname -I
Example: `192.168.1.2:3001' You can type this directly into your browser
Remember to configure 2 Factor Authentication
An updated version of section VI can be followed using the instructions at https://github.com/RobertCSternberg/ARPNetworkMonitor
mkdir networkscanner && cd networkscanner
FROM nginx:alpine
RUN apk update && apk add --no-cache arp-scan
COPY run_scan.sh /run_scan.sh
RUN chmod +x /run_scan.sh
COPY nginx.conf /etc/nginx/nginx.conf
CMD /bin/sh -c "/run_scan.sh & nginx -g 'daemon off;'"
Note: To save after using nano, press ctrl + x, Y, then enter.
#!/bin/sh
while true
do
echo "<html><head><title>Arp Scan Results</title></head><body><h1>Arp Scan Results</h1>" > /tmp/index.html
echo "<p>Last updated: $(TZ='America/Chicago' date '+%B %d, %Y %I:%M:%S %p') Central Time US</p>" >> /tmp/index.html
echo "<pre>" >> /tmp/index.html
# Call the curl command here. Replace the URL with the one you want to call from Uptime Kuma Push Monitor
/usr/bin/curl "https://google.com" > /dev/null 2>&1
# Replace the arp-scan address with your network address and subnet mask. Most commonly 192.168.1.0/24
arp-scan 192.168.1.0/24 >> /tmp/index.html 2>> /tmp/arp-scan-errors.log
if [ $? -ne 0 ]; then
echo "Arp-scan failed. See /tmp/arp-scan-errors.log for details." >> /tmp/index.html
fi
echo "</pre></body></html>" >> /tmp/index.html
mv /tmp/index.html /usr/share/nginx/html/index.html
cp /usr/share/nginx/html/index.html /usr/share/nginx/html/index-copy.html
sleep 30
done
Note: To save after using nano, press ctrl + x, Y, then enter.
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
}
}
Note: To save after using nano, press ctrl + x, Y, then enter.
docker build -t networkscanner .
2. Run the docker image and start the container, set the container to auto-restart, allow connections to the root network, allow the docker user to run the processes related to the arp scan.
docker run --restart=always --network=host -d --cap-add=NET_RAW --cap-add=NET_ADMIN networkscanner
Access the ARP web server by visiting http://[Your Raspberry Pi IP Address]/
or test headless with curl http://[Your Raspberry Pi IP Address]/
Remember: you can find your [Your Raspberry Pi IP Address] by using hostname -I
Use sudo crontab -u root -e
* * * * * /usr/bin/curl "[PUSH URL]" > /dev/null 2>&1
@reboot /usr/bin/curl "[PUSH URL]" > /dev/null 2>&1
sudo raspi-config
sudo shutdown -h now
sudo Reboot
sudo apt-get update
sudo apt-get install nmap
-
Top 1000 ports
nmap [ip address to scan]
-
All ports
nmap -p- [ip address to scan]
-
Check all ports even if ping is blocked
nmap -p- -Pn [ip address to scan]
-
Advanced Scan of all ports (half-handshake, skip ping, all ports)
nmap -sS -Pn -p- [ip address to scan]
-
Check which service is using port
80
usingsudo netstat -tuln | grep :80
orsudo ss -tuln | grep :80
-
If nginx service is using port '80', stop the service using
sudo systemctl stop nginx
and prevent nginx from starting up when the system rebootssudo systemctl disable nginx
-
Check all docker containers using
sudo docker ps -a
or just check running docker containers usingsudo docker ps
-
Remove stopped docker containers using
sudo docker container prune
-
Start, Stop, or Remove a docker container using
sudo docker start [container id]
,sudo docker stop [container id]
, andsudo docker rm [container id]
-
To enter into a running Docker container to test commands use
docker exec -it [container id] /bin/sh