Social Icons

Setup Dynamic DNS / DynDNS for *FREE* on Raspberry Pi / Ubuntu


Update: You can try our newer and easier guide which uses dns4e.com here

You might have recently setup your Raspberry Pi or your Linux box as a 24 x 7 torrent downloader, or a small Web server to host your own website. And just then you realize that your ADSL or Cable Internet connection has a dynamic IP address which changes frequently and every time you reconnect. Thus, it becomes hard to access your box with a fixed Domain name or IP address.

To solve this problem you can setup a Dynamic DNS which will update your IP to a DNS name everytime it changes and you can access you hosted website, or ssh into it to monitor torrent downloads with ease.

While there are many paid dynamic dns service providers available, but here you will see one way to do it for **FREE** [Thanks to freedns.afraid.org]

Step 1
Register for a Free domain at http://freedns.afraid.org/signup/
[We will take techhome.homenet.org in this guide]

Step 2
Logon to FreeDNS (where you just registered) and goto http://freedns.afraid.org/dynamic/
Or, simply click on "Dynamic DNS" link from the left navigation menu

Right click on "Direct URL" and copy the URL and paste it somewhere.

You should notice a large and unique alpha-numeric key in the URL, make a note of it as shown below:
http://freedns.afraid.org/dynamic/update.php?[alpha-numeric-key]

Step 3
Install inadyn using the following command:
sudo apt-get install inadyn


Step4
Configure inadyn using the below steps:
sudo nano /etc/inadyn.conf

And add the following contains in it replacing the actual values:
--username techhome
--password mypassword
--update_period 3600
--forced_update_period 14400
--alias techhome.homenet.org,alphanumeric key
--background
--dyndns_system default@freedns.afraid.org
--syslog



Step 4
Now, we need to ensure that the DNS updater (Inadyn) runs automatically after every re-boot

export EDITOR=gedit && sudo crontab -e

Add the following line:
@reboot /usr/sbin/inadyn


Step 5
Reboot system and then run the following command to ensure inadyn is running:

ps -A | grep inadyn

Now your host is ready and up for accessing from internet...

You can trying ssh-ing from another computer over the internet
ssh username@techhome.homenet.org

Or, if any web server is running, then simply browse to  http://techhome.homenet.org

Or, you can just ping it to test ping techhome.homenet.org

To check the logs you can use this:
more /var/log/messages |grep INADYN

This has been re-tested to be working perfectly with inadyn 1.96.2-1 on Raspbian 3.12.22+

