Linux IP Updater for Dynamic Networks

Follow

Comments

81 comments

  • Avatar
    deveretu

    that one-liner from madhusker seems like a good choice to run my (asus) router.  I don't care about the plain text psw.. no one else has access to the router.. so I look forward to giving it a try..

    I would rather have this update running as a windows service.. but I'm not in the mood for bothering with that anytime soon... unless there is already a setup script or other app for it.?

    I suppose I could put the command in the windows task scheduler just as easily.. at least there are quite a few easy ways to accomplish the same task..  thanks everyone for posting to this thread... it's actually very helpful to see the broad range of methods to solve the problem! 

  • Avatar
    mattwilson9090

    If you're going to do your updates in Windows just install the Updater app. It runs as a service, and there is no need to sort out a script, scheduling, or to put your password anywhere as plain text.

  • Avatar
    wsw70

    A more pythonic version (rather than using curl):

    >>> import requests
    >>> r = requests.get('https://updates.opendns.com/nic/update', auth=('yourlogin', 'yourpassword'))

    r.ok can be tested to ensure that the update was done (the result is in r.text)

     

  • Avatar
    zamanoof

    how can i use this method with DD-WRT Router ??

  • Avatar
    rotblitz
    1. You perform an internet search for: DD-WRT OpenDNS
    2. You will be landing at https://www.dd-wrt.com/wiki/index.php/OpenDNS
    3. You follow the instructions.
  • Avatar
    iceman24
    "Time for an update to this thread! /sbin/curl -v -k -u user@blah.com:PASSWORD https://updates.opendns.com/nic/update Put it in a cron job and forget it. Work well on my QNAP NAS." Can someone tell me how to do this. I did quite a bit of looking, but I'm not sure how people are editing things for acronyms are used too much, like VI. I can get to that file in my QNAP using WinSCP, but unsure of what else to do. Thanks.
  • Avatar
    rotblitz

    You'll want to visit a Linux specific forum for your query.  This here is for OpenDNS support, not for Linux support.

  • Avatar
    monsoft

    The easiest way to edit cron jobs is to use "crontab -e" command. It will open crontab file in editor (nano or vi depends on settings). After you need to schedule when run command:

    0 1 * * * /usr/bin/curl -k -u 'user@domain:password' https://updates.opendns.com/nic/update

     

    This will run this cronjob daily at 1AM. Location of curl will depends on your system setup. You can check it using "locate curl" command or if is not working using "find / -type f -name curl".

    You will expect to get answer from update which looks like this:

    $ good Your_IP

    where Your_IP is your current external IP address

     

     

  • Avatar
    piegope

    Please modify this to the article!

    1. You're login....

    2. If you have ......

    3. If you have special characters ...... And don't use ampersand (&) character in your password.

  • Avatar
    ilyass.researcher

    Guys please help me with this : IP Updater for OpenDNS using android ( My local network ) https://support.opendns.com/requests/222303
    Thank you very much

  • Avatar
    cobalt-phoenix

    Too bad that this thread is about Linux, not about Android... 
    Therefore you'll not get an answer here.

  • Avatar
    aheidrich

    Thanks for the Raspberry / no-ip config recommendation, exactly the same case for me. Mine doesn't work at the moment, despite I have reached a similar state: 

    opendns works in itself

    no-ip detto

    order may be relevant when using both.

    I am not at home at the moment, but my first job is going to be to check the differences when I get home later.

  • Avatar
    scott216

    I followed the instructions at the beginning of the post and installed this in my Raspberry Pi 2.  If my RPi reboots, will ddlcient start up automatically?  Or do I need to do something extra to make that happen?

     

  • Avatar
    el_garicimo (Edited )

    Alright, I did this a year ago and in doing it again to setup new linux laptops for my little cousins, found it wasn't quite working.

    When I manually switched networks from my cellphone hotspot to my home network, the ip associated with my OpenDns network on the OpenDns dashboard was not updating, and running ddclient in verbose debug mode was resulting in a nohost error.

    Long story short, I believe I had to register an OpenDns service at www.dnsomatic.com for it to all work ( and it does seem to be working now).

    Here are the full instructions I re-documented for myself:

    #### SETTING UP OPEN DNS CLIENT on Ubuntu for DynamicIPs #######
    # From https://www.youtube.com/watch?v=iuDCuUEmKF4 , my (el_garicimo 's)
    # comment on April 03, 2015 13:07 in
    https://support.opendns.com/hc/en-us/articles/227987727 , and also personal
    # trial and error

    1. make sure your OpenDns network_label is registered at www.opendns.com , set up as a dynamic ip network, that the option to update the ip is checked, and that
      your desired amount of content filtering is set -- see
      https://support.opendns.com/hc/en-us/articles/227987787-Dynamic-IP-General-Information-for-OpenDNS-usage
    2. Also need to add OpenDNS service at https://www.dnsomatic.com
    3. install ddclient from the terminal: sudo apt-get install ddclient
    4. DDCLIENT SETUP: select other, and type in updates.dnsomatic.com
    5. DDCLIENT SETUP: select dyndns2
    6. DDCLIENT SETUP: enter the username you set up on opendns
    7. DDCLIENT SETUP: enter the password you setup on opendns
    8. DDCLIENT SETUP: when it says network interface used for dynamic dns server,not applicable, so press enter
    9. DDCLIENT SETUP: DynDns fully qualified domain name:
           enter_your_open_dns_network_label
      (OpenDns doesn't host fully qualified domain names, it does recursive
      DNS lookup. In the youtube tutorial, it says enter all.dnsomatic.com, but
      just enter your openDns network label, and the config file should put it in the right spot)
    10. Afterwards, edit ddclient settings: run

      sudo nano /etc/default/ddclient

      , and change

      run_ipup="false"
      run_daemon="true"
      daemon_interval="3600"

      (daemon interval is in seconds, so 3600 is an hour, depends on freq. of IP address change)

      My /etc/default/ddclient looks like this:

      # generated from debconf on Sun Jan 8 23:37:47 EST 2017
      # Configuration for ddclient scripts
      #
      # /etc/default/ddclient

      # Set to "true" if ddclient should be run every time DHCP client ('dhclient'
      # from package isc-dhcp-client) updates the systems IP address.
      run_dhclient="false"

      # Set to "true" if ddclient should be run every time a new ppp connection is
      # established. This might be useful, if you are using dial-on-demand.
      run_ipup="false"

      # Set to "true" if ddclient should run in daemon mode
      # If this is changed to true, run_ipup and run_dhclient must be set to false.
      run_daemon="true"

      # Set the time interval between the updates of the dynamic DNS name in seconds.
      # This option only takes effect if the ddclient runs in daemon mode.
      daemon_interval="3600"

    11. similarly edit /etc/ddclient.conf and add
          daemon=3600
          ssl=yes
          use=web, web=myip.dnsomatic.com
          OPENDNSNETWORKNAME
      Your Open DNS Network Name should be the last line in the file, see
      https://support.opendns.com/hc/en-us/articles/227987727

      My /etc/ddclient.conf looks like this:

      # Configuration file for ddclient generated by debconf
      #
      # /etc/ddclient.conf

      daemon=3600
      use=web, web=myip.dnsomatic.com
      ssl=yes
      server=updates.dnsomatic.com
      protocol=dyndns2
      login=myOpenDnsLogin
      password='mypassword'
      myOpenDnsNetworkLabel

    12. to test if working: 
          sudo ddclient -daemon=0 -debug -verbose -noquiet
      because you have registered the OpenDNS service at dnsomatic.com, you should
      NOT get the nohost error

    13. need to do setup OpenDns servers in your Network connecitons, instructions
      at https://support.opendns.com/hc/en-us/articles/228007087-Ubuntu , but if you find that you can only edit individual networks,or you want to make sure that you will always be using OpenDNS' s name servers, then follow my comments in https://support.opendns.com/hc/en-us/articles/227987727/comments/115000163007
  • Avatar
    el_garicimo (Edited )

    @rotblitz (I assume you are an OpenDNS employee), if there was an OpenDNS documentation page on setting up ddclient, I think that would be very helpful for people trying to setup OpenDNS on their linux computers. I've done this before and am a software engineer, and I still had trouble doing it again after a year given the current documentation.

    I tried to document my steps in my recent comment, https://support.opendns.com/hc/en-us/articles/227987727?page=3#comment_115000136688

    Let me know if you agree, and if so feel free to take any of my steps.

    I think the main thing missing is pointing out that you need to register an OpenDns service at dnsomatic.com for a ddclient daemon to work.

    It would also be useful to walk people through the (what can be intimidating) setup process for installing ddclient , which I try to do in my steps.  Though I do note that you've posted a link to the ddclient documentation.

  • Avatar
    el_garicimo

    Here is how to make sure your computer is always using the Open DNS servers regardless of connection / network, if the linux distro you are using uses network manager to manage your networks (And if you are using a ubuntu derivative of linux, there is a good chance it is)

    First make sure you are indeed using the network manager, by running the following in your terminal:

    $ nmcli connection

    If that works, then you are indeed using network manager.

     

    You should be able to see what your dns nameserver is by seeing the contents of resolv.conf in /etc:

    $ cat /etc/resolv.conf

    You will probably see something like this:
    nameserver 127.0.1.1

    now, 127.0.1.1 is the IP address of your local computer, which is because these days, by default ubuntu makes dns queries by first going to your local computer so it can see check if things are discoverable on the network. This will always be there unless you comment out the following line in /etc/NetworkManager/NetworkManager.conf :

    change

    dns=dnsmasq

    to

    #dns=dnsmasq

    This is explained in http://askubuntu.com/questions/627899/nameserver-127-0-1-1-in-resolv-conf-wont-go-away

    The above prevents your local computer from always being inserted at the top of /etc/resolv.conf , but the contents of this file are created by what is in /etc/resolvconf/resolv.conf.d

    run the following below to edit the head file

    cd /etc/resolvconf/resolv.conf.d
    sudo cp -p head head.orig  #backup copy, always do this
    sudo nano head

    enter in the openDNS name servers:

    nameserver 208.67.222.222
    nameserver 208.67.220.220

    hit ctrl + x to exit , nano, you will be prompted to save, hit Y and then enter to save and save it as the same file name. This is from http://askubuntu.com/questions/130452/how-do-i-add-a-dns-server-via-resolv-conf

     

    Turn off your wifi, turn it back on , or do it via the terminal with 

    $ sudo service network-manager restart

    Then check the output of your reslov.conf file again, and you should see the opendns servers listed at the top:

    $ cat /etc/resolv.conf

    You can check if you are actually using the OpenDNS nameservers by using dig:

    dig google.com
  • Avatar
    nb5691

    @el_garicimo January 16, 2017 06:18

    Thank you for your detailed documentation. God bless you.

    the output of

    $ sudo cat /etc/resolv.conf

    why nameserver is appearing twice???

    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    nameserver 208.67.222.222
    nameserver 208.67.220.220
    nameserver 208.67.222.222
    nameserver 208.67.220.220

    the output of

    dig google.com is as follows :

    ; <<>> DiG 9.10.3-P4-Ubuntu <<>> google.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27468
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 4096
    ;; QUESTION SECTION:
    ;google.com. IN A

    ;; ANSWER SECTION:
    google.com. 300 IN A 172.217.26.174

    ;; Query time: 728 msec
    ;; SERVER: 208.67.222.222#53(208.67.222.222)
    ;; WHEN: Wed Jan 25 15:17:53 IST 2017
    ;; MSG SIZE rcvd: 55

    the output of

    $ nslookup -type=txt debug.opendns.com

    is as follows :

    Server:        208.67.222.222
    Address:    208.67.222.222#53

    Non-authoritative answer:
    debug.opendns.com    text = "server m2.lon"
    debug.opendns.com    text = "flags 20 0 70 7950800000000000000"
    debug.opendns.com    text = "originid 0"
    debug.opendns.com    text = "actype 0"
    debug.opendns.com    text = "source 180.215.123.242:13906"

    Authoritative answers can be found from:

     

  • Avatar
    el_garicimo

    @nb5691  , looks like you're good. You shouldn't worry about the name servers being there multiple times -- it's probably coming from the head, and then the fact that you probably set it in the network manager GUI (Graphical User Interface) too.

     

    but the must important thing is that you are indeed using the OpenDNS servers when making that request , which you can see from what you said here:

    the output of

    dig google.com is as follows :

    ; <<>> DiG 9.10.3-P4-Ubuntu <<>> google.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27468
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 4096
    ;; QUESTION SECTION:
    ;google.com. IN A

    ;; ANSWER SECTION:
    google.com. 300 IN A 172.217.26.174

    ;; Query time: 728 msec
    ;; SERVER: 208.67.222.222#53(208.67.222.222)
    ;; WHEN: Wed Jan 25 15:17:53 IST 2017
    ;; MSG SIZE rcvd: 55
  • Avatar
    clinton.bester74

    I dont know if its just me, but the ddclient is no longer hosted on Sourceforge, seems either something i broken or its just the site

  • Avatar
    rotblitz

  • Avatar
    nb5691 (Edited )

Please sign in to leave a comment.