fredag, januari 02, 2015

Setting up Duck DNS

The free and also great Duck DNS service is a simplistic DNS service that allows dynamic IP users to experience the benefits of a textual domain name like mydomain.duckdns.org. The service is very easy to use but you still have to report your dynamic IP address every now and then so that Duck DNS may direct incoming requests to mydomain.duckdns.org to the correct host. You can do this manually through the web interface but a more lazy approach is to use one of the available web services. I choose to use the reverse lookup service which allows Duck DNS to set the IP address to the IP address of the incoming request for a specific domain, which includes a token that only I and Duck DNS know. This is how i set this up on a small server running Ubuntu linux.

  1. Register on https://www.duckdns.org, copy the token available on https://www.duckdns.org/domains
  2. Create a script like the following:
    #!/bin/bash
    curl -s https://duckdns.org/update/[yourdomain]/[your token] > /dev/null
  3. Make the script executable by:
    chmod +x [scriptname]
  4. Schedule the script through to be run every 5 minutes and on reboot:
    # m h dom mon dow command
    */5 * * * * /home/[user]/bin/duck.sh
    @reboot /home/[user]/bin/duck.sh
  5. Test the set up by manually changing the IP on the Duck DNS website and verify that it changes to the correct IP within 5 minutes.