Dynamic IP setup

Post Reply
xtcraver2003
Posts: 5
Joined: Wed Nov 21, 2012 12:01 am

Dynamic IP setup

Post by xtcraver2003 » Sun Dec 09, 2012 9:28 pm

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?

User avatar
whasf
Site Admin
Posts: 1312
Joined: Thu Jul 19, 2012 9:11 pm

Re: Dynamic IP setup

Post by whasf » Mon Dec 10, 2012 6:44 am

Yes
-- Whasf

xtcraver2003
Posts: 5
Joined: Wed Nov 21, 2012 12:01 am

Re: Dynamic IP setup

Post by xtcraver2003 » Mon Dec 10, 2012 8:02 am

And could I get the name of the executable? :)

User avatar
whasf
Site Admin
Posts: 1312
Joined: Thu Jul 19, 2012 9:11 pm

Re: Dynamic IP setup

Post by whasf » Mon Dec 10, 2012 9:37 am

It's whatever you make it. We don't have a program, you'd have to write your own.
-- Whasf

PrBlahBlahtson
Developer
Posts: 539
Joined: Sun Jul 22, 2012 12:17 am

Re: Dynamic IP setup

Post by PrBlahBlahtson » Mon Dec 10, 2012 11:24 pm

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."

Vanyel
Posts: 31
Joined: Sun Jul 22, 2012 10:58 am
Location: New Brunswick, Canada

Re: Dynamic IP setup

Post by Vanyel » Sat Dec 22, 2012 12:38 pm

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?

Melodina
Posts: 29
Joined: Mon Jul 23, 2012 9:20 am

Re: Dynamic IP setup

Post by Melodina » Mon Dec 24, 2012 9:31 am

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.
Attachments
auto_zoneip.zip
PHP Script, PHP x64, mysql lib, grep, lynx
(5.01 MiB) Downloaded 348 times

Post Reply