Delphi Demo: DynDNS through your WebHost’s CPanel (e.g. 1and1.com)

March 6, 2007

aka Dynaminc DNS with 1and1.com

aka How to automate a Web Session with Delphi

 Here’s a program I’ve been beta testing for a few months.  I use it on a subdomain of TheCodeCave.com to allow me to always reach my home.  I use Road Runner Cable from Time Warner and have a dynamic IP address.  That means that my IP can change at any point in time.  And it does!

I used to use the site Dyn.EE to provide a link to my house.   I always liked them because their client is written in Delphi.  However, now that I have TheCodeCave.com and a gazillion subdomains hanging off of it (MyIP.TheCodeCave.com, Webmail.TheCodeCave.com, Rot13.TheCodeCave.com and the list goes on) I thought I would also make an url that connected to my house.

 This was tedious but quite duable to do once.  You just go into the 1and1.com control panel, create the domain, wait for it to become functional, and then modify the DNS settings and override the A record.  Simple right? Well mostly, it is just point and click at what seems logical.

 However, that’s a pain to do on a regular basis because well…

  1. The UI is slow.  The control panel takes for ever to get through.
  2. You have to first look up your own IP address first.  I usually would call my wife and have her send me an email and I’d grab it from the email header and then fix the DNS.  What a pain.
  3. Why suffer through minutes of clicking a few times a year when several hours of programming can get your around it?

So, I give you : The Code Cave’s Dynamic DNS Updater.

The Code Cave's DDNS Updater!

 The usage is simple. 

  1. Create a subdomain on your site and twiddle your thumbs til it becomes active sometime in the next hour or two.
  2. Enter that domain in the first field.  NOTE: If you put your main URL, your main URL will no longer point at your website.  Be careful!  You want this to be something like:  subdomain.example.com
  3. Enter the main password for your account.  This is sent over HTTPS to 1and1.com and not to me.  Have no fear. ;)   But it will appear in the debugging section if you check that “Show IE Data Sent” box.
  4. Click the Update 1and1.com Domain button and watch it work.

Your change should be available almost immediately, however, when debugging this program I sent the change a few (dozen) times and it eventually refused to allow any more updates to go through for another 24 hours.  It’s been fine ever since.  I’ve since changed the program so that does not try to update the DNS if the URL is already correctly set. 

I’ve additionally made the program so that it takes the three fields mentioned above as  parameters.  You can put this into Windows XP’s scheduler and every 15 minutes, it will check the current IP and update as needed.  Or just put it in your startup folder.  This of course means your password will be put into your scheduler, but you have the source code, you can add encryption if that is a concern on your PC.

So, an easy way to do it would be to create a short cut in the startup folder to the program with the parameters like this:

tcc_DDNSUpdater URL PASSWORD DOMAINID

That will look something like this:

tcc_DDNSUpdater dyn.sample.com My1PaSsWoRd  12323213

 The quickest way to get your domain ID is to run the program manually once and just click the Update 1and1.com Domain button.  Then you can see the domain ID below.

 The program follows this procedure recreating the required browsing session (so it is only as fast as your connection to 1and1.com).

  1. Go to MyIP.TheCodeCave.com and get the current IP address (This is a constant in the code and you can change it easily).
  2. Use a socket to retrieve the IP address for the URL you are looking up.
  3. If the two match, terminate the application.
  4. Navigate to Admin.1and1.com and get a session ID needed to establish the secure login.
  5. Login using HTTPS, the domain to update as the user name, and the provided password.
  6. If a Domain ID has not been provided, navigate to the list of domains and retrieve the ID of the domain (The subdomain HAS to be amoung the first 50 domains, alphabetically, on your account.)
  7. Navigate to the DNS update page for that domain (a requirement of the 1and1 Control Panel software)
  8. Submit the DNS record change.

Simple as that!

The full delphi source is available in the Zip file.  The usual “If this crashes your site and costs you $30,000 dollars, why the heck did you run non-standard like this and risk a business site on it!  I’m not responsible for your site’s safety you are.  So consider the very real risk that things can go wrong with demo stuff downloaded off the Internet and err on the side of safety.” warning message applies.

You can download the file here: TCC_DDNSUpdater_Main.zip (link)

 I’ll post details of the code later.

I created this app using a Websession logger that might be of use to you.  I use it in my automation processes at work and also us it to create forum submission links that I could not have book marked on the web in any other fashion.

Enjoy!

Share and Enjoy:
  • del.icio.us
  • Fark
  • Reddit
  • Digg
  • DZone
  • email
  • Facebook
  • FriendFeed
  • Google Bookmarks
  • Netvibes
  • Ping.fm
  • Posterous
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Yahoo! Bookmarks
  • Add to favorites
  • Blogosphere News
  • HackerNews
  • Identi.ca
  • LinkedIn
  • MySpace
  • Print
  • Yahoo! Buzz

Comments

