EndPoint Manager and NAT

We are going to have some phones (Cisco 7940s) on site and some phones that will not be at the same location as FreePBX. I have turned on NAT for the extensions that these phones will be using, however the file generated by the SIP$mac.cnf template does not contain the external IP address for the proxy1_address, or values for things like nat_enable, nat_address, etc…

We have the phones working just fine with manually created cnf files, but would rather use EndPoint Manager.

I’m using FreePBX 2.9.0.7 distro.

What am I doing wrong?

Is there a way to get the “External IP” from “Asterisk SIP Settings” and “nat” from “Extensions” values from within the EndPoint Manager templates?

I added print_r($this); to the replace_static_variables function in the base.php file to examine what is available in the EndPoint Manager, and saw no sign of the server’s external IP address or of the extension’s NAT flag. However, this data is needed in order for EndPoint Manager to support remote devices. Which, it seems to be would be a design consideration from the start. So, I would have to assume that I am missing something.

Any help would be greatly appreciated. Thank you.

It’s not included. Those variables from the Asterisk SIP Settings page aren’t included. I don’t think I’ll ever include those because:

A) Not everyone uses Asterisk SIP Settings
B) Some phones can be IAX, what do I do then
C) Not everyone assigns phones to the same PBX hosting the TFTPBoot files.

I implented a hack, that I thought might benefit others.

  1. I added an item to template_data.xml:
        <item>
            <!-- Image Name -->
            <variable>$external_ip</variable>
            <default_value></default_value>
            <description>External IP Address</description>
            <type>input</type>
        </item>
  1. I created two clones, one for local phones and one for remote phones. In the clone for the remote phone, I put the external IP address for the PBX, in the clone for the local phones, I left it blank.

  2. I created a function in base.php called “parse_if” (which is just a slightly modified variant of “parse_loops”):

    /**
     * Parse data between {if_*}{/if_*}
     * @param string $line_total Total Number of Lines on the specific Phone
     * @param string $file_contents Full Contents of the configuration file
     * @param boolean $keep_unknown Keep Unknown variables as {$variable} instead of erasing them (blanking the space), can be used to parse these variables later
     * @param integer $specific_line The specific line number to manipulate. If no line number set then assume All Lines
     * @return string Full Contents of the configuration file (After Parsing)
     * @example {if_external_ip}{/if_external_ip}
     * @author Andrew Nagy
     */
    function parse_if($line_total, $file_contents, $keep_unknown=FALSE, $specific_line='ALL') {
        //Find line looping data betwen {line_loop}{/line_loop}
        $pattern = "/{if_(.*?)}(.*?){\/if_(.*?)}/si";
        while (preg_match($pattern, $file_contents, $matches)) {
            if(isset($this->options[$matches[3]]) and $this->options[$matches[3]] != "") {
                $parsed = "";
                $parsed .= $this->parse_config_values($matches[2], FALSE, "GLOBAL");
                $file_contents = preg_replace($pattern, $parsed, $file_contents, 1);
            } else {
                $file_contents = preg_replace($pattern, "", $file_contents, 1);
            }
        }
        return($file_contents);
    }
  1. Added call to “parse_if” under the call for “parse_loops”:
$file_contents = $this->parse_if($line_total,$file_contents, $keep_unknown = FALSE, $specific_line);
  1. Now, in my template I can have logic like this:
{if_external_ip}
#
# NAT
#
nat_enable: "1"
nat_address: "{$external_ip}"
nat_received_processing: 1
proxy1_address: "{$external_ip}"
proxy2_address: "{$external_ip}"
{/if_external_ip}

Just dont ever click “check for updates”.

ever.

Sorry to hijack a thread, but this is as close as I have found to the subject matter. I am trying to set up a GXP2000 with extension pad, but the interface in EPM doesn’t have the capability to configure all of the extra buttons. Where are the cloned template files kept so that I can edit the clone rather than the master?