Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Dynamic DNS for your GoDaddy domains

by stevieb (Canon)
on May 17, 2022 at 18:26 UTC ( #11143954=CUFP: print w/replies, xml ) Need Help??

With its API, GoDaddy makes it easy to do dynamic DNS updates for your domain's hostnames. I made it easy to do with Perl with Net::DynDNS::GoDaddy (which uses my new Addr::MyIP to get your current external IP address). I'll give an example, then an example use of the distribution's packaged binary script.

use Addr::MyIP; use Net::DynDNS::GoDaddy; my $hostname = 'home'; my $domain = 'example.com'; my $current_host_ip = host_ip_get($hostname, $domain); my $my_ip = myip(); if ($current_host_ip ne $my_ip) { host_ip_set($host, $domain, $my_ip); }

Simple. The library requires a godaddy_api.json file in your home directory (MacOS, Unix or Windows, the software has 100% test coverage on all systems) that looks like this:

{ "api_key" : "api_key", "api_secret" : "api_secret" }

Using the binary we'll install when you install the library, it will prompt you for this information on its initial run:

> update-ip home example.com Please enter your GoDaddy API key and hit ENTER: ...api_key... Please enter your GoDaddy API secret and hit ENTER: ..api_secret... Updated record for 'home.example.com' from x.x.x.x to x.x.x.x

...after the initial run, it won't prompt anymore:

> update-ip home example.com Not updating the 'home.example.com' record, IPs are the same

You can specify the IP if you don't want to use your current public-facing one we automatically get for you:

> update-ip home example.com 10.7.10.2

The most useful use for me is to have multiple hostnames ('home', 'office', 'roaming' etc) and just run the program through cron:

# Home storage server */15 * * * * update-ip home example.com >> /tmp/update-home_cron.log 2 +>&1

My laptop:

*/15 * * * * update-ip roaming example.com >> /tmp/update-roaming_cron +.log 2>&1

Usage:

Usage: update-ip host domain.name [ip.addr]

Have fun!

-stevieb

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://11143954]
Approved by kcott
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2023-03-31 03:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (74 votes). Check out past polls.

    Notices?