Connecting Freeswitch And Asterisk

From FreeSWITCH Wiki

Jump to: navigation, search

Connecting Freeswitch and Asterisk

These are the steps and how i did to connect FS and Asterisk.

I first tried to use auth gateways to do the job, but was VERY tedious to resolve some issues, so i decided to doit using ACLs in both ways.

Lets assume you have asterisk box using IP 2.2.2.2 and FS using IP 1.1.1.1.

You need to add a acl list to ${FREESWITCH_HOME}/conf/autoload_configs/acl.conf.xml

<list name="asterisk_box" default="deny">
  <node type="allow" cidr="2.2.2.2/32"/>
</list>

In the [settings] section of ${FREESWITCH_HOME}/conf/sip_profiles/external.xml

<param name="apply-inbound-acl" value="asterisk_box"/>

Create the exten in ${FREESWITCH_HOME}/conf/dialplan/default.xml with the pattern to call asterisk extensions

<extension name="ast_extens">
  <condition field="destination_number" expression="^(2\d{3})$">
    <action application="set" data="hangup_after_bridge=true"/>
    <action application="bridge" data="sofia/external/$1@2.2.2.2"/>
    <action application="hangup"/>
  </condition>
</extension>

In the Asterisk box on /etc/asterisk/sip.conf

[general]

...

allowguest=no

[1.1.1.1]
type=peer
host=1.1.1.1
port=5080
disallow=all
allow=ulaw
trustrpid=yes
sendrpid=yes
; if using elastix you need the following or all phones will ring when a sip call comes in
context=from-internal

In /etc/asterisk/extensions.conf

exten => _1XXX,1,Dial(SIP/${EXTEN}@1.1.1.1:5080)
exten => _1XXX,n,Hangup

exten => _2XXX,1,Dial(SIP/${EXTEN})
exten => _2XXX,n,Hangup
Personal tools