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

    Cron rc.dyndns.update issues

    DHCP and DNS
    2
    2
    3.1k
    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.
    • F
      FreeMinded
      last edited by

      Hi all

      I'm using Dynamic DNS (with nsupdate.info) and have some issues with the cron job supposed to update the dyndns at least once a day.

      1. What does /etc/rc.dyndns.update do exactly? This blog post http://www.andysblog.de/pfsense-mit-ddns-hinter-einem-router in german suggests that it checks it's real WAN IP by using an external service. From looking at the source I can't see this happening. But I'm not a coder and therefore I probably miss looking at right place.

      2. Running /etc/rc.dyndns.update from the command line in the webGUI renders the webGUI inresponsive and needs a reboot in order to get it working again. How can I run /etc/rc.dyndns.update manually?

      3. What is the suggested way to handle Dynamic DNS in the case of a pfSense having a static IP on the WAN behind a ISP DSL router? Some posts suggest to increase the frequency of the mentioned cron job. But for that it should work properly in the first place.

      The crontab entry looks like this (it's from the standard settings and I didn't change anything)
      1  1  *  *  *  root  /usr/bin/nice -n20 /etc/rc.dyndns.update

      Any help is appreciated!

      1 Reply Last reply Reply Quote 0
      • I
        InAr
        last edited by

        @FreeMinded:

        1. What does /etc/rc.dyndns.update do exactly? This blog post http://www.andysblog.de/pfsense-mit-ddns-hinter-einem-router in german suggests that it checks it's real WAN IP by using an external service. From looking at the source I can't see this happening. But I'm not a coder and therefore I probably miss looking at right place.

        Thank you for pointing to this page, it may have solved my problem with updating the ips for the dynamic dns entries.
        /etc/rc.dyndns.update uses code from /etc/inc/dyndns.class. This dyndns.class file uses checkip.dyndns.org for getting the routers online ip.
        As described in your linked article I have installed the cron package and edited the dyndns entry to check for an ip update every 10 minutes.
        I have changed the dyndns.class file according to this description to use a custom webpage with a simple php file to get my online ip from.

        @FreeMinded:

        2. Running /etc/rc.dyndns.update from the command line in the webGUI renders the webGUI inresponsive and needs a reboot in order to get it working again. How can I run /etc/rc.dyndns.update manually?

        By executing "/etc/rc.dyndns.update" via ssh or via gui editing the dynamic dns entry and press the save & force update button does work for me.

        @FreeMinded:

        3. What is the suggested way to handle Dynamic DNS in the case of a pfSense having a static IP on the WAN behind a ISP DSL router? Some posts suggest to increase the frequency of the mentioned cron job. But for that it should work properly in the first place.

        As the dynamic dns update script uses checkip.dyndns.org to monitor the pfs online ip it should notice an ip change and update the entries correctly.
        For me the check can't extract an correct ip from this url sometimes and it looks like the service isn't retrying correctly when such a failure happens. This failure will be listed under "Status->Systems Logs".
        I hope all the changes from 1. will fix the problems for me. I'll have to wait a few days to be sure it really works.

        My changes to dyndns.class function _checkIP()  – (PFSense version 2.3.1-RELEASE-p1):

        		function _checkIP() {
        			global $debug;
        
        			if ($debug) {
        				log_error(sprintf(gettext('Dynamic DNS %1$s (%2$s): _checkIP() starting.'), $this->_dnsService, $this->_FQDN));
        			}
        
        			if ($this->_useIPv6 == true) {
        				$ip_address = get_interface_ipv6($this->_if);
        				if (!is_ipaddrv6($ip_address)) {
        					return 0;
        				}
        			} else {
        				$ip_address = get_interface_ip($this->_if);
        				if (!is_ipaddr($ip_address)) {
        					return 0;
        				}
        			}
        			if ($this->_useIPv6 == false && is_private_Ip($ip_address)) {
        				$hosttocheck = "www.MYDOMAIN.com/remoteip/index.php"; 
        				$try = 0;
        				while ($try < 3) {
        					//$checkip = gethostbyname($hosttocheck);
                                                $checkip = file_get_contents('http://www.MYDOMAIN.com/remoteip/index.php');
                                                //print('checkip is:'.$checkip);
        					if (is_ipaddr($checkip)) {
        						break;
        					}
        					$try++;
        				}
        				if ($try >= 3) {
        					log_error(sprintf(gettext('Dynamic DNS %1$s debug information (%2$s): Could not resolve %3$s to IP using interface IP %4$s.'), $this->_dnsService, $this->_FQDN, $hosttocheck, $ip_address));
        					return 0;
        				}
        				$ip_address = $checkip;
        				if (is_ipaddr($ip_address)) {
        					if ($this->_dnsVerboseLog) {
        						log_error(sprintf(gettext('Dynamic DNS %1$s (%2$s): %3$s extracted from %4$s'), $this->_dnsService, $this->_FQDN, $ip_address, $hosttocheck));
        					}
        				} else {
        					log_error(sprintf(gettext('Dynamic DNS %1$s (%2$s): IP address could not be extracted from %3$s'), $this->_dnsService, $this->_FQDN, $hosttocheck));
        					return 0;
        				}
        			} else {
        				if ($this->_dnsVerboseLog) {
        					log_error(sprintf(gettext('Dynamic DNS %1$s (%2$s): %3$s extracted from local system.'), $this->_dnsService, $this->_FQDN, $ip_address));
        				}
        			}
        			$this->_dnsIP = $ip_address;
        
        			return $ip_address;
        		}
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.