DDNS Client

If you want to set up a DDNS Server instead, please see ddns.server.

Using LuCI

DDNS stands for Dynamic DNS. Simply put, using this service gives a name to your ip. So if you're hosting something on your line, people wouldn't have to bother typing your IP. They can just type in your domain name! It also helps when your ip changes. Users won't need to discover what your new ip is, they can simply type your domain name.

First of all, you'll need to register to a DDNS. See the http://wiki.openwrt.org/doc/howto/ddns.client#requirements section below for a list of suggested DDNS providers.

This guide will help you configure your ddns service, so that your router auto-updates your ip to your ddns. The simplest method possible would be through LuCI (the default webUI for openwrt).

Step 1, install the packages

Login into your router through your browser. Go to Administration (top right) > System (top left) > Software > Update Package Lists Let it update, go back to Software. Find luci-app-ddns. Install it, then when it says the installation is finished, it's installed!

Just press any other link at the openwrt WebUI, and the WebUI will refresh itself and Dynamic DNS will appear under Services > Dynamic DNS. If those tabs don't show up, reboot the machine.

Step 2, configuration

Variable Description Example
enable Self explanatory none
Service Which DDNS do you use? Choose one dyndns
use_https If set to 1 DDNS updates use SSL
Host The DNS name of the ip, as configured in the DDNS site your.domain.name
Username Username of your DDNS yourusername
Password Password of your DDNS yourpassword
Source of IP-address This tells the router where to look for your actual WAN IP Address Usually at 'Network'
Network/Interface/URL If you choose Network, it would be the one negotiating your connection, in this case, the wan wan
Check for changed IP every Self Explanatory 10
Check-time unit The unit for the value above min
Force Update every Self explanatory 72
Force-time unit Unit for the value above hr

Step 3, You're done!

That's all you need to do! First update takes as long as the force update option is set to.

If the wan interface changes its address, the DDNS account is updated automatically. Additionally an unconditional update is sent periodically. The interval is specified by the force update option.

After initial configuration the ifup wan command can be used to force a DDNS update. Or, for Backfire, the following commands.

. /etc/profile # That's a period followed by a space
ifup wan

Using ddns-scripts

OpenWrt uses the package

ddns-scripts
for providing DDNS service.

Requirements

For a longer list of additional DDNS providers, see:

Installation

Install the ddns-scripts package.

opkg update
opkg install ddns-scripts

If you like to configure

ddns-scripts
using the LuCI WebUI also install this package:

opkg update
opkg install luci-app-ddns

Configuration

The configuration is stored in /etc/config/ddns which contains more thorough documentation.

In order to enable Dynamic DNS you need at least one section, and in that section the "enabled" option must be set to one.

Each section represents an update to a different service. This sections specifies several things:

  • service (dyndns.org, etc.)
  • domain (set this to all.dnsomatic.com for DNS-o-Matic)
  • username
  • password (sometimes it is the api token, not your login password)
  • IP source (wan, eth0, web)