23 Responses to “Delphi Demo: DynDNS through your WebHost’s CPanel (e.g. 1and1.com)”

  1. Joe on March 7th, 2007 8:54 pm

    Thanks so much!
    Works great. Oh, I built a small script that you can run on another domain that gets the ip address similar to the one you have only it makes a very very simple xml file:
    <xml>
    <date> 6/07/07 – 4:50PM</date>
    <ipaddress> IP </ipaddress>
    </xml>

    Though I’m not sure if thats really nessesary. :-)

    If anyone else wants to run a script like the one on myip.thecodecave.com its really simple if you have php. :-)
    <title><?php print $_SERVER['REMOTE_ADDR']; ?></title><?php print $_SERVER['REMOTE_ADDR']; ?>

    Hope that helps… :)

  2. Joe on March 7th, 2007 8:57 pm

    You can delete the last comment, sorry… :)
    The download link doesnt work.

  3. Brian on March 8th, 2007 10:00 am

    Which link? The one in the post? It seems to work for me…

  4. Joe on March 12th, 2007 6:20 pm

    Your Download link. :-(

  5. Brian on March 12th, 2007 9:29 pm

    OK, it had some slashes the wrong direction. My website is drive X: and when I copied the path, I forgot to reverse the slashes. Some browsers are very unforgiving with syntax and can’t handle that. That’s probably a good thing because allowing the flexiblity promotes sloppiness and moves away from standards.

    Thanks for letting me know.

  6. Joe on March 12th, 2007 9:40 pm

    How do I get it to do this automatically when I boot without the window?

  7. Brian on March 12th, 2007 10:08 pm

    Ah, with the code as it is, you can’t. I should have tested that section, but if I had, I wouldn’t have gotten the post working.

    The download file is updated.

    I’ve added text to post to better explain the run time parameters.

  8. Joe on March 12th, 2007 11:00 pm

    Where? I don’t see it. :-)

  9. Brian on March 13th, 2007 8:16 am

    That would be the section that looks like this:

    So, an easy way to do it would be to create a short cut in the startup folder to the program with the parameters like this:

    tcc_DDNSUpdater URL PASSWORD DOMAINID

    That will look something like this:

    tcc_DDNSUpdater dyn.sample.com My1PaSsWoRd 12323213

    The quickest way to get your domain ID is to run the program manually once and just click the Update 1and1.com Domain button. Then you can see the domain ID below.

  10. Joe on March 20th, 2007 6:33 pm

    Thanks… Is there a way to manually input the IP address from the command line? I built a little command line application that parses a CSV file and gets the url’s id from the file. So all i have to do is URL PASSWORD. :-) I can send the code to you if you want and or the program. :)

  11. Brian on March 20th, 2007 7:10 pm

    Not right now, but you could easily make the change. Download Turbo Delphi and see if you can figure out how to make the change to the Delphi code.

    If you have any trouble, I’ll coach you through it. But the cost of the change will be you becoming a Delphi programmer!

  12. Joe on March 22nd, 2007 12:17 pm

    Turbo Delphi is not free? Am I wrong?

  13. Brian on March 22nd, 2007 12:31 pm

    Turbo Delphi IS free. Go and grab it today!

  14. Joe on March 29th, 2007 9:24 pm

    Oh, I was there, just went to the wrong link I guess. I’ll download it and work on this eventually. Tell you when its done . :-)

  15. James Kirby on May 2nd, 2007 7:45 pm

    Hi there, a while ago i brought a 1and1.co.uk domain name and tried this program and realised it was only for 1and1.COM so i edited the program using the delphi source file and made it so you can edit either, .CO.UK or .COM and also added some enhancements to it aswell.

    It’s faster than the previous version, and has got a progress bar for output information.
    It’s all the original program, just lets say… Tuned!

    Hope this helps some people as it did with me!! ALOT. untill i brought a static IP where i dont need it any more.

    Have Fun:
    http://www.JKirbyProductions.co.uk

  16. James Kirby on May 2nd, 2007 7:48 pm

    sorry i forgot the link to the file:

    TCC_DDNSUpdater.exe (link)

  17. Дим on September 5th, 2008 7:05 pm

    Интересно! Надеюсь продолжение будет не менее интересным…

  18. Filipp on September 8th, 2008 3:40 pm

    Народ в таких вот случаях так говорит – Авось задатка не дает. :)

  19. Kun Xi on November 14th, 2008 1:32 pm

    That is cool!
    What is the license of the source code? I plan to hack a script using ANSI C, and ported it to WD MyBook World Edition to access the files everywhere.

  20. Brian Layman on November 14th, 2008 1:36 pm

    It’s referenced in the source, but basicaly buy me a cup of coffee and/or reference me & my site somewhere and we’re good. Hope it works well for you.

  21. Max on December 15th, 2008 7:28 am

    James – do you still have the modified file for 1and1.co.uk available? Thanks.

  22. Эрик on January 30th, 2009 3:49 pm

    Отлично! Нет ну правда, просто слов нет! :)

Got something to say?





Who is Brian Layman

