EdgeRouter Dynamic DNS Update for DNSMadeEasy

Ubiquiti EdgeRouters still don’t have built-in dynamic DNS (DDNS) support for DNSMadeEasy1 so I use the python client that they recommend2.

There’s limited space on most EdgeRouters, so don’t go installing pip; just grab the small number of libraries necessary and install them semi-manually.

  1. Open ssh to the EdgeRouter.

  2. Add Debian sources.
    set system package repository wheezy components 'main contrib non-free' 
    set system package repository wheezy distribution wheezy 
    set system package repository wheezy url http://http.us.debian.org/debian
  3. Install python-setuptools.
    sudo apt-get update && sudo apt-get install python-setuptools
  4. Grab the python code from https://github.com/wyrmiyu/ddns-tools/tree/master/dnsmadeeasy using
    cd /config/user-data
    mkdir ddns
    cd ddns
    curl https://raw.githubusercontent.com/wyrmiyu/ddns-tools/master/dnsmadeeasy/update_ddns_dnsmadeeasy.py -o ddns.py
    curl https://raw.githubusercontent.com/wyrmiyu/ddns-tools/master/dnsmadeeasy/settings.json.sample -o settings.json
  5. Grab our dependencies. For each of these, download the source .tar.gz file, untar it and install.
    • https://pypi.org/project/certifi/#files
    • https://pypi.org/project/urllib3/#files
    • https://pypi.org/project/idna/#files
    • https://pypi.org/project/chardet/#files
    • https://pypi.org/project/requests/#files
        curl (blah.tar.gz) -o blah.tar.gz
        tar zxvf blah.tar.gz
        cd (somefolder)
        sudo python setup.py install
        cd ..
        sudo rm -rf (somefolder)

      For example:

       curl https://files.pythonhosted.org/packages/4d/9c/46e950a6f4d6b4be571ddcae21e7bc846fcbb88f1de3eff0f6dd0a6be55d/certifi-2018.4.16.tar.gz -o certifi.tar.gz
       curl https://files.pythonhosted.org/packages/3c/d2/dc5471622bd200db1cd9319e02e71bc655e9ea27b8e0ce65fc69de0dac15/urllib3-1.23.tar.gz -o urllib3.tar.gz
       curl https://files.pythonhosted.org/packages/65/c4/80f97e9c9628f3cac9b98bfca0402ede54e0563b56482e3e6e45c43c4935/idna-2.7.tar.gz -o idna.tar.gz
       curl https://files.pythonhosted.org/packages/fc/bb/a5768c230f9ddb03acc9ef3f0d4a3cf93462473795d18e9535498c8f929d/chardet-3.0.4.tar.gz -o chardet.tar.gz
       curl https://files.pythonhosted.org/packages/54/1f/782a5734931ddf2e1494e4cd615a51ff98e1879cbe9eecbdfeaf09aa75e9/requests-2.19.1.tar.gz -o requests.tar.gz
  6. One more dependency, which is a zip file.
    • https://pypi.org/project/dnspython/#files
      curl https://files.pythonhosted.org/packages/e4/96/a598fa35f8a625bc39fed50cdbe3fd8a52ef215ef8475c17cabade6656cb/dnspython-1.15.0.zip -o dnspython.zip
      sudo apt-get install unzip
      unzip dnspython.zip
      cd (somefolder)
      sudo python setup.py install
      sudo apt-get remove unzip
  7. Using your favourite editor, modify settings.json and complete all fields.
    cd /config/user-data/ddns
    vi settings.json
  8. Test run and confirm it updates without error.
    /usr/bin/python /config/user-data/ddns/ddns.py
  9. Cleanup python-setuptools
    sudo apt-get remove python-setuptools
  10. Add it to your crontab. I’m assuming a TTL of 600 (10 minutes) for your DNS entry, so set this script to run every 10 minutes.
    crontab -e
    */10 * * * * /usr/bin/python /config/user-data/ddns/ddns.py