Optionally, thse following may be specified:

  • option update_url (needed if the service isn't supported by /usr/lib/ddns/services)
  • check_interval
  • force_interval

Use the "check_interval" to specify how often to check whether an update is necessary, and the "force_interval" option to specify how often to force an update. Specify the units for these values with the "check_unit" and the "force_unit" options. Units can be "days", "hours", "minutes" or "seconds". The default force_unit is hours and the default check_unit is seconds. The default check_interval is 600 seconds, or ten minutes. The default force_interval is 72 hours or 3 days.

config service "myddns"
        option enabled          "0"
        option service_name     "dyndns.org"
        option domain           "mypersonaldomain.dyndns.org"
        option username         "myusername"
        option password         "mypassword"
        option ip_source        "network"
        option ip_network       "wan"
        option force_interval   "72"
        option force_unit       "hours"
        option check_interval   "10"
        option check_unit       "minutes"
        #option ip_source       "interface"
        #option ip_interface    "eth0.1"
        #option ip_source       "web"
        #option ip_url          "http://ipv4.wtfismyip.com/text"
        #option update_url      "http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]"
        #option use_https       "1"
        #option cacert          "/etc/ssl/certs/cacert.pem"

A short example for a dyndns.org service to configure via UCI CLI:

root@OpenWrt:~# uci set ddns.myddns.enabled=1
root@OpenWrt:~# uci set ddns.myddns.domain=host.dyndns.org
root@OpenWrt:~# uci set ddns.myddns.username=
root@OpenWrt:~# uci set ddns.myddns.password=
root@OpenWrt:~# uci set ddns.myddns.enabled=1
root@OpenWrt:~# uci commit ddns
root@OpenWrt:~# ACTION=ifup INTERFACE=wan /sbin/hotplug-call iface

An example for noip.com service that updates via pinging web url:

config 'service' 'myddns'
	option 'interface' 'wan'
	option 'force_interval' '72'
	option 'force_unit' 'hours'
	option 'check_interval' '10'
	option 'check_unit' 'minutes'
	option 'enabled' '1'
	option 'service_name' 'no-ip.com'
	option 'username' 'YOUR-USERNAME'
	option 'password' 'YOUR-PASSWORD'
	option 'ip_source' 'web'
	option 'ip_url' 'http://[USERNAME]:[PASSWORD]@dynupdate.no-ip.com/nic/update?hostname=[DOMAIN]&myip=[IP]'
	option 'domain' 'YOUR-DOMAIN.no-ip.org'

Trying it out

The script runs when hotplug events happen or a monitored IP address changes, so initially, you have to start it manually. After setting "enabled" to 1, run the following:

sh
. /usr/lib/ddns/dynamic_dns_functions.sh # note the leading period
start_daemon_for_all_ddns_sections "wan"
exit
,where "wan" is the name of the interface from /etc/config/ddns, which also has to match an interface from /etc/config/network. At this point you can verify that the dynamic DNS updater service is running by calling '# ps' from the command line and looking for '/usr/lib/ddns/dynamic_dns_updater.sh myddns 0' process.

You can also simulate a hotplug event to trigger a DDNS update manually:

root@OpenWrt:~# ACTION=ifup INTERFACE=wan /sbin/hotplug-call iface
where 'wan' is the interface name from /etc/config/network.

Debugging

If something goes wrong, you can see what is happenning by calling

/usr/lib/ddns/dynamic_dns_updater.sh myddns
Note: myddns is the name of the service config entry in /etc/config/ddns file.

If you only see the update_url= output you forgot the enable flag for the service.

For example if you see badauth in Update Output, you have to change your password which contains only letters and numbers. Because busybox's (v1.15.3) wget implementation has an issue handling encoded URLs.

Sometimes the scripts mess up and many instances of the updater will be fired. In this case, use this command to kill them all and start again

root@OpenWrt:~# ps | grep dynami[c] | awk '{print $1}' | xargs kill
root@OpenWrt:~# ACTION=ifup INTERFACE=wan /sbin/hotplug-call iface

Tweaks

Full API documentation available here: https://www.dyndns.com/developers/specs/syntax.html

To enable wildcard domains (*.foo.dyndns.org) on dyndns.org, replace the line in /usr/lib/ddns/services with:

"dyndns.org"            "http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?wildcard=ON&hostname=[DOMAIN]&myip=[IP]"

To retain the wildcard setting on dyndns.org, replace the line in /usr/lib/ddns/services with:

"dyndns.org"            "http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?wildcard=NOCHG&hostname=[DOMAIN]&myip=[IP]"

To add dyndns protocol compatible services like dyndns.it, add a line in /usr/lib/ddns/services with:

"dyndns.it"            "http://[USERNAME]:[PASSWORD]@dyndns.it/nic/update?hostname=[DOMAIN]&myip=[IP]"

To add dyndns protocol compatible services like no-ip.com, add a line in /usr/lib/ddns/services with:

"no-ip.org"            "http://[USERNAME]:[PASSWORD]@dynupdate.no-ip.com/nic/update?hostname=[DOMAIN]&myip=[IP]"

SSL support

By default ddns-scripts uses the wget program for DNS updates. Busybox provides its own version of wget, which does not support SSL. In order to use SSL (https) for updating the DNS info, you can either follow the instructions at SSL and Certificates in wget or install curl and see the correct way below. You will need to add the appropriate root certificate for your ddns provider.

Adding ddns ssl services

Edit /usr/lib/ddns/services and add "dnydns.org (SSL)"

# DDNS supporting HTTPS connections requires wget or curl with SSL/HTTPS support
"dyndns.org (SSL)"      "https://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]"
At this point you may use either either The Correct Method using curl or Using Wget.

The correct way

No need to modify /usr/lib/ddns/services. Automatic change of URI scheme from http to https is controlled by use_https option. Install curl and add the following to /etc/config/ddns (replace cacert path to the correct one, either a file or a directory):

option use_https        1
option cacert           /etc/ssl/certs/Example_CA.pem
Note that you need to download a Certificate Authority bundle as curl's pre-packaged bundle is out of date. Curl does maintain a current CA bundle here: http://curl.haxx.se/ca/

Curl SSLv2,3 Support

If your DDNS provider is using SSLv2 or SSLv3 Curl will throw error code 35 because it can't connect unless you specify the correct SSL version. To fix this, you must modify /usr/lib/ddns/dynamic_dns_updater.sh as such:

For SSLv2 replace –sslv3 with –sslv2

Find this string of code:

retrieve_prog="${retrieve_prog}--cacert $cacert "

Replace it with the following:

retrieve_prog="${retrieve_prog}--sslv3 --cacert $cacert "

Find this string of code:

retrieve_prog="${retrieve_prog}--capath $cacert "

Replace it with the following:

retrieve_prog="${retrieve_prog}--sslv3 --capath $cacert "

Using wget

If you want to stick to wget, then you should set SSL_CERT_DIR variable in /usr/lib/ddns/dynamic_dns_functions.sh before calling /usr/lib/ddns/dynamic_dns_updater.sh because /etc/profile is not sourced in daemon mode.

Self-Signed certificates

Note: this is also a workaround for the wget ssl bug mentioned on SSL and Certificates in wget#A Caveat

If your service provider uses a self-signed certificate, one options is to use the –no-check-certificate option with wget (read the disclaimer here: http://www.gnu.org/software/wget/manual/html_node/HTTPS-_0028SSL_002fTLS_0029-Options.html#HTTPS-_0028SSL_002fTLS_0029-Options).

Replace the retrieve_prog line in /usr/lib/ddns/dynamic_dns_updater.sh with this:

retrieve_prog="/usr/bin/wget --no-check-certificate -O - ";

An another workaround for wget's SSL bug and https://freedns.afraid.org (I've tested only this one.) is to install curl and replace the retrieve_prog line in /usr/lib/ddns/dynamic_dns_updater.sh with this:

retrieve_prog="/usr/bin/curl";

Using webif

FIXME

Packages

FIXME

updatedd updatedd-mod-dyndns updatedd-mod-noip luci webif

Other methods

DDNS scripts have been a surprisingly dynamic(lol) part of OpenWrt. There have been many other scripts and packages used.

Back to top

doc/howto/ddns.client.txt · Last modified: 2013/05/27 14:18 by puleglot