[HowTo] Dynamic DNS 3rd level resolution for OSMC

As soon as you need that your PC will be reachable with the public IP address, you can setup a free dns service in order to reach your machine with a unique hostname upon the changes of the IP address from the ADSL connection.

This guide is a reviewed one of my very old guide written for [Ubuntu][1]

There is still a free system for DNS dynamic resolution provided by https://freedns.afraid.org

This installation has been tested on RPI2 with final release of OSMC (I’m very confident that will work on RPI too)

Register your account
Go to https://freedns.afraid.org and register a free account
Freedns offers a lot of domain names (…and I mean a lot), assuming that you choose: mooo.com
You’ll have “yourname”.mooo.com

Install the packages

sudo apt-get install curl wget cron

Configure dynamic DNS
Login to Freedns and choose the link FreeDNS - Free subdomain AND domain hosting!
At the bottom of the page click the link besides your domain account named “quick cron example”, this will open a txt page, at the bottom there is an example for the cron script:

4,9,14,19,24,29,34,39,44,49,54,59 * * * * sleep 13 ; wget --no-check-certificate -O - https://freedns.afraid.org/dynamic/update.php?MkNRaEoxaxzxzczxzxzcwsTtTas1= >> /tmp/freedns_yourname_mooo_com.log 2>&1 &

Take note/copy this line; on OSMC box type:

export EDITOR=nano && sudo crontab -e

and paste/save the above line previously copied.
Reboot OSMC

sudo reboot

Test dynamic DNS
from another machine issue the ping command around the time you’ve choose in cron

ping yourname.mooo.com

If the OSMC respond you’re done.

Further notes
Since the original post the inadyn client is not needed anymore, both because at the moment contains a bug for freedns and because cron is less complicate. I’ve personally changed cron to update every 15 minutes instead of 5 minutes as the script proposed by freedns and I changed the append line “>>” to overwrite “>” for log in tmp; so here my cron entry:

0,15,30,45 **** sleep 6 ; wget -O - http://freedns.afraid.org/dynamic/update.php?MkNRaEoxaGoXCvCXffsNTkxODQxvA== > /tmp/freedns_myname_mooo_com.log
2>&1 &

The cron file (named: root) is located under this path:

/var/spool/cron/crontabs/root

I’m not involved in Fredns team, but I like their service.
[1]: HOWTO Configure Freedns (afraid.org) service with Inadyn (Lucid)

2 Likes

Thanks @dentaku65! Nice tutorial!

Another solution which i think can be used for any service is ddclient and cloudflare.
For example .tk domain names doesnt have an updater, my guess is freedns doesnt either since you resolved to this.
What i did was create my domain name that i want to update in cloudflare and used their NS records on my .tk provider. So basically my domain name points to cloudflare. Then i use the ddclient app on linux to update a CNAME and A record name of the domain name in cloudflare with the pi’s wan ip address…and bam. you got dynamic updating and a simple DDOS protection :slight_smile: and no need for crons since the above action is done automatic when a new ip is given.

Hello,
but this solution is for second level domain, correct?

sorry for the delay, totally forgot to check out this thread. Not sure what you mean with 2nd, 3rd level of domains here.
To simplify things, this would work for any type of domain name. .com .tk .whatever even domains like from afraid.org.

Since cloudflare provides live editing A and CNAME records from the ddclient, your domain name only needs to have the ns records that cloudflare provides you with when you create a ‘domain’ with them. I quote the word domain, because its more like a hosting. You create a setting there with the domain name you want to update and it provides you some NS records. You set those records to your afraid domain settings so it points to cloudflare, then use the ddclient app to update cloudflare A, CNAME records with your WAN IP…and bam you get live updating of your afraid name.

This is my ddclient.conf file to update my domain name:

syslog=yes                # log update msgs to syslog
mail=root                # mail all msgs to root
mail-failure=root            # mail failed update msgs to root
pid=/var/run/ddclient.pid        # record PID in file.
ssl=yes                    # use ssl-support.  Works with
##
## CloudFlare (www.cloudflare.com)
##
use=web,
protocol=cloudflare,        \
zone=sandbird.tk,            \
server=www.cloudflare.com,  \
login=myemail@address.here,     \
password=my_cloudflare_password             \
sandbird.tk

Nice! I was using the OP tutorial, then came across ddclient for google domains, so I’m able to use my own domain.

Hi den, thanks for writing this up.

I managed to get the cront job runnning and my domain registered (used the mooo.com on as suggested).

I am able to ping my address xxxx.mooo.com, which returns the correct ip of my router at home. However, when I go to the address and put in an open port (i.e. to get to my transmission webui) I get ERR_NAME_NOT_RESOLVED in chrome and the equivalent in safari.

Is there anything else that needs doing?

Have you forwarded the appropriate ports in your router? You need to do this so that external traffic gets directed to the correct device within your LAN.

Thanks ashtonaut, I’ve opened and forwarded the correct ports to access the transmission webui.

I’m able to access it outside of my home network if I know the IP so I know the opened port is working as it should.

Are you trying to test access from outside your home network, or inside? I know some routers can’t cope if you try to enter the DDNS address while inside your home network. Try accessing from a different network if you haven’t already tried.

Edit: Another check would be to use dnschecker.org (or a similar site) to check the resolution of your IP from your host name.

I did have issues with that when first setting up so I’ve been testing it by tethering through my phone. I’ve actually had some success in the last hour! I’ve managed to acces the transmission web-ui as well as connect via sftp outside of my home network using the subdomain I registered.

Only thing thats not worked using the subdomain so far is ssh (weird how it works in fileZilla though?! though that was just a gui for ssh…).

Quite happy with this for now, perhaps ssh access to the console will work using a normal wifi connection rather than tethering…

Another thing to consider is that your isp may block certain ports

There are websites that can scan your domain and check which ports are open if you are having trouble with one in particular.

All seems to be working now, ssh to the console has worked fine over a regular network from my office to my network back home. So no real solutions other than leaving it for a day and not testing with a mobile via tethering.

Thanks for the responses :smile:

If you want to access the pi from inside the house you have to use the local ip address (ex: 192.168.1.4) of the pi…or if you have portfowarded port 80, your transmission port, and port 22 for ssh to the raspberry pi, then you can edit your : c:\windows\system32\drivers\etc\hosts file and add something like this there:

192.168.1.4     mydomain.tk

where 192…is your local ip address of the pi, and mydom… is your WAN domain name you have that you want to redirect to your wan ip.
This way you’ll be able to connect from ssh, ftp, or browser using mydomain.tk for example.

From the outside or tethering to ssh you need to have port 22 forwarded to the pi’s ip.

Please! Never open port 22 to the internet! This is a huge security risk and how bot-nets are formed. Either edit SSH config to change the port to some random non-standard port, or use port mapping in you router to direct a non-standard port to port 22 inside your network. And it should go without saying that any device faced to the web should ALWAYS have default passwords changed prior to doing so.

1 Like

the freedns solution from the first post https://freedns.afraid.org is really a great solution for lightweight devices like a Raspberry. I have set it to update every 4 hours, because I do not know ANY internetprovider that uses a lower frequency for changing IP addresses.

With this solution, you have 0.0 footprint, nothing in the memory. It’s why I prefer it over ddclient or any other solution.

The title of this topic should be simplified though. https://freedns.afraid.org allows you to create your own subdomain: myname.a-chosen-domain-on-freedns.com that’s what he means with “3rd level”. Very minor detail.

Hello zilexa,
I agree that the afraid.org is a very neat solution for RPI
I still be confident to use Dynamic DNS 3rd level resolution as topic due to the effective configuration indicated; of course this means:
.com (1st level)
bar.com (2nd level)
foo.bar.com (3rd level, or in this contest you)

For the quality of the internet provider, well it depends which Country (mine is not so good) :open_mouth: ; in any case a wget call is very lightweight in term of resources

by
den