37 comments:

  1. I would recommend https://dns4e.com/ to use as a Dynamic DNS service. Ir provides very simple API to update DNS record with your public, or any other IP. You need cron and curl, which are most likely already installed. Just execute crontab -e and enter a line like this:

    */10 * * * * curl 'https://api.dns4e.com/v7/me.dns4e.net/a' --user 'PublicKey:SecretKey' -X POST

    It will update your IP on 10 minutes, or less if you change the first number. Also you can configure your own domain, or select a free subdomain under dns4e.net.

    ReplyDelete
    Replies
    1. awesome api... no issues for now... very fast...

      Delete
    2. Hi there. Thanks for the tip. I'm a super noob when it comes to CRON and I want to use this to keep a Raspberry Pi Domoticz server updated. I'm assuming you change the 'me' wording to the domain you registered with dns4e? When saving the Cron file, do you have to give it a name or just accept the defaults?

      Delete
    3. Awesome! Simple and working 100%!

      Delete
    4. Outstanding! Works perfectly.

      Delete
    5. Thank you, useful!

      Delete
    6. Received email from DN4E that "DNS4E will be working till April 15, 2015 and will stop providing services indefinitely". I switched to dynu.com instead. Free,IP update time is less than 1 miunte,free subdomain and custome domain names supported.

      Delete
  2. Good tutorial, but I didn't understand how to register for a free domain with FreeDNS. I created an account and then followed your link, but there was no domain created. Could you please explain what you mean by "Register for a free domain"? There are quite a few options there.

    ReplyDelete
    Replies
    1. From the left hand navigation menu on FreeDNS website click on subdomain, and choose a subdomain of your choice of Type: A

      Your address would be like .subdomain.com and this will point to your public IP address of your RasPi

      Delete
    2. Hello Abhishek,

      I read your really useful articles about creating owncloud for Raspberry Pi. Since I wanted to access OwnCloud through Dynamic DNS from freedns.afraid.org, I first obtained one domain name based on your article. I can ping to this IP address and domain name fine. But I cannot login to Owncloud,

      INADYN gives following error messages:

      W:INADYN: Main: error ‘RC_DYNS_RSP_NOTOK’ (0x48).
      INADYN: Started ‘INADYN version 1.96.2’ –dynamic DNS updater.
      I:INADYN: IP address for alias ‘xxx.yyyy.com’ needs update to ‘xx.yy.zz.uu.vv’
      W:INADYN: Error validating DYNDNS svr answer . Check usr, pass, hostname, abuse,…!
      W:INADYN: DYNDNS Server response:#012HTTP/1.1 200 OK#015#012Server:nginx#015#012Date:….

      And errors in nginx_start_errors:

      nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
      nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
      ….

      What am I doing wrong? Any help will be highly appreciated. Thank you.

      Delete
    3. Hello,

      There are couple of things that might go wrong...
      1. Check you have performed everything correctly as in Step. 4
      2. If you see everything is right as mentioned in Step.4 then try the following:
      Uncomment the following line from nginx.conf
      pid /var/run/nginx.pid;

      This is probably due to some issue with a few versions of nginx scripts,though I haven't faced this but it appears there are many other users over internet who are troubled.

      Good Luck!

      Delete
  3. Thanks for your tutorial. My problem is that I paid money for my standard dns with DYN, two weeks ago and still I have not managed to use treir service. Can you help?

    ReplyDelete
    Replies
    1. I have not used the paid service from dynDNS or freedns.afraid.org however the concept should be same. You can try reaching out to their helpdesk / support since you're a paid / premium customer.

      Delete
  4. You might want to note that inadyn has to be installed first (and isn't installed in raspbian at least). Apart from that, this worked like a charm, thanks.

    ReplyDelete
    Replies
    1. You're right... I missed out on mentioning the steps about installing inadyn. The post is updated now. Thanks for the note!

      Delete
  5. Does this require Port Forwarding to be configured on the router to which RPi is attached?
    I have followed the steps and trying to ssh into RPi from an external computer (different network). I am getting "connection refused" message. I also tried canyouseeme.org and found out the port 22 open test is always timed out. Any insights?
    What is your setup that works perfectly?
    Thanks.

    ReplyDelete
    Replies
    1. Yes if your Raspberry Pi is behind a router you will have port forward from your router to your device.

      Delete
    2. What port do I need to foward?

      Delete
    3. if your ssh is running on port 22 (default) then you need to forward that to any unused port on your router. You should try connecting to the port which you have forwarded from your router to your raspberry pi for ssh protocol.

      For more details on port forwarding please go through some tutorials on google, that might give you a detailed insight.

      Delete
  6. there is no /etc/inadyn.conf in my raspberry even after I installed the inadyn... whats wrong?

    ReplyDelete
  7. hey , i dont understand what --alias techhome.homenet.org,alphanumeric key?

    can u share me about alphanumeric key? where i find it

    ReplyDelete
    Replies
    1. You will get your unique alpha numeric key from step 2 mentioned.

      Delete
  8. Great post and thanks for continuing to answer questions.
    Step 4 re-opens GNU Nano, which is full of text. Where do I add the extra reboot line?

    ReplyDelete
    Replies
    1. Add the line at the end of the file, no need to change anything existing.

      Delete
  9. I can't find: "Right click on "Direct Link" and copy the URL and paste it somewhere" anywhere. Have they change the site since you made this guide. Or am I blind :/ Thanks for great guides!

    ReplyDelete
    Replies
    1. I have updated that section of the guide with more clarity, Hope this helps you better now.

      Delete
  10. Setup and config works like a charm with afraid.org, but keep getting this error:

    Apr 17 23:42:44 raspberrypi INADYN[1936]: W: DYNDNS: Error 'RC_IP_RECV_ERROR' (0x15) when talking to IP server
    Apr 17 23:42:44 raspberrypi INADYN[1936]: W:'RC_IP_RECV_ERROR' (0x15) updating the IPs. (it 3)

    Do you know if this is due to Inadyn is using checkip.dyndns.org to find my IP-address and this service is responding incorrectly?

    ReplyDelete
  11. Iam getting the same error on an newly updated raspian system:

    INADYN:IP: Error 0x68 in recv()
    W: DYNDNS: Error 'RC_IP_RECV_ERROR' (0x15) when talking to IP server
    W:'RC_IP_RECV_ERROR' (0x15) updating the IPs. (it 3)

    I think this is a bug in Inadyn...

    ReplyDelete
  12. I am getting same error. Is there other program which could be substituted for Inadyn?

    ReplyDelete
  13. I got 2 errors in the log

    Sep 10 16:21:14 raspberrypi INADYN[1910]: INADYN:IP: Error '0xb' resolving host name 'checkip.dyndns.org'
    Sep 10 16:21:14 raspberrypi INADYN[1910]: W: DYNDNS: Error 'RC_IP_INVALID_REMOTE_ADDR' (0x12) when talking to IP server

    what's wrong?

    ReplyDelete
  14. i can open my surocam program "webiopi" offline. iplocaladdr:8000, then i online use *****.chickenkiller.com or *****.chickenkiller.com:8000 is not working. when i ping *****.chickenkiller.com its working.. can you help me to fix it.?

    ReplyDelete
    Replies
    1. Check if port forwarding is done properly in case you have a router in between.

      Delete
  15. It's also free at hn.org.

    ReplyDelete
  16. Are you able to have 2 different alias lines in the inadyn.conf??

    Is it just a case of entering -

    --alias techhome.homenet.org,alphanumeric key
    --alias techhome2.homenet.org,alphanumeric key2

    into the file?

    ReplyDelete
  17. Being a newbie, this is an Interesting thread.

    Can this be used also, having a virtual server setup on the RPi, reporting dyn IP for all the multiple own domains I have on the virtual server?

    Sincerely,
    Christian

    ReplyDelete
  18. I had to make some changes to the inadyn config to get it working:

    # Service provider
    system default@freedns.afraid.org
    # Hostname
    # Only use url, not alphanumerical key.

    ReplyDelete