Nat – asterisk/freeswitch in nat/no-nat setup

asteriskfreeswitchnat;sipvoip

my current setup – i use bunch of sip hard-phones around few offices. all devices have two sip accounts configured – one on internal sip proxy [for calls between the branches], another – at 3rd party voip providers [ since it's in different countries – those are different providers, but that's irrelevant ].

i was thinking about terminating sip calls on something like asterisk/freeswitch server and having all sip-devices log on just once to such server[s] – mostly to provide things like voicemail, groupcalls, redirections etc. it seems perfectly doable but there is one problem – i cannot find examples how to prepare for nat/no nat. for calls routed to from/to 3rd party voip operator – i'll need handling for nat/stun etc, but for handling of internal calls – i do not want any nat, all traffic should go via vpns to different branches.

can you provide me some hints how to configure it? any tutorials?

thanks!

Best Answer

For FreeSWITCH, I believe this functionality can be handled by the internal/external sip profiles. You can find more info on wiki.freeswitch.org

The NAT configuration to your external VoIP provider(s) can be setup in the external profile (example /usr/local/freeswitch/conf/sip_profiles/external/voipprovider.xml). You can set these two parameters to match your public ip address:

<include>
        <gateway name="voipprovider">
        <param name="ext-rtp-ip" value="x.x.x.x"/>
        <param name="ext-sip-ip" value="x.x.x.x"/>
        <param name="username" value="user"/>
        <param name="password" value="password"/>
        <param name="realm" value="sip.voipprovider.com"/>
        </gateway>
</include>

To use your external voip providers, you would setup your dialplan (/usr/local/freeswitch/conf/dialplan/default.xml) something like this. To use different voip providers depending on destination, you can adjust the regex:

<include>
 <extension name="Dial Out VoIP Provider">
   <condition field="destination_number" expression="^9(1\d{10})$">
     <action application="bridge" data="sofia/gateway/voipprovider/$1"/>
   </condition>
 </extension>
</include>

I hope this helps. I don't have any experience w/ Asterisk, so I am not sure how you would set it up with that switch.