3

I intend to run a debian server at home, it will host various websites, SSH server and email.

I have a dynamic IP address and I am unwilling to pay the extra for a static IP.

I was thinking I could probably get around the DNS issue if I ran my own name server and used something like no-ip to set auto-updated nameserver addresses for my registered domains, eg:

On the registrar:

john-hunt.com (and my other domains) nameservers = johnns1.noip.com & johnns2.noip.com

johnns1.noip.com, johnns2.noip.com -> my dynamic IP

Which will make sure that the nameservers for my domains are always pointing to my machine at home.

I will run BIND or something similar on the home machine to actually serve up the DNS records.

The real problem I have is that I don't quite know how I'd configure BIND (or tinydns or whatever) to accept and apply updates when my IP address changes.. I can think of a way to bodge it (poll & ping johnns1.noip.com to get my IP address, then grep on the zonefiles and reload every 5 minutes..) but that doesn't feel very solid.

Does anyone have any experience in this area? I had a look at no-ip's enhanced services but they want $25 for hosting records for every domain (and I have quite a few).

  • 2
    The solution here is to not run your own name server. Registrars take a while to update, and so when your IP changes, it could take hours or days before the new IP is picked up by the internet. Plus some registrars will refuse frequent updates. Additionally, this might be off topic for here. It doesn't really have anything to do with unix. Probably more appropriate on serverfault. – Patrick Jul 17 '14 at 12:57
  • I wasn't intending on updating the registrar's NS records, just the dns records hosted on my own machine. Also, I was assuming there'd be a software solution to the problem hence asking it here. – John Hunt Jul 17 '14 at 14:10
2

I do the following which has worked well for me the last 10+ years. I setup a dynamic DNS name on a service such as DynDNS (which was free until this year) or some other such provider. This gives me a foothold so that my constantly changing IP will always be rooted in a static name such as sam.dyndns.org.

I then create CNAMEs in bind that point to this static name and voila I have permanent names.

  • I didn't realise you can have CNAME entries pointing to a record not in the same dns record.. sounds interesting though! – John Hunt Jul 17 '14 at 14:01
  • You can do these yourself or make use of your registrars free DNS hosting as well. – slm Jul 17 '14 at 14:04
  • You know I think this might well work! You're a genius. Marked as correct because I doubt I'll remember to come back here and mark it. – John Hunt Jul 17 '14 at 14:09
  • You can also leverage this my stacking the external domains as CNAMEs on a single DDNS name and then use Nginx/Apache's virtualhosts to multi-plex them out too. – slm Jul 17 '14 at 14:16
0

While BIND does have DDNS support, it's a bit fiddly to set up as you need to create authentication keys because the updates seem to be handled over the DNS protocol itself, to allow for the updates to come from a different machine to that running the BIND server, so this of course requires a secure authentication mechanism.

I was going to go down this path myself but ended up having my domain hosted on Amazon's Route53 service instead. They have an API to update records which can be used for dynamic IPs. I set a low TTL for that one entry, and have a cronjob on my machine that looks up my current IP address and updates the Route53 record if my IP has changed.

The cost at the time of writing is about US$0.90/month so it's not free, but this seems quite reasonable for my use case considering the redundancy and failover built into the service. The rest of my DNS entries are in there too because the cost is per-zone, regardless of how many entries you actually put in the zone.

I use the aws command line tools along with a script like this (run from cron once an hour) for updating the Route53 record when my IP changes:

#!/bin/sh

function updateDNS
{
        TARGET_ZONEID="$1"
        TARGET_FQDN="$2"
        IP="$3"
        CUR_IP="$4"
        TYPE="$5"

        if [ "$IP" != "$CUR_IP" ]; then
                echo '{ "Comment": "DDNS update", "Changes":[ { "Action":"UPSERT", "ResourceRecordSet":{ "ResourceRecords": [ { "Value":"'"$IP"'" } ], "Name": "'"$TARGET_FQDN"'", "Type": "'"$TYPE"'", "TTL": 60} } ] }' |
                        aws route53 change-resource-record-sets --hosted-zone-id "$TARGET_ZONEID" --change-batch file:///dev/stdin > /dev/null
        fi
}

TARGET_ZONEID="ABC123"
TARGET_FQDN="homeip.example.com."
IP=`dig +short myip.opendns.com @resolver1.opendns.com`
CUR_IP=`dig +short "$TARGET_FQDN"`
TYPE="A"

updateDNS "$TARGET_ZONEID" "$TARGET_FQDN" "$IP" "$CUR_IP" "$TYPE"
# Can add more updateDNS calls to do other hosts, AAAA records, etc.

I run this script from a couple of hosts on the network so that if one of them is down, the IP still gets updated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.