Difference between revisions of "Dynamic DNS"

From ArchWiki
Jump to: navigation, search
(Router: rewrite to clarify benefits)
(Undo revision 539635 by ZombB (talk) sorry, freeDNS was allready mentioned above)
(48 intermediate revisions by 17 users not shown)
Line 1: Line 1:
 
[[Category:Domain Name System]]
 
[[Category:Domain Name System]]
 +
[[ja:ダイナミック DNS]]
 
'''Dynamic DNS''' or '''DDNS''' is a method of updating, in real time, a [[DNS]] to point to a changing IP address on the Internet. This is used to provide a persistent domain name for a resource lacking a static IP. To use DDNS, you need to both sign up with a DDNS provider and set up an automatic update tool that will notify the provider when your IP address changes.
 
'''Dynamic DNS''' or '''DDNS''' is a method of updating, in real time, a [[DNS]] to point to a changing IP address on the Internet. This is used to provide a persistent domain name for a resource lacking a static IP. To use DDNS, you need to both sign up with a DDNS provider and set up an automatic update tool that will notify the provider when your IP address changes.
  
== DDNS Update Tools ==
+
== Update tools ==
  
 
=== Router ===
 
=== Router ===
Line 10: Line 11:
 
=== ddclient ===
 
=== ddclient ===
  
