Simple script that helps identifying birboxes on a wired network
.gitignore | ||
main.py | ||
README.md |
IoT IP Beacon
Simple daemon that helps you find your lost IoT device on the open sea of IP addresses.
How it works?
This simple daemon broadcast some basic system information every 10 seconds to the local subnet.
These information are the following:
- Configured IP address of the sending interface
- Hostname
- Birbox software version
- Uptime
The messages is formed as the following UTF-8 encoded string:
BIRBOX|{ipaddr}|{hostname}|{version}|{uptime in seconds}
The messages are broadcast to the 6969 UDP port.
All you need is to listen to such packets on the network, so you can find your lost IoT device in no time.
Usage
Just start the script as a system daemon. You may have to change the interface name.
Receiver example
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
client.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
client.bind(("", 6969))
while True:
data, addr = client.recvfrom(1500)
src_ip = addr[0]
try:
header, self_ip, hostname, version, uptime = data.decode().split('|')
except ValueError:
continue
if header == 'BIRBOX':
print("IP Address:",src_ip)
if src_ip != self_ip:
print("Warning! Reported and origin IP differ! Reported ip:",self._ip)
print("Hostname:", hostname)
print("Version:", version)
print("System uptime:", uptime,'sec')