Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Nagios plugin to detect changed IP address of WRT54G router. - TIMTOWTDI

by tmiklas (Hermit)
on Feb 27, 2006 at 14:26 UTC ( #533025=note: print w/replies, xml ) Need Help??


in reply to Nagios plugin to detect changed IP address of WRT54G router.

Hmmm - very nice code and perl usage at all BIG ++

... but to get the same result you don't have to run such 'combinations'... maybe i should not write this as this is Perlmonks but using Perl should make our life easier... and sometimes not-using Perl does the same :-/

Fast and tested solution... register yourself with dyndns or no-ip system or anything like this (it's free)... and set your DNS properly:
hostname.my.domain. IN CNAME dynamic.update.domain. hostname.my.domain. IN MX 1 hostname.my.domain.
then point the MX to the same host (as shown above)... all of the systems provide free tools for updating it's entries... and to do it Perl-ish way, use Net::DNS::DynDNS :-)

The task now is to get the information about IP change no later than a few seconds after it has changed... without constantly querying the router or blindly updating the dns database without checking if it was necesery. Eventually your host will be inaccessible for some time (but anyway much shorter than waiting for the ISP staff to change the DNS entries and reload configuration).

I hope i won't get downvoted (too much) for describing non-Perl solution, hehe...

Greetz, Tom.
  • Comment on Re: Nagios plugin to detect changed IP address of WRT54G router. - TIMTOWTDI
  • Download Code

Replies are listed 'Best First'.
Re^2: Nagios plugin to detect changed IP address of WRT54G router. - TIMTOWTDI
by blue_cowdawg (Monsignor) on Feb 27, 2006 at 14:52 UTC
        Fast and tested solution... register yourself with dyndns or no-ip system or anything like this (it's free)... and set your DNS properly

    Your suggestion has merit. It does however miss the point of why I do what I do. My MX is for the domain that I have registered to myself. I don't want "dyndns" in the middle somwhere. I already pay folks for the privelege of using their machine to host my website, so why not also let them host my CNAME and MX?

    The good news is the DHCP assigned address changes infrequently enough that this approach that I'm using isn't a major PITA. If it ever became such I'd re-review my options and possibly implement something along the lines of what you suggest. When I first started hosting my own mailserver and farming out my MX DNS entry DynDNS was not an ooption.

    In fact, the incidence of my IP address changing happens so infrequently that I've even considered adding to this script (and it's predecessor which wasn't as nice as this one) logic to automatically create the trouble ticket with my hosting provider for them to update the DNS entry.

    I'm just waiting for the day when T1 lines become "affordable" and I can host my whole domain myself. Yeah... right... dream on...


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
      Cheap but equally sad solution I used once in a similar situation was to have a cron hit a page on my external website every X minutes/hours - then update my external records as needed via the ping-page.



      "I have never written bad code. There are merely unanticipated features."

      I also use dyndns, and find it to work wonderfully for my purposes (with my own domains as well).

      With Tom's suggestion you will not need to receive at email@yourdomain.dyndns.org, you will still be able to accept mail at email@yourdomain.com.

      The changes at your dns host would look something like this:

      OLD: www.yourdomain.com. IN A 111.222.111 (static ip of webserver) emailserver.yourdomain.com. IN CNAME homecomputer.yourdomain.com. homecomputer.yourdomain.com. IN A 222.111.222 (dynamic ip) yourdomain.com. IN MX 10 emailserver.yourdomain.com. NEW: www.yourdomain.com. IN A 111.222.111 (static ip of webserver) emailserver.yourdomain.com. IN CNAME uniquename.dyndns.org. yourdomain.com. IN MX 10 emailserver.yourdomain.com.

      In the NEW: example, your dns host no longer needs to update any ip addresses. DynDNS would have a record that looks something like this:

      uniquename.dyndns.org. IN A 222.111.222 (dynamic ip)
      You would run a DynDNS client (Perl script?) that automatically updates that ip address as it changes.

      With dyndns.org keeping track of your routable ip address, your dns host only needs to know that they can reach that server at uniquename.dyndns.org.

      This will allow you to sit back and relax, knowing that even if your ip address changes everyday, email@yourdomain.com will still be delivered to your email server without you having to call anyone.

      FWIW, the last router (Netgear) I bought for my house has a DynDNS client installed on it, so I don't need to run the client on one of my computers.

        1. Most of the scripts I've seen so far to do such IP updates were written in perl of course :-)
        2. Getting a router with built-in support for services like DynDNS, No-IP.info or others is the best choice, as the IP is set a few seconds after the IP changes...
        3. We have drifted away from the basic topic... Perl is a matter of choice and the ability to code the working solution - blue_cowdawg has just shown us that!

        Greetz, Tom.
      Of course i agree 100% with your oppinion... i had the same situation here. I hope you did not get me wrong - the easiest way to express my point of view is TIMTOWTDI - nothing more. Leaving your A and MX records to guys at DynDNS has some more concerns (like security... for paranoid people) and lots more... Anyway it does not change my oppinion that I like your code shown above - it has already helped me today with another problem :-)

      Cheers, Tom.
        Leaving your A and MX records to guys at DynDNS has some more concerns (like security... for paranoid people) and lots more...

        Isn't the fact that your IP address could suddenly change a security problem as well? You could quite easily have attempts to deliver mail to the wrong place. There is no guaranty that everyone's DNS servers will honor very short TTL.

        If security isn't a concern, your WRT54G already has software that will update your records at dyndns.org immediately after the IP changes. I did not see anyone mention that.

        This might be off topic, but why do so many people insist on running mail servers at home? Most cable modem and DSL IP ranges are on a lot of mail servers blacklists, for one thing. Reliability isn't terribly high, either. You can get a small and reliable virtual server for $10 a month (or less), and the box you are on will likely have connectivity through more than one large ISP (my provider seems to have 6 very high speed connections.

        Oknow
      The #1 reason to have your DNS and Other Services hosted by separate entities.... If your Service Provider flakes out with webhosting ( say, a DDOS attack... ) *YOU* can redirect *YOUR* traffic away from them without any intervention on *THEIR* part... Control Am Good.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://533025]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2022-05-28 06:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (98 votes). Check out past polls.

    Notices?