I am a WordPress expert living in North East Ohio. I am part of the ever expanding Open Source Internet workforce. I am able to stay at home, with my wife and four home schooled kids, while working as the Senior Developer for b5media - a blogging network that has hosted over 300+

I co-host the NEO WordPress Monthly meetup. I am the board chair of our local church. I host and have provided development services for clients such TV personalities Rhett and Link as well as corporations such as Borland International.

In my spare time I try to sneak out, canoe, mountain bike and camp as often as I can. Sometimes I also defend the earth against zombies and aliens, but usually not during the camping trips.

Services Provided

In providing hosting, email, theme and plugin development to my clients, I function as a single point of contact answering to the needs of their expanding sites.

My service portfolio includes but is not limited to WordPress hosting, optimization, theme development and custom plugin creation. Community creation via vBulletin, Ning and BuddyPress and bbpress

I also am well experienced in site conversion, transition and merges. To clarify this, website technologies change and giving up your data is not an option. I have transitioned literally hundreds of sites from one platform to another.

viagra 50 mg indian version of viagra cialis cheapest viagra india online viagra cost comparison viagra for sale without prescription generic tadalafil online buy viagra in korea indian levitra discount cialis online viagra prescription over the counter vardenafil cialis otc cialis no rx cialis 30 mg viagra ranbaxy buy levitra in uk cialis low price tadalafil tablets 10mg cheap viagra fast shipping cheap generic levitra cialis discount cialis 5mg viagra discount prices buy levitra without prescription vardenafil online generic levitra canada viagra professional price cheapest sildenafil citrate indian version of cialis viagra lowest price viagra online prescriptions tadalafil 10mg levitra over the counter levitra prescriptions online buy viagra without a prescription liquid tadalafil citrate buy viagra prescription online tadalafil 20mg india india viagra generic sildenafil citrate for sale vardenafil hcl 10mg cialis discount coupon buy levitra australia viagra over the counter in canada liquid sildenafil tadalafil price comparison viagra cost in india cialis mail order sildenafil sales buy vardenafil cialis offer cheap vardenafil generic cialis no prescription viagra tabs generic indian names viagra price canada vardenafil hcl 20 mg generic viagra without prescription viagra by scilla biotechnologies buy generic cialis free viagra viagra over the counter viagra pills kamagra 100 mg cialis from india tadalafil australia tadalafil 20mg tablets tadalafil soft tabs sildenafil pills viagra no prescription required generic viagra paypal tadalafil online indian viagra cost tadalafil online pharmacy generic soft viagra sildenafil soft tablets viagra generic names buy viagra in ireland levitra without prescription levitra online purchase cialis pill indian tadalafil levitra 5mg cialis cost per pill tadalafil oral jelly sildenafil no prescription vardenafil price generic cialis 10mg cheap cialis no prescription order sildenafil citrate indian generic viagra blue viagra buy cialis usa apcalis 20mg tablets viagra overnight delivery sildenafil india purchase viagra without a prescription viagra prescriptions order viagra without prescription viagra with no prescription levitra for sale purchase viagra canada discount levitra viagra 200mg cheap viagra 100mg cialis overnight delivery buy sildenafil online viagra made in india cialis tabs 10mg viagra indian pharmacy viagra for sale in ireland viagra uk prices buy viagra in europe generic cialis india levitra online viagra for sale india buy viagra in dublin generic cialis soft tabs viagra 50mg cost generic sildenafil 100mg tadalafil generic viagra super active 100 mg kamagra 100mg sildenafil 100 mg tablets cialis no prescription viagra low price online cialis suhagra tablets buy cialis daily use tadalafil sample cialis prices viagra prescription online buy cialis pill kamagra from india cialis online levitra mg vigora india vardenafil 10 mg sildenafil citrate 100mg buy viagra in india buy cialis professional viagra in india buy viagra in singapore generic revatio viagra substitutes sildenafil canada viagra no script cheap kamagra viagra retail price cheap lovegra order viagra uk buy cialis in mexico viagra prescription price purchase cialis online without prescription online cialis prescription ranbaxy caverta buy viagra in hong kong sildenafil price cialis mastercard buy viagra in england viagra mail order canada cialis tablets for sale order cialis cialis soft tabs generic levitra india tadalafil prices cheap sildenafil citrate tablets cialis online prescriptions cialis 5 mg daily levitra prices prescriptions viagra viagra over the counter alternative cialis 20 mg tablets cialis generic india cialis prescribing cialis 20mg daily sildenafil 50 mg viagra drug prices tadalafil generic india cialis sale viagra prices buy viagra 50 mg levitra pharmacy buy viagra generic viagra prescription drug cialis daily cost vardenafil uk viagra soft tabs online buy viagra super active cialis 10mg price 25mg viagra silagra 100mg online viagra prescriptions cialis prescription cheap cialis india revatio 20 mg indian equivalent of viagra tadalafil india viagra capsules cheapest viagra buy cialis without prescription tadalafil overnight cheap tadalafil online purchase viagra online no prescription