The package {{Pkg|ddclient}} is available in the [[community]] repository. It includes [[systemd]] support and can be used with a range of Dynamic DNS providers.
+
{{Pkg|ddclient}} is compatible with many DDNS services and is the recommended tool for updating DDNS if your [[#Router|router]] is not an option. It includes [[systemd]] support.
  
To use the service, [[enable]] and [[start]] the {{ic|ddclient.service}} unit after filling in the configuration file {{ic|/etc/ddclient/ddclient.conf}}. An example which updates an Afraid.org account looks like this:
+
After installing, edit the default config {{ic|/etc/ddclient/ddclient.conf}} to set up your DDNS provider (it includes many examples). Then [[enable]] and [[start]] {{ic|ddclient.service}}.
  
{{hc|/etc/ddclient/ddclient.conf|2=
+
Some of the compatible services are listed below, but you can also check the [http://sourceforge.net/p/ddclient/code/HEAD/tree/trunk/sample-etc_ddclient.conf examples] and [http://sourceforge.net/p/ddclient/wiki/protocols/ protocols] for more.
daemon=600
 
cache=/tmp/ddclient.cache
 
syslog=yes
 
pid=/var/run/ddclient.pid
 
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
 
 
 
ssl=yes
 
 
 
## Configuration variables applicable to the 'freedns' protocol are:
 
#  protocol=freedns            ##
 
#  server=fqdn.of.service      ## defaults to freedns.afraid.org
 
#  login=service-login          ## login name and password registered with the service
 
#  password=service-password    ##
 
#  fully.qualified.host        ## the host registered with the service.
 
#
 
protocol=freedns
 
login=my-freedns.afraid.org-login
 
password=my-freedns.afraid.org-password
 
myhost1.afraid.org
 
myhost2.afraid.org
 
}}
 
 
 
==== Starting ddclient after networking is up ====
 
 
 
In some installs, it appears that enabling the {{ic|ddclient.service}} unit will cause it to start the ddclient process before networking is properly up. The ddclient process is then unable to properly lookup the domain names required and does not retry the lookup later, making the process useless.
 
 
 
Set ddclient to start when the {{ic|network-online.target}} is reached by editing {{ic|ddclient.service}} with {{ic|systemctl edit --full ddclient.service}} and adding or modifying the emphasized lines:
 
 
 
{{hc|/etc/systemd/system/ddclient.service|2=
 
[Unit]
 
Description=Dynamic DNS Update Client
 
After=network.target
 
'''PartOf=network-online.target'''
 
 
 
[Service]
 
Type=forking
 
PIDFile=/var/run/ddclient.pid
 
ExecStart=/usr/bin/ddclient
 
 
 
[Install]
 
'''WantedBy=network-online.target'''
 
}}
 
 
 
{{Note|
 
* A full replacement must be created, because a drop-in override cannot modify the {{ic|[Install]}} section of a unit file. Make sure to disable and reenable the {{ic|ddclient.service}} so that the symlink is put into the right place.
 
* It may be necessary to configure the network manager to activate {{ic|network-online.target}} (for [[netctl]] see [[netctl#Activate network-online.target]]).
 
}}
 
 
 
==== Compatible Services ====
 
  
 
{| class="wikitable"
 
{| class="wikitable"
 +
|+ ddclient compatible services
 
! Service
 
! Service
 
! Cost
 
! Cost
! Records
+
! Available Records
 
! Hostname Limit
 
! Hostname Limit
 
! Config Notes
 
! Config Notes
 
! Alternative tools
 
! Alternative tools
 
|-
 
|-
! [http://freedns.afraid.org/ FreeDNS]
+
! [http://now-dns.com/ Now-DNS]
| Free or paid || CNAME, A, AAAA, MX, NS, TXT, LOC, RP, HINFO, SRV || 5 free || [http://freedns.afraid.org/scripts/freedns.clients.php example] || {{aur|afraid-dyndns-uv}}, {{aur|petrified}}
+
| Free || A, AAAA || unlimited || [https://now-dns.com/client/ddclient.conf example] ||
 +
|-
 +
! [http://www.changeip.com/ ChangeIP]
 +
| Free or paid || A, AAAA, CNAME, MX, codomains || 7 free || [https://sourceforge.net/p/ddclient/wiki/protocols/#changeip example] ||  
 
|-
 
|-
 
! [http://www.dnsdynamic.org/ DNSdynamic]
 
! [http://www.dnsdynamic.org/ DNSdynamic]
 
| Free || || || [https://www.dnsdynamic.org/api.php example] ||
 
| Free || || || [https://www.dnsdynamic.org/api.php example] ||
 +
|-
 +
! [https://www.duckdns.org/ Duck DNS]
 +
| Free || || || [https://sourceforge.net/p/ddclient/wiki/protocols/#duckdns example] || {{aur|duckdns}}
 +
|-
 +
! [http://freedns.afraid.org/ FreeDNS]
 +
| Free or paid || CNAME, A, AAAA, MX, NS, TXT, LOC, RP, HINFO, SRV || 5 free || [http://freedns.afraid.org/scripts/freedns.clients.php example] || {{aur|afraid-dyndns-uv}}, {{aur|petrified}}
 
|-
 
|-
 
! [http://www.noip.com/ No-IP]
 
! [http://www.noip.com/ No-IP]
| Free or paid || || 3 free, 25+ paid || Use protocol {{ic|dyndns2}}, server {{ic|dynupdate.noip.com}} || {{aur|noip}}
+
| Free or paid || || 3 free, 25+ paid || Use protocol {{ic|noip}}, server {{ic|dynupdate.no-ip.com}} || {{aur|noip}}
 
|-
 
|-
 
! [https://www.nsupdate.info/ nsupdate.info]
 
! [https://www.nsupdate.info/ nsupdate.info]
 
| Free and open source || A, AAAA || || Use protocol {{ic|dyndns2}} || {{aur|inadyn-fork}}
 
| Free and open source || A, AAAA || || Use protocol {{ic|dyndns2}} || {{aur|inadyn-fork}}
 
|-
 
|-
! [https://www.duckdns.org/ Duck DNS]
+
! [https://dyn.com/dns/ Dyn DNS]
| Free || || || || {{aur|duckdns}}
+
| Free or paid || A, CNAME, MX ||  || [https://sourceforge.net/p/ddclient/wiki/protocols/#dyndns2 example] || {{aur|ndyndns}}
 +
|-
 +
! [https://www.namecheap.com/ Namecheap]
 +
| Paid || A, CNAME || || [https://sourceforge.net/p/ddclient/wiki/protocols/#namecheap example] || {{aur|ndyndns}}
 +
|-
 
|-
 
|-
! [http://www.changeip.com/ ChangeIP]
+
! [https://www.dynu.com/ Dynu]
| Free or paid || A, AAAA, CNAME, MX, codomains || 7 free || ||  
+
| Free or paid || || 4 free, 500 paid || [https://www.dynu.com/DynamicDNS/IPUpdateClient/DDClient example] ||
 
|-
 
|-
 
|}
 
|}
 +
{{Note| Free users of no-ip are required to manually confirm their domain(s) every 30 days. Domain confirmation is not required for Enhanced users though. More info at [http://www.noip.com/support/knowledgebase/why-is-my-hostname-pending-deletion/ Why is My Hostname Pending Deletion?]}}
  
=== Other ===
+
==== Use an external website to determine IP address  ====
  
There are other DDNS updaters that work with several providers including:
+
If ddclient is unable to detect your IP address, you can configure ddclient to fetch your IP from an external webpage such as [http://whatismyip.org/ whatismyip.org]. Add somewhere in the config file:
  
; inadyn-mt: In the [[AUR]] as {{AUR|inadyn-mt}}. Supports a large number of providers as [http://sourceforge.net/projects/inadyn-mt listed here].
+
{{hc|/etc/ddclient/ddclient.conf|2=
; ndyndns: In the [[AUR]] as {{AUR|ndyndns}}. Update client for the dynamic DNS services from DynDNS and Namecheap.
+
# use whatismyip.org to determine IP address
 +
use=web
 +
web=whatismyip.org
 +
}}
  
== Dynamic DNS Providers ==
+
==== Starting ddclient after networking is up ====
  
There are many different DDNS providers and some are supported by official or third-party tools. A partial list is given below. Many of these providers are also supported by the generic tools listed in the [[#Tools Supporting Multiple Dynamic DNS Services|section]] below.
+
If you find that ddclient is unable to update your IP properly, it may be that the ddclient process is starting before networking is up. To fix it, you can edit the unit file to depend on {{ic|network-online.target}}:
  
=== Afraid and Now-IP===
+
{{hc|# systemctl edit ddclient.service|2=
[http://FreeDNS.afraid.org FreeDNS.afraid.org] and [https://now-ip.com Now-IP.com] are free services which are easy and uncomplicated to set up.  
+
[Unit]
 +
After=network-online.target
 +
Wants=network-online.target
 +
}}
  
There are several options to enable automatic DDNS updating for these providers:
+
Additional configuration for {{ic|network-online.target}} may be necessary, see [https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget#cutthecraphowdoimakenetwork.targetworkforme].
  
; afraid-dyndns: The package {{AUR|afraid-dyndns-uv}} is available in the [[AUR]].
+
=== Other tools ===
; petrified: The package {{AUR|petrified}} is available in the [[AUR]].
 
; cron
 
: A cron job to update the service can be configured as follows:
 
* Goto your [http://freedns.afraid.org/dynamic/index.php Dynamic DNS] page at freedns.afraid.org
 
* Add A record and select your prefered domain name
 
* Press '''quick cron example''' behind the desired A record
 
* Test one of the examples:
 
curl http://freedns.afraid.org/dynamic/update.php?Ukd...
 
* Use {{ic|crontab -e}} to insert the new cronjob:
 
*/6 * * * * sleep 20 ; curl http://freedns.afraid.org/dynamic/update.php?Ukd...Dk2 > /tmp/freedns_my_ddns_record.com.log 2>&1 &
 
; netctl:
 
To add the record of your IP to freedns.afraid.org along with a network connection through the use with [[Netctl]]. You can append the following line to your netctl profile.
 
{{bc|<nowiki>ExecUpPost='curl -ks http://freedns.afraid.org/dynamic/update.php?ZRRJZ...................bzo4Njc1M4DA'</nowiki>}}
 
  
=== DNSdynamic ===
+
Other DDNS updaters that work with several providers are {{AUR|inadyn-mt}} ([http://sourceforge.net/projects/inadyn-mt supported providers]) and {{AUR|ndyndns}} (supports DynDNS and Namecheap).
  
[http://www.dnsdynamic.org/ DNSdynamic] "will always be absolutely free" and works with {{Pkg|ddclient}}. [https://www.dnsdynamic.org/api.php This page] has information on how to configure {{Pkg|ddclient}}.
+
== Other providers ==
 +
 
 +
The following DDNS providers are not compatible with [[#ddclient|ddclient]] so updating your IP with them may require a special tool or some custom scripting. Remember that if the service allows you to update your IP using the command line, you can automate the process using tools such as [[cron]] or [[systemd/Timers]].
  
 
=== duiadns ===  
 
=== duiadns ===  
[https://www.duiadns.net Duiadns.org]. The package {{AUR|duiadns}}{{Broken package link|{{aur-mirror|duiadns}}}} is available in the [[AUR]].
+
[https://www.duiadns.net Duiadns.org] is a free service.
  
=== No-IP ===
+
=== FreeDns.io ===
 
 
{{AUR|noip}} is a dynamic DNS client updater for [http://www.noip.com no-ip.com] services.
 
  
Configure the client by running
+
[https://freedns.io FreeDns.io] provides free A and AAAA DNS records and CNAME, TXT and MX records with a premium membership. You can update your IP using their HTTP API (with a 60 requests-per-hour limit). They provide [https://github.com/nkovacne/freedns-samples several example scripts].
  
# noip2 -C
+
=== Now-DNS ===
 
+
[https://now-dns.com Now-DNS.com] is a free service which is easy and uncomplicated to set up.
See {{ic|noip2 -h}} for more options. [[Start]] {{ic|noip2.service}} to run the host updater and [[enable]] it to run automatically at boot.
 
 
 
=== nsupdate.info ===
 
[https://www.nsupdate.info/ nsupdate.info] is a free and open source dynamic DNS service. One can use {{AUR|inadyn-fork}} to update the ip. An example configuration:
 
{{hc|/etc/inadyn.conf|<nowiki>
 
background
 
verbose        5
 
period        300
 
cache-dir      /mnt/ddns
 
startup-delay  60
 
syslog
 
 
 
#logfile /var/log/ddns.log
 
#pidfile /var/run/ddns.pid
 
 
 
system ipv4@nsupdate.info
 
ssl
 
username your_host_name.nsupdate.info
 
password PassWoRd_given_on_site
 
alias your_host_name.nsupdate.info
 
</nowiki>}}
 
You should then [[start]] {{ic|inadyn.service}} and [[enable]] it to automatically start on boot.
 
  
 
=== System-NS ===
 
=== System-NS ===
  
[http://system-ns.com/ System-NS] free DNS service. It can be configured to update using a cron script through the following steps. Make a directory and create a script file within it:
+
[http://system-ns.com/ System-NS] is a free service which can be updated via the command line. See [https://system-ns.com/services/dynamic the official documentation].
$ cd ~
 
$ mkdir systemns
 
$ cd systemns
 
$ vi systemns.sh
 
Put the following text in systemns.sh. You should change the domain and token parameters.
 
#!/bin/bash
 
wget -q -O- --post-data "type=dynamic&domain=mydomain.system-ns.net&command=set&token=880078764367979fe765c0fa3f4efff1" http://system-ns.com/api | grep -v '"code":0' | awk '{print d, $0}' "d=$(date)" >> ~/systemns/systemns.log
 
Make the systemns.sh file executable.
 
$ chmod +x systemns.sh
 
Open crontab.
 
$ crontab -e
 
Put this text in the crontab (run every 5 minutes)
 
*/5 * * * * ~/systemns/systemns.sh
 
 
 
=== DuckDNS ===
 
 
 
{{AUR|duckdns}} is a dynamic DNS client updater for [https://duckdns.org DuckDNS.org] services. After installation go to your {{ic|/etc/duckdns.d}} and copy/edit the {{ic|default.cfg}}. Just enter the hostname and token you received from DuckDNS. Any file ending on {{ic|.cfg}} will be read by the script and used to contact the DuckDNS services. The script also writes debug messages to logger.
 
 
 
Do not forget to [[enable]] the duckdns.timer so your IP will be updated every 5 minutes.
 
 
 
=== FreeDns.io ===
 
 
 
[https://freedns.io FreeDns.io] is a dynamic DNS provider. They provide free A and AAAA DNS records for free, and optionally you can apply for a Premium account which includes CNAME, TXT and MX records.
 
 
 
They provide an API which can be called from a script written in any of the most used programming languages, including PHP, Python and Ruby. Samples might be reached [https://github.com/nkovacne/freedns-samples here]. Once chosen and copied to the machine which will update the host, a cron-job should be created in this form:
 
 
 
*/5 * * * * ~/update-my-freedns-host
 
 
 
(Assuming the ~/update-my-freedns-host script has execution permissions)
 
 
 
This provider allows up to 60 requests per hour, so even a cron-job run every minute is ok, because if your IP doesn’t change in two consecutive requests, it’s not considered a “hit”.
 
  
=== ChangeIP ===
+
=== Loopia.se ===
  
[https://changeip.com ChangeIP.com] provides free A, AAAA, CNAME, MX, URL DNS records, you can also apply for free codomain like {ic|git.example.changeip.com} and many more.
+
If you use loopia.se as name server, you can query updates of DNS records via ''curl'' as described in the [https://support.loopia.se/wiki/curl/ official documentation].
  
They provide easy [http://www.changeip.com/accounts/knowledgebase.php?action=displayarticle&id=34 api] such as {ic|curl -u 'user:pass' https://nic.ChangeIP.com/nic/update}.
+
If you use 2FA for login, or by some other reason would rather use the LoopiaAPI via a python script to change the DNS dynamically, you should follow the instructions [https://support.loopia.se/wiki/uppdatera-dynamisk-ip-adress-med-loopiaapi/ on this page]. The python file is well written and easy to understand, and basically all you need to do is to generate an API key on your login at Loopia kundzon first.

Revision as of 17:13, 4 September 2018

Dynamic DNS or DDNS is a method of updating, in real time, a DNS to point to a changing IP address on the Internet. This is used to provide a persistent domain name for a resource lacking a static IP. To use DDNS, you need to both sign up with a DDNS provider and set up an automatic update tool that will notify the provider when your IP address changes.

Update tools

Router

If the device needing DDNS sits behind a router, you should first check if the router itself can update any DDNS services. Although the selection of services may be limited, there are several advantages to using the router: it will probably be easier to set up, will require little to no maintenance, and will have no downtime (if the router is down you won't have Internet anyway).

ddclient

ddclient is compatible with many DDNS services and is the recommended tool for updating DDNS if your router is not an option. It includes systemd support.

After installing, edit the default config /etc/ddclient/ddclient.conf to set up your DDNS provider (it includes many examples). Then enable and start ddclient.service.

Some of the compatible services are listed below, but you can also check the examples and protocols for more.

ddclient compatible services
Service Cost Available Records Hostname Limit Config Notes Alternative tools
Now-DNS Free A, AAAA unlimited example
ChangeIP Free or paid A, AAAA, CNAME, MX, codomains 7 free example
DNSdynamic Free example
Duck DNS Free example duckdnsAUR
FreeDNS Free or paid CNAME, A, AAAA, MX, NS, TXT, LOC, RP, HINFO, SRV 5 free example afraid-dyndns-uvAUR, petrifiedAUR
No-IP Free or paid 3 free, 25+ paid Use protocol noip, server dynupdate.no-ip.com noipAUR
nsupdate.info Free and open source A, AAAA Use protocol dyndns2 inadyn-forkAUR
Dyn DNS Free or paid A, CNAME, MX example ndyndnsAUR
Namecheap Paid A, CNAME example ndyndnsAUR
Dynu Free or paid 4 free, 500 paid example
Note: Free users of no-ip are required to manually confirm their domain(s) every 30 days. Domain confirmation is not required for Enhanced users though. More info at Why is My Hostname Pending Deletion?

Use an external website to determine IP address

If ddclient is unable to detect your IP address, you can configure ddclient to fetch your IP from an external webpage such as whatismyip.org. Add somewhere in the config file:

/etc/ddclient/ddclient.conf
# use whatismyip.org to determine IP address
use=web
web=whatismyip.org

Starting ddclient after networking is up

If you find that ddclient is unable to update your IP properly, it may be that the ddclient process is starting before networking is up. To fix it, you can edit the unit file to depend on network-online.target:

# systemctl edit ddclient.service
[Unit]
After=network-online.target
Wants=network-online.target

Additional configuration for network-online.target may be necessary, see [1].

Other tools

Other DDNS updaters that work with several providers are inadyn-mtAUR (supported providers) and ndyndnsAUR (supports DynDNS and Namecheap).

Other providers

The following DDNS providers are not compatible with ddclient so updating your IP with them may require a special tool or some custom scripting. Remember that if the service allows you to update your IP using the command line, you can automate the process using tools such as cron or systemd/Timers.

duiadns

Duiadns.org is a free service.

FreeDns.io

FreeDns.io provides free A and AAAA DNS records and CNAME, TXT and MX records with a premium membership. You can update your IP using their HTTP API (with a 60 requests-per-hour limit). They provide several example scripts.

Now-DNS

Now-DNS.com is a free service which is easy and uncomplicated to set up.

System-NS

System-NS is a free service which can be updated via the command line. See the official documentation.

Loopia.se

If you use loopia.se as name server, you can query updates of DNS records via curl as described in the official documentation.

If you use 2FA for login, or by some other reason would rather use the LoopiaAPI via a python script to change the DNS dynamically, you should follow the instructions on this page. The python file is well written and easy to understand, and basically all you need to do is to generate an API key on your login at Loopia kundzon first.