I have a Raspberry Pi that communicates with two other devices on the same LAN. Because it's not my network I can't give the devices static IPs. When they roll over I have to find the new IPs and update them in two configobj configuration pages.
I'd like to write a program that scans the network for the two devices and when they change IPs, modify the two configuration files with the new addresses and restart the programs that need them.
I know how to use configobj to update the .conf files with the new IPs, but how do I get the IP address from the known MAC addresses?
The two devices can't be modified to report their address so I have to detect it from the raspberry pi.
So what I need to know is:
- Can I detect an IP in python using a MAC address, and
- How can I restart a program from another python program? In the Linux console I would use 'sudo systemctl restart weewx'. Can I do that from within Python?
Thanks!