Skip to content

Create a DNS domain hostname

trinib edited this page May 14, 2022 · 11 revisions

Dynamic DNS service

You can choose any of these websites:

OPTIONAL:Logs are set to save in Pi's home directory(/home/pi). If using other OS, change location.
For example: home/username or /root

IMPORTANT:Scripts are set to point at /home/pi in crontab(job schedule). If using other OS, set correct path.

DYNUDNS

  1. Create account at https://www.dynu.com/en-US/ControlPanel/CreateAccount/

  2. Go to https://www.dynu.com/en-US/ControlPanel/DDNS/ and select add domain

  1. Enter any name in host and select a domain in top level options for example : trinibvpn.freeddns.org

IPv4

  1. Need to install DDclient to update external IPv4 address when it changes:

    sudo apt-get install ddclient -y
    

It will show to a setup screen, keep pressing enter until installation is done.

  1. Open DDclient configuration file:

    sudo nano /etc/ddclient.conf
    
  2. Copy&Paste text below, just change to your username, password, domain name:

    # ddclient configuration for Dynu
    #
    # /etc/ddclient.conf
    # Check every 5 minutes
    daemon=600
    # Log update msgs to syslog
    syslog=no
    # Record PID in file
    pid=/var/run/ddclient.pid
    # Get ip from server
    use=web, web=checkip.dynu.com/, web-skip='IP Address'
    # IP update server
    server=api.dynu.com
    protocol=dyndns2
    # Your info
    login=USERNAME
    password=PASSWORD
    DOMAINNAME
    
  3. Put all the parameters in the configuration file before running DDclient:

    sudo /usr/sbin/ddclient -daemon 300 -syslog
    
  4. Start DDclient daemon:

    sudo systemctl restart ddclient && sudo systemctl start ddclient
    

Reboot router and check in dynu control panel to see if IPv4 updated. (keep note on the last external IP you had or manually change it to something random in dynu settings before)

IPv6

Need to use a update URL command script method for IPv6 because DDclient do not update it when it changes(let me know if it does).

  1. Need to create a script file to update dns service:

    sudo nano dynu.sh
    
  2. Copy&Paste this line but with your own username and passowrd:

    echo url="https://api.dynu.com/nic/update?username=USERNAME&password=PASSWORD" | curl -k -o /home/pi/dynu.log -K -
    
  3. Set permission to the file:

    sudo chmod 700 dynu.sh
    
  4. Run this command to check if dynudns updated. Go to https://www.dynu.com/en-US/ControlPanel/DDNS/ and under LAST UPDATED, you will see time updated.

    sudo /home/pi/dynu.sh
    
  5. Use a cron job to make the script run every 5 minutes:

    crontab -e
    
  • Add the following at the bottom of crontab:
*/5 * * * * sudo /home/pi/dynu.sh >/dev/null 2>&1

DONE !

FREEDNS

  1. Create account at https://freedns.afraid.org/

  2. Click on “Add a subdomain” on the left and enter any subdomain name and pick any domain, but for destination put 0.0.0.0 to check if your external IP updates.

  1. Create a script to update external IP address when it changes:

    sudo nano free.sh
    
  2. Copy&Paste this line but with your token:

    echo url="https://freedns.afraid.org/dynamic/update.php?YOURTOKEN" | curl -k -o /home/pi/free.log -K -
    

  1. Set permission to the file :

    sudo chmod 700 free.sh
    
  2. Run this command to check if freedns updated. Go to https://freedns.afraid.org/subdomain/ and check if destination option changed to your external IP

    sudo /home/pi/free.sh
    
  3. Use a cron job to make the script run every 5 minutes

    crontab -e
    
  • Add the following at the bottom of crontab:
*/5 * * * * sudo /home/pi/free.sh >/dev/null 2>&1

Optional:

  • Use DDclient instead to update IP for freedns.afraid.org, copy&paste text below in /etc/ddclient.conf:
daemon=5m
timeout=10
syslog=no # 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
# ssl-library

use=if, if=eth0
server=freedns.afraid.org
protocol=freedns
login=YOUR FREEDNS LOGIN
password=YOUR FREEDNS PASSWORD
your.freedns.domain
  • Use cron script

New Cron script(Update Interface v2) recently added [click here]


DONE !

DUCKDNS

  1. Create account at https://www.duckdns.org/

  2. Verfy reCAPTCHA and add any domain name

  1. Create a script to update DNS service:

    sudo nano duck.sh
    
  2. Copy&Paste this line but with your own domain name and token :

    echo url="https://www.duckdns.org/update?domains=YOURDOMAIN&token=YOURVALUE" | curl -k -o /home/pi/duck.log -K -
    
  • Get token on the site main page

  1. Set permission to the file :

    sudo chmod 700 duck.sh
    
  2. Run this command to check if duckdns updated. Go to https://www.duckdns.org/ and under CHANGED, you will see time updated

    sudo /home/pi/duck.sh
    
  3. Use a cron job to make the script run every 5 minutes

     sudo crontab -e
    
  • Add the following at the bottom of crontab:
*/5 * * * * sudo /home/pi/duck.sh >/dev/null 2>&1

DONE !

Clone this wiki locally