Episode: 4203 Title: HPR4203: Setup DuckDNS on a Raspberry Pi Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr4203/hpr4203.mp3 Transcribed: 2025-10-25 21:20:39 --- This is Hacker Public Radio Episode 4,203 for Wednesday 11 September 2024. Today's show is entitled, Set Up Duck DNS on a Raspberry Pi. It is hosted by Kevin and is about 17 minutes long. It carries a clean flag. The summary is, Kevin discusses dynamic DNS and how to set up duck DNS on a Raspberry Pi. Hello, hello, this is Kevin and welcome to another episode of HPR and just when you thought it was safe to be listening, here I am again restarting up the after a short summer break the Pi series. So this is this first one that I am going to come back to. It is actually one that by itself doesn't actually do an awful lot. I want to go over duck DNS, now you may be thinking what in the world is duck DNS? Well duck DNS is a free dynamic DNS provider. Now if you already know exactly what that is and this is on the internet, you may want to fast forward for the next week while because I am just going to go over what a dynamic DNS is. Now you may think okay, I am not a clue, what is that? The dynamic DNS is essentially just a, it's a DNS address that changes, okay? Now you may be thinking okay, what's the point? Well let me put it this way, whenever you set up a server in your house and let's say you've got your movie server, your media server, whatever it's going to be, you'll have an internal IP address, like for example, your router very often, a lot of those routers are things like one, one six eight dot one nine two dot one dot one, something like that. It's always going to be there. Now if you go to your router, you will find that your ISP will actually have assigned you an IP address, which allows the outside world to connect into your router, okay? But only you know that, ideally you don't share that. But just in case you share it, what the ISPs will do is they will take that and regularly and when I say regularly, I mean at least once a day, every single day, they are going to change it, okay? So although you may have the exact address, if you were just saying, for example, you were using to connect to one of your own home servers, by the end of the day, that address would be useless, it would just give you a dead link. What dynamic DNS is do is you set them up and they give you the link to your address and you just link to this address itself, your dynamic DNS. And what happens is it will automatically update. So when your address, your ISPs address updates, this will also update. So you may be thinking, okay, then what's this got to do with me? Well, if you're listening to this pi series and you're still listening to it, then quite a lot, especially for the next few that I'm going to do. The last few have been things that you would just use around the house. But the next thing is really I'm going to focus on are things where you really do want to access them from outside, let's say outside. So if you're on your phone out and about, you can use this. If you are away on holiday, you're on some less computer, you can access this using this. So duck DNS is I have to admit, I only found out about this fairly recently because I thought all dynamic DNS providers were paid for. I did not realize there was any free options available. So when I came across this, I was really delighted to see this. So yeah, but we're going to need to get the service running on a pi and I obviously have got a pi for this. So no real surprise. So if you're still listening and if you think this is something that I'm interested in, then keep listening. If I've already lost you, okay, switch off now, but hopefully you're still here. So what are you going to need? Well, you're going to need a Raspberry Pi, you're going to need a microSD card with a Raspberry and all that. Well, actually, whichever is your favorite pi operating systems installed. Of course, you are going to need a power supply. And I would also recommend that you have this connected to an Ethernet. That's just my personal opinion. You can connect through Wi-Fi. I just find when it's something you always want to be able to connect to, I just like the security and stability, sorry, the stability of an Ethernet cable. Now, so what do you need to do? Okay. So if you've got your pi connected up to a keyboard and a monitor, go straight in and we can use that. Otherwise, you will need to connect to it remotely, which we've kind of gone over this quite a few times already. So you can log in using SSH. So depending on whichever one you want. Right. The first thing we're actually going to do though, is to head over to duckDNAs.org and we've got a sign up for that. Once you've done that, you'll need to choose your own, if you sign in, now the options are sign in. It's a sign in with persona, sign in with Twitter, sign in with GitHub, read it or Google. I'll pre-warn you. They say straight away that, read it is no longer available, despite the fact that the buttons there. And I thought it sign in with GitHub and it's said unable to. So I don't understand why. But anyway, you'll have to do that. Then you'll get, you'll have to go through a capture, which was a bit of a pain, perfectly honest. But once you've signed up for your account, your free account, it will then give you a token. So we're going to use this token to update, so you have the Raspberry Pi update or IP address. OK. And you'll also need to pick a domain. So for example, if you were having one related to hacker public radio, for example, hacker public radio, projects, and it will be duckDNAs.org. So whichever one you want. And then you add the domain and it gets associated with your token. Now, you can, don't worry if you just make a mistake. Then what you can actually do is you can delete the domain and it gets removed completely. So it's all pretty self-explanatory there. So now we're going to need to actually get this. Now we've got this. We've got this registered and got our token. We're going to need to get this set up. So the first thing that I would recommend you do is update and upgrade your Raspberry Pi. Always make sure it's in the latest version of everything before you actually do a major install like this. So now we're going to use Carl to send the request duckDNAs to actually update its we need to install Carl. So pseudo-opt install Carl and we're going to then create a directory. So we're going to need to actually put duckDNAs on. So it really does not matter too much where you're going to do if you want to put it in the fold, actually fold in the opt folder or if you want to put it just in your document. It's entirely up to you. So I just use them make a pseudo make MKDIR. So pseudo make directory. So pseudo MKDIR and then put in whichever one you want and just make sure you note in this. Okay. We're also going to need directly where its logs can be kept. Now just for continuity I quite like to keep it in the log folder. So pseudo MKDIR forward slash bar forward slash log forward slash duckDNAs forward slash okay. So we've got our two folders made up there. So what we're going to do next is we're going to write a bash script to auto update the Raspberry Pi's IP address with the duckDNA service okay. So pick your text editor of choice. I'm just going to use nano for the sake of simplicity. So go pseudo nano and whatever you just created for in the second last step, not the last one I was for your logs, but the place where the script is going to be found. So let's just say for example, you kept it in in the opt and you created a folder and they're called duckDNAs. So pseudo nano forward slash opt forward slash duckDNAs forward slash duckDNAs and this is going to create a file in there called duckDOT sH. Okay. Now this part's actually really important and I would really recommend that you actually go and check the show notes so you can actually get this because it's quite lengthy, okay. And you're going to have to put in your details. So you're going to have to put in here your duckDNA and also the your token. Okay. Now I'm certainly not going to read out mine. So to do this, so you go echo space URL equals inverted commas HTTPS colon forward slash forward slash WWW dot duckDNAs dot org forward slash update question mark domains equals and then you need to put in your own duckDNAs to me. In the and symbol and token equals and then you need to put in your own token. Okay. And there's no spaces at all in all of this here at this point. Then and IP equals inverted commas and then a space and then the vertical line. I can remember that's what it's called space curl space dash key space that lower key ski space dash lower case O space forward slash var forward slash log forward slash duckDNAs forward slash duck dot log space. And then dash upper case key. And then space and then another dash okay. So what you'll want to do is you want to save and quit if you're using nano it's control legs and then press Y and then enter. So control legs legs that you want to save press Y and enter. So now before running the script we have to modify the script permission so that only the file owner can edit view or execute this file. Now so you don't want anybody else to be able to use it to be able to edit this or see your token. So to do that so again this is assuming you are in your picture of duckDNAs folder in the opt folder to pseudo space C H mod space 770 0 space forward slash opt OPT forward slash duckDNAs forward slash duck dot S H. Again like I said I would highly recommend rather than typing this in if you go to the show notes and actually just copy and paste them then there's a less chance of making a mistake. So the next thing we're going to do is to set up a crime job so that we can update the duckDNAs from the Raspberry Pi because remember what I said you may have an address one minute and a no later this address has changed so we want to constantly be checking this. So we'll do this by setting a crime tab so pseudo space crime tab C R O N T A B space dash lower case E okay and if you're asking what editor do you want to use I mean it's down to you are for the easy and seek I use nano that's just me you use whatever you want okay now we want to go down to the very bottom of the file at opens and we're going to set this to update every five minutes now you may be thinking that's too much well actually no it's not because it can change at any point and if you're only updating once an hour if it happens to be a minute after it's there has been checked then your device is not going to be accessible for the next 59 minutes so we'll go every five minutes. So to do that now if we do said ask this can we start some on your number pad it's like the one you would use for multiply I think it's an ask this it's called so it's ask the space forward slash five space asterisk space asterisk space asterisk space asterisk space asterisk space forward slash OPT forward slash duck DNS forward slash duck dot sh space and then the greater than symbol that I'll point to the right forward slash dev forward slash null in you LL space two greater than and symbol one okay so after I'm entering that then control x to get it now no you want to save yes yes and then enter okay and we can actually wait essentially just for five minutes if you want to check to see if your duck DNS is actually updating okay now this is maybe something that you may be thinking okay so what's it do well that's what I'm going to look at in or some use cases for it in some of the next ones I'll describe what I've got running of course it's entirely up to you but what this essentially does is this is going to allow you to connect to a pie from the outside world not just within your own house or within your own network chassis okay so it's you have to have this is an app project in it in and of itself but it is certainly one that we're going to be using in the next few projects so I hope that you found this of some informative and hopefully where you will manage to make use I will say duck DNS is a free service so if you find you actually use this then can I please recommend that you actually you actually go and make a donation because this is an absolutely fantastic service and like I said until very recently I genuinely thought this was only duck dynamic DNS is where only available as paid for services so to see this as free this is absolutely fantastic so yes and of course as always please help can spread the word of it HPR please continue if you can to actually upload and give shows and also one other thing is one the best thing so that we can actually do it's actually spread the word talk to other people who might be interested about it let them find out about it and let them I mean they're maybe not going to listen to every single episode but keep on get them to keep on checking maybe especially with something that you know about somebody maybe you recommend the show if you know it's something they're going to like so anyway until next time this is Kaby signing off you have been listening to Hacker Public Radio at Hacker Public Radio does work today's show was contributed by a HPR listener like yourself if you ever thought of recording podcast and click on our contribute link to find out how easy it really is hosting for HPR has been kindly provided by an onsthost.com the internet archive and our syncs.net on the Sadois status today's show is released on our creative commons attribution 4.0 international license