Arkanis Development




During the last few weeks I've been working on a small, simple and self-contained dynamic DNS server: MiniDynDNS. A friend of mine wanted to bring one of his computers online but didn't want to use an 3rd party service like DynDNS.

Well, you probably know the typical hacking answer: "Why not build something like that ourselves?". How hard can it be? After all we only need a hash table or dictionary for a simple DNS server. Throw in some code to parse and generate DNS packets and your're done.

After a bit of hacking and testing it actually worked. An HTTP interface would be nice so I can tell my router to report changed IPs by itself. So in it went.

You can probably imagine that the result was a funny but scary bit of code. I did some cleanup and ended up with about 600 lines of Ruby. Some more refactoring into several classes resulted into a bit to much glue code for my taste so I reverted back to simple procedural style. The code isn't pretty or fancy but it's easier to understand this way I hope.

So if you want to role your own little DynDNS for your private stuff, take a look. Maybe it's what you want. But remember: It's only build for small stuff, not high-traffic sites. :)

2 comments for this post

leave a new one

#1 by

Hi there,

Chris is calling again :-)

Your minidyndns is working fine since months. Many thanks for that coding. I'd like contribute a patch to update ips more easy. Normally, the client updates it's own public ip. So why the client first has to find out which is his public ip. Instead, the client should tell the server: Update my IP with my current public ip.

So if no myip parameter is provided, use remote-ip.

I'm not a ruby-hacker, so I don't know if this is good code, but it works for me :-)

cp:/opt/minidyndns# diff dns-14.rb dns.rb 481c481,484 < --- > > cp_sock_domain, cp_remote_port, cp_remote_hostname, cp_remote_ip = connection.peeraddr > log "#{cp_remote_ip} calling for update" > 492c495 < throw :status, :bad_request unless params["myip"] --- > # throw :status, :bad_request unless params["myip"] 494c497,502 < ip_as_string = CGI::unescape params["myip"].first --- > if params.include? 'myip' > ip_as_string = CGI::unescape params["myip"].first > else > ip_as_string = cp_remote_ip > end >

Bye, Chris

#2 by

Hi Chris,

That's a really neat idea. Thanks for sharing it and providing a patch. :) Would have solved some trouble I had a while ago. I've implemented it based on your patch, updated the documentation and released it as v1.2.0.

If you want to use it you just have to download the new dns.rb file.

Happy programming Stephan

Leave a new comment

Having thoughts on your mind about this stuff here? Want to tell me and the rest of the world your opinion? Write and post it right here. Be sure to check out the format help (focus the large text field) and give the preview button a try.


Format help

Please us the following stuff to spice up your comment.

An empty line starts a new paragraph. ---- print "---- lines start/end code" ---- * List items start with a * or -

Just to keep your skill sharp and my comments clean.