Page 1 of 1
Dynamic IP setup
Posted: Sun Dec 09, 2012 9:28 pm
by xtcraver2003
Setting up the server to run on a dynamic ip is a real son of a B^&*# at the moment. I can auto update pretty much everything via ddns. The real issue comes with the Zone ip settings. Is there a way i could auto update the zone ip with an executable?
Re: Dynamic IP setup
Posted: Mon Dec 10, 2012 6:44 am
by whasf
Yes
Re: Dynamic IP setup
Posted: Mon Dec 10, 2012 8:02 am
by xtcraver2003
And could I get the name of the executable?
Re: Dynamic IP setup
Posted: Mon Dec 10, 2012 9:37 am
by whasf
It's whatever you make it. We don't have a program, you'd have to write your own.
Re: Dynamic IP setup
Posted: Mon Dec 10, 2012 11:24 pm
by PrBlahBlahtson
You'd basically need something that:
1) detects when the IP changes
2) calculates the new zoneip
3) connects to the SQL server (probably 127.0.0.1)
4) update 'zone_list' set zoneip = ...
5) restart servers
Insert: "Hell, I bet I could do that with PHP."
Re: Dynamic IP setup
Posted: Sat Dec 22, 2012 12:38 pm
by Vanyel
xtcraver2003 wrote:Setting up the server to run on a dynamic ip is a real son of a B^&*# at the moment. I can auto update pretty much everything via ddns. The real issue comes with the Zone ip settings. Is there a way i could auto update the zone ip with an executable?
I haven't used it in quite some time as I prefer to do the math myself but doesn't the DSP Server Updater now set the IP for you?
Re: Dynamic IP setup
Posted: Mon Dec 24, 2012 9:31 am
by Melodina
Here.
On windows, edit db.config.php to your DB setup. Then run updatezip.bat
On unix, just run php update_zonip.php after editing the db.config.php
Here is what the code looks like.
Code: Select all
//
// db.class.php --> DB Functions
// db.config.php --> DB Connection Information
//
$getIP = explode(": ", trim(shell_exec("lynx --dump www.my-ip-address.com | grep \"Your IP is\"")));
echo "The IP Address we detected is: ".$getIP[1].". (From my-ip-address.com)\n";
// calc zone ip
$zstring = explode(".", $getIP[1]);
$zip = $zstring[0] + ($zstring[1] * 256) + ($zstring[2] * 65536) + ($zstring[3] * 16777216);
echo "Zone IP: ".$zip."\n";
// update db
require_once 'db.class.php';
$db = new Db();
echo "Run query on db: UPDATE zone_settings SET zoneip='".$zip."';\n";
$db->updateDb("UPDATE zone_settings SET zoneip='".$zip."';");
echo "Settings have been updated\n";
The package is big becase of windows deps. (Lynx, grep, and php)
Make this automated? Crontab in unix, or Windows Scheduler.