Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Dynamic DNS update by hand?

    Scheduled Pinned Locked Moved DHCP and DNS
    12 Posts 5 Posters 8.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wrodina
      last edited by

      I'm using pfSense's Dynamic DNS setup for my provider (ZoneEdit), but I would like to add an additional update for a service that isn't supported in the listing (OpenDNS).

      As near as I can figure, this should be as simple as accessing the following URL:

      https://username:password@updates.opendns.com/nic/update?hostname=

      (Yes, nothing following the "hostname" parameter. The above URL works correctly when entered by hand.)

      I was intending to add this using wget as a cron job, but I am having difficulty getting the wget package installed (dependency hell).

      Is there a simpler way to "touch" a website for this kind of update? I'm assuming it happens for the normal dynamic DNS updates, but I can't quite put my finger on where that takes place when I'm looking at a shell prompt. I've seen where it's possible to add another provider to the list, but I want to keep the ZoneEdit update in addition to doing the OpenDNS update.

      1 Reply Last reply Reply Quote 0
      • P
        Perry
        last edited by

        Try searching for curl on forum & google

        /Perry
        doc.pfsense.org

        1 Reply Last reply Reply Quote 0
        • W
          wrodina
          last edited by

          I actually know what curl is, and I had done that search before. All I seem to find on the forums here are various php codeblocks that involve curl… which I'm not familiar with. Also, doing a "find" at the shell prompt doesn't seem to locate the curl executable.

          Is the curl command available via command prompt? If so, which directory is it hiding in?

          If php is the only way to use curl, is the syntax documented somewhere? It looks particular to pfSense in the forum postings I've found.

          (Happy to RTFM, if someone can help me find the FM.)

          • Thanks.
          1 Reply Last reply Reply Quote 0
          • W
            wrodina
            last edited by

            Anyone?

            1 Reply Last reply Reply Quote 0
            • M
              Monoecus
              last edited by

              why don't you run this url with curl in a cron job?

              1 Reply Last reply Reply Quote 0
              • W
                wrodina
                last edited by

                Yes… that's my idea. I just can't seem to find the curl executable anywhere!

                find / -name curl doesn't give me any results.

                I was actually able to add the functionality I needed by adding DNS-O-Matic as a dynamic DNS provider… but it would still be handy to know where to find curl/wget if they are already installed.

                1 Reply Last reply Reply Quote 0
                • F
                  Falcon4
                  last edited by

                  Curl isn't an executable. It's part of PHP.

                  You initialize it, configure it, then run it. It's really "that simple". Typically, things in PHP are done with one function call, but cURL actually takes a more flexible approach since there are so many things you can configure with cURL. You initialize a cURL "object", tell it what to do, then tell it to do it. In your case, grab a cURL object, tell it to request that page and not return any data, execute it, then tell it to go away. Simple as that ;)

                  (And no, I'm too tired to come up with any code… sorry :()

                  edit: in the case of cron, you should be able to "cron" the PHP executable (... right?) and give it the path of a PHP script. Since cURL isn't a standalone executable, you need to run it as part of PHP somehow.

                  1 Reply Last reply Reply Quote 0
                  • W
                    wrodina
                    last edited by

                    Ok… well, the cURL I'm familiar with is an executable (like wget):

                    http://curl.haxx.se/

                    So I'm understanding that the cURL program proper may not be installed, but PHP has in-built support for the function (via libcurl). Gotcha.

                    From their website, looks like a variant of this code would do the trick:

                    //
                    // A very simple example that gets a HTTP page.
                    //
                    
                    $ch = curl_init();
                    
                    curl_setopt ($ch, CURLOPT_URL, "http://www.zend.com/");
                    curl_setopt ($ch, CURLOPT_HEADER, 0);
                    
                    curl_exec ($ch);
                    
                    curl_close ($ch);
                    ?>
                    
                    1 Reply Last reply Reply Quote 0
                    • P
                      Perry
                      last edited by

                      My solution to update DNS at opendns.org and gratisdns.dk

                      $ch = curl_init();
                      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                      //************ OpenDNS *******************
                      Echo "Updating OpenDNS \n";
                      curl_setopt($ch, CURLOPT_URL, "https://username:password@updates.opendns.com/nic/update?hostname=");
                      $result = curl_exec($ch);
                      Echo "\n Done \n";
                      //************ GratisDNS *****************
                      Echo "Updating GratisDNS \n";
                      curl_setopt($ch, CURLOPT_URL, "https://ssl.gratisdns.dk/ddns.phtml?u=username&p=password&d=domain&h=hostname");
                      $result = curl_exec($ch);
                      curl_close ($ch);
                      ?>
                      

                      Add it as a cronjob in the config.xml
                      If your ip doesn't change very often you can use this script to make the check locally and only update when needed

                      #!/bin/sh
                      # 
                      # Update ip address on opendns.org and gratisdns.dk from crontab. It only returns output if 
                      # changed.
                      # 
                      # Requirements: 
                      #       - crontab entry, ie: "*/5 * * * * /usr/local/etc/rc.d/OpenAndGratisDNS.sh"
                      #       - /usr/local/www/OpenAndGratisDNS.php
                      #
                      ext_if="Your_Wan_Nic_Name" 
                      dns_file="/var/run/OpenAndGratisDNS.ip"
                      update_file="/usr/local/bin/php /usr/local/www/OpenAndGratisDNS.php"
                      
                      EXIT_SUCCESS=0             
                      EXIT_FAILURE=1
                      
                      if [ `id -u` -ne 0 ]
                      then
                              echo "Only root may run this program."
                              exit $EXIT_FAILURE
                      fi
                      
                      usage(){
                              echo "Usage: $0"
                      }
                      
                      get_ip(){
                              if [ -f $dns_file ]
                              then
                                      registered_ip=`cat ${dns_file}`
                              else
                                      registered_ip=""
                              fi
                              current_ip=`ifconfig ${ext_if} | awk '/inet / { print $2 }'`
                      }
                      
                      update_hosts(){
                              if [ "$registered_ip" != "$current_ip" ]
                              then
                                      echo "Local ip address changed, updating dns entries.. "
                                      echo
                                      $update_file
                                      echo
                                      echo "done."
                                      echo "Registering new ip.. "
                                              echo $current_ip > $dns_file
                                      echo "done."
                              fi
                      }
                      
                      #
                      # Main 
                      #
                      get_ip
                      update_hosts
                      
                      exit $EXIT_SUCCESS
                      

                      Hope it helps

                      Btw. The owner of gratisdns.dk are using pfSense (pic and danish text here) hosting 12% of all .dk and a total of over 150000 domains.

                      OpenAndGratisDNS.php.txt
                      OpenAndGratisDNS.sh.txt

                      /Perry
                      doc.pfsense.org

                      1 Reply Last reply Reply Quote 0
                      • W
                        wrodina
                        last edited by

                        Ah, very cool. Thanks much.

                        1 Reply Last reply Reply Quote 0
                        • E
                          eri--
                          last edited by

                          Btw. The owner of gratisdns.dk are using pfSense (pic and danish text here) hosting 12% of all .dk and a total of over 150000 domains.

                          Well i think they could support somewhat since 1.3 will have all that an ISP supports begining from shaping, ability to block or shape P2P or other protocols by the addition of an application layer comparable to l7-filter of linux. :)

                          1 Reply Last reply Reply Quote 0
                          • P
                            Perry
                            last edited by

                            I've seen them support some FreeBSD coding before so who knows :)

                            /Perry
                            doc.pfsense.org

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post
                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.