Skip to main content

Configuring Audiocodes Behind NAT

About

About text.

Configuring Audiocodes Behind NAT

If there is a better way to accomplish this, please update this page!

The scenario is this:

FS with public IP <----- Internet -----> NAT <----- Audiocodes -----> PSTN

The audiocodes is a gateway to the PSTN but is behind a NAT and the public IP address of the NAT device is dynamic, which means it can change in any moment the ISP wants it. I cannot register the audiocodes in a <gateway> section AFAIK since I don't even have its IP address (dynamic DNS was not an option for me). The solution is register the audiocodes as a user. In this case, the user name of the audiocodes is gonna be "audiocodesgw", so you need to create a user section in directory/default/audiocodesgw.xml and the password is "secret".

<include> <user id="audiocodesgw"> <params> <param name="password" value="secret"/> </params> <variables> <variable name="user_context" value="default"/> </variables> </user> </include>

Now, depending on your audiocodes settings you may need to add the parameter "force-register-domain" to the SIP profile you are going to use. I used internal (sip_profiles/internal.xml), where I added:

<param name="force-register-domain" value="$${domain}"/>

This way, even if the audiocodes try to register with the IP address, the user will be found in the FS domain.

At this point you should be able to get your audiocodes to register with FS. Verify it by typing:

sofia status profile internal

That's assuming you also used the internal profile. The audiocodes registration should be shown there.

Registrations:

Call-ID 53438138331200085019@192.168.0.240 User audiocodesgw@63.80.191.86 Contact "user" <sip:audiocodesgw@189.140.92.153> Agent Audiocodes-Sip-Gateway-MP-118 FXS_FXO/v.5.20A.027.004 Status Registered(UDP)(unknown) EXP(2008-12-03 02:22:07)

At this point, the audiocodes is registered. However, since we need to send calls to route to the PSTN to the audiocodes we cannot just bridge with SOFIA/internal/audiocodesgw. We need something like SOFIA/internal/12345678@189.146.92.153 to send the number "12345678" to the audiocodes to route to the PSTN.We just used the audiocodes register as a trick to get the IP address of the NAT device of the audiocodes. Now we will use the sofia_contact function to send the call to the proper IP. In your dial plan you will need something like this:

    <extension name="audiocodes">
<condition field="${sofia_contact(audiocodesgw@$${local_ip_v4})}" expression="^sofia\/internal\/audiocodesgw\@(.*)$" break="never">
<action application="set" data="audiocodesip=$1"/>
</condition>
<condition field="destination_number" expression="^55(\d{8})$">
<action application="bridge" data="SOFIA/internal/$1@${audiocodesip}"/>
</condition>
</extension>

What this does is to define a condition that I know beforehand is gonna be true in order to get the IP address provided by the sofia_contact function and store it in the $audiocodes variable using the set application. After that, if the number starts with "55" (this is of course up to you) and followed by 8 digits it will call the bridge application sending the last 8 digits to the $audiocodes IP that was provided with the sofia_contact function.