Delphi Demo: DynDNS through your WebHost’s CPanel (e.g. 1and1.com)
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…
- The UI is slow. The control panel takes for ever to get through.
- 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.
- 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 usage is simple.
- Create a subdomain on your site and twiddle your thumbs til it becomes active sometime in the next hour or two.
- 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
- 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.
- 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).
- Go to MyIP.TheCodeCave.com and get the current IP address (This is a constant in the code and you can change it easily).
- Use a socket to retrieve the IP address for the URL you are looking up.
- If the two match, terminate the application.
- Navigate to Admin.1and1.com and get a session ID needed to establish the secure login.
- Login using HTTPS, the domain to update as the user name, and the provided password.
- 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.)
- Navigate to the DNS update page for that domain (a requirement of the 1and1 Control Panel software)
- 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!
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… 🙂
You can delete the last comment, sorry… 🙂
The download link doesnt work.
Which link? The one in the post? It seems to work for me…
Your Download link. 🙁
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.
How do I get it to do this automatically when I boot without the window?
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.
Where? I don’t see it. 🙂
That would be the section that looks like this:
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. 🙂
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!
Turbo Delphi is not free? Am I wrong?
Turbo Delphi IS free. Go and grab it today!
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 . 🙂
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
sorry i forgot the link to the file:
TCC_DDNSUpdater.exe (link)
Интересно! Надеюсь продолжение будет не менее интересным…
Народ в таких вот случаях так говорит – Авось задатка не дает. 🙂
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.
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.
James – do you still have the modified file for 1and1.co.uk available? Thanks.
Отлично! Нет ну правда, просто слов нет! 🙂
Please send me the .co.uk ver of the 1and1 dns updater, looks great …
Thanks in advance
Sorry I don’t have Delphi installed at the moment and 1and1 has changed their UI significantly in the last four years. So I don’t know that this would work anymore.
Brian, there’s two things wrong with your blog:
1) You have to do something to keep the spammers out
2) Your **comments** RSS URL is hooked into DelphiFeeds.com, not your blog entries RSS URL. We just got a ‘new post’ in that feed linking to the comment by ‘Pam’ (notice her URL)
Hi Jan,
Thanks for the comment. There HAVE been a lot of spammers come through Akismet lately. It averages <1 a day, but that is WAY more than there used to be. I think they are all manual spammers. I just went through and removed the 45 spam comments that have gotten through since August 20th. I've been watching it but hadn't bothered to clean it up largely since I didn't think it mattered too much.
Of course I'd not known that the comment feed was in DelphiFeeds.com as opposed to the real feed. I've now fixed that. It was a result of a permalink change way back when. A quick rewrite rule got things pointing in the right direction.
Unfortunately I've not used Delphi professionally since 2007 and at all since a re-install of Windows a few years back. Though I've been contemplating how I can do a re-install lately, just to get a fix. My last article on it was in March of 2007. So you won't likely be seeing much of me on Delphi Feeds no matter how much I miss it and the familiar names still there today...
Obviously this works great with 1and1.com, but is there a version that works with 1and1.co.uk? My Account ID obviously will not work on 1and1.com and I really want this software!!