dynamic IP

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
djesus
Posts: 3
Joined: Mon Dec 15, 2003 7:44 am

dynamic IP

Post by djesus »

Hi all, I have zoneminder in a dsl with dynamic IP to know the ip I have make a script:

Code: Select all

#!/bin/sh

newip=$(/usr/bin/lynx -source http://www.showmyip.com | /bin/grep TITLE | /usr/bin/cut -f 4-d'>' | /usr/bin/cut -f5 -d' ')
echo "$newip" > /tmp/newip
diff /tmp/ipnow /tmp/newip &> /dev/null
if [ $? -eq 0 ]
then
echo The IP hasn't changed
else
echo "UPDATE Monitors SET Host='"$newip"' WHERE id=1;" > /tmp/updateip.sql
mysql -h hostserverzm -uzmuser -pzmpassword zmdb < /tmp/updateip.sql &> /dev/null
if [ $? -eq 0 ]
then
echo $newip > /tmp/ipnow
else
echo DB FAILED 
fi
fi
This script is in all my computer with zoneminder, and in a main server have a zoneminder to connect to all the "client zoneminder". The zoneminder server must have static ip because is the reference for the clients.

The id is the Monitor id of zoneminder server
The hostserverzm,zmuser,zmpassword,zmdb must have the correct values for the zoneminder server.

This script can be in cron for example each 15 minutes to get always the correct ip.

Best Regards
maciekc
Posts: 150
Joined: Wed Feb 23, 2005 9:21 pm
Location: Czestochowa, POLAND

Post by maciekc »

Why not to use service like no-ip or dyndns?
And set domain name in monitor settings.
Post Reply