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

    Ddns check ip change for different server output?

    Scheduled Pinned Locked Moved DHCP and DNS
    4 Posts 2 Posters 826 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.
    • T
      tyn
      last edited by

      Hi,
      I'm trying to use an alternate check IP service that my ISP provides but its output is simply my IP address; not the required "Current IP Address: x.x.x.x" format.  I'm not familiar with the PfSense code but I do have some experience with programming.  I'm running 2.3.3 p1.

      If someone could point me toward the script/s that interpret the server response then I can try to do an edit to support either "Current IP Address: x.x.x.x" or "x.x.x.x" server output.

      Thanks.

      1 Reply Last reply Reply Quote 0
      • N
        NOYB
        last edited by

        cd /etc
        grep -RIi "Current IP Address:" *

        You should also read this thread before making modifications to checkip.
        https://forum.pfsense.org/index.php?topic=127148.msg702341#msg702341

        1 Reply Last reply Reply Quote 0
        • T
          tyn
          last edited by

          Thanks
          The regular expression in services.inc (function dyndnsCheckIP, line 2047) is pretty easy to update so it can support an IPv4 address that is the last text in the body of a check IP service.  I'm not exactly sure what to do about IPv6 addresses yet.

          replace this:

          preg_match('=Current IP Address: (.*)=siU', $ip_result_decoded, $matches);
          $ip_address = trim($matches[1]);
          

          with this:

          preg_match('=\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b=', $ip_result_decoded, $matches);
          $ip_address = trim($matches[0]);
          

          The thread you referred me to makes this a little more complicated than I hoped so I'll have to do some more research into getting it to work under all circumstances.

          1 Reply Last reply Reply Quote 0
          • N
            NOYB
            last edited by

            Doesn't seem like it should be too difficult to update the dyndns.class _checkip() function to utilize the services.inc dyndnsCheckIP($int) function.

            At first glance maybe something like replacing this.

            
            				$ip_ch = curl_init("http://{$checkip}");
            				curl_setopt($ip_ch, CURLOPT_RETURNTRANSFER, 1);
            				curl_setopt($ip_ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            				curl_setopt($ip_ch, CURLOPT_INTERFACE, 'host!' . $ip_address);
            				curl_setopt($ip_ch, CURLOPT_CONNECTTIMEOUT, '30');
            				curl_setopt($ip_ch, CURLOPT_TIMEOUT, 120);
            				if ($this->_useIPv6 == false) {
            					curl_setopt($ip_ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
            				}
            				$ip_result_page = curl_exec($ip_ch);
            				curl_close($ip_ch);
            				$ip_result_decoded = urldecode($ip_result_page);
            				preg_match('/Current IP Address: (.*)<\/body>/', $ip_result_decoded, $matches);
            				$ip_address = trim($matches[1]);
            
            

            With this.

            
            				$ip_address = dyndnsCheckIP($this->_if);
            
            

            And don't let that _useIPv6 test confuse you.

            
            				if ($this->_useIPv6 == false) {
            					curl_setopt($ip_ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
            				}
            
            

            That test is redundant and should be removed anyway.  It is already included by the parent if test at line 1726.

            
            			if ($this->_useIPv6 == false && is_private_ip($ip_address)) {
            
            

            So if _useIPv6 is not false none of that code is executed anyway.

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