📂
my database
  • Introduction
  • Home setup
    • Raspberry
      • OS Installation
      • Enable SSH and first access
      • SSH configuration
      • Change default credentials
      • Home DNS
      • WiFi USB
      • Live cam
      • ESP32
      • AD/DA
      • Humidity sensors
    • Remote access
      • ssh
      • Turn on/off remote computer
      • Dynamic DNS
      • Remote ssh
      • Home VPN
  • GNU/Linux commands
    • locale
    • crontab
    • chmod
    • router
  • Future sections
    • Topics
  • Research
    • Introduction to Sustainability
Powered by GitBook
On this page
  • Create DNS for your public IP
  • Dynamically update the hostname
  • Create file with credentials
  • Automate hostname updates

Was this helpful?

  1. Home setup
  2. Remote access

Dynamic DNS

PreviousTurn on/off remote computerNextRemote ssh

Last updated 4 years ago

Was this helpful?

To be able to access your home network devices remotely, you need to know the public IP of your network. This is given by your ISP and changes dynamically.

In this section, we will create a DNS alias that will map a given hostname to your up-to-date public IP. To this end, we will use .

Create DNS for your public IP

  • Go to and register.

  • Go to Manage Hostnames in the left navigation bar.

  • Create your hostname. First, you need to click on Check Availability, next it will ask you for your public IP. Note that NOW-DNS will auto-fill it, however, you easily check your IP .

NowDNS configurayion panel
  • Once created, your hostname will appear on the DNS table.

Dynamically update the hostname

As aforementioned, public IPs are dynamic, which means that they change from time to time (e.g. router reboot). Getting track of these changes is unfeasible, even more when you are abroad (as you would need to access your home network which in turn requires you to previously know the current public IP).

Create file with credentials

First, create a file called /home/pi/crons/now-dns/credentials with your NOW-DNS details using the following structure:

/home/pi/crons/now-dns/credentials
machine now-dns.com login [YOUR_MAIL] password [YOUR_PASSWORD]

After creating, modify the permissions so only you have access

chmod 600 /home/pi/crons/now-dns/credentials

Automate hostname updates

To do this, we will create a local script, which runs periodically (using crontab). First, we create a script file.

/home/pi/crons/now-dns/script.sh
# Get current public IP
PUBLIC_IP=$(curl icanhazip.com)
NOW_DNS="lucas-example.2mydns.net"

# Update ip
curl --netrc-file /home/pi/crons/now-dns/credentials \
    https://now-dns.com/update?hostname=$NOW_DNS&myip=$PUBLIC_IP

Next, we add script execution to crontab. In our configuration, we set an every-5-minute execution.

$ crontab -e
*/5 * * * * bash /home/pi/crons/now-dns/script.sh

You can check the logs of crontab by running

tail -n 10 -f /var/log/syslog | grep CRON
Registered DNS

To solve this, we simply create a script that updates the NOW-DNS hostname (using ) and place it as a crone task on the raspberry.

NOW-DNS API
Is "curl -u username:password http://example.com" secure?, StackExchange
How to pass credentials to curk?, StackOverflow
NOW-DNS
NOW-DNS
here