Skip to main content



Configuration instructions for exchanging calls between FreeSWITCH™ and Asterisk using SIP.

Click to expand Table of Contents

Connecting FreeSWITCH and Asterisk Using SIP

With ACLs

These are the steps and how I did to connect FreeSWITCH 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 do it using ACLs in both ways.

Lets assume you have asterisk box using IP and FS using IP

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=""/>

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@"/>
<action application="hangup"/>

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




; if using elastix you need the following or all phones will ring when a sip call comes in

In /etc/asterisk/extensions.conf

exten => _1XXX,1,Dial(SIP/freeswitch_1/${EXTEN})
exten => _1XXX,n,Hangup

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

Using Authentication

This howto is based on FreeSWITCH Version 1.0.trunk (10906) with default configuration. We assume that booth servers have static IPs and don't need to register. To set up the trunk we are going to utilize the use case predefined in default configuration for default gateway.


In vars.xml you will find 6 variables which define your default gateway:

  <X-PRE-PROCESS cmd="set" data="default_provider=HOSTNAME.DOMAIN.COM"/>
<X-PRE-PROCESS cmd="set" data="default_provider_username=USER_NAME"/>
<X-PRE-PROCESS cmd="set" data="default_provider_password=BOOTH_WAY_PASSWORD"/>
<X-PRE-PROCESS cmd="set" data="default_provider_from_domain=HOSTNAME.DOMAIN.COM"/>
<X-PRE-PROCESS cmd="set" data="default_provider_register=false"/>
<X-PRE-PROCESS cmd="set" data="default_provider_contact=5000"/>

Note: default_provider_password is used to authenticate calls from and to Asterisk and HOSTNAME.DOMAIN.COM is the DNS name of Asterisk server.

Those variables are used in two configuration files:

  1. directory/default/ which describes:
    • the user for authentication of calls coming from Asterisk to FreeSWITCH. The ID on this user will be the same as value of variable default_provider.
    • the gateway for authentication of calls outgoing from FreeSWITCH to Asterisk. The ID of this gateway will be the same as ID of the user.
  2. dialplan/default// which contains routes utilizing the gateway. Probably you should customize expression parameter of <condition field="destination_number" ... > to your needs. Only calls to destination number matching expression will go through the gateway.

Before going further, you should look into dialplan/public.xml, this is the file where you'll need to create a rule to route incoming calls in public to default. If the call reach FS console but it doesn't go further, look again at this file, you might have an error. I've include an example to route incoming calls to extension 6969 to default dialplan!

    <extension name="public_extensions">
<condition field="destination_number" expression="^(6969)$">
<action application="transfer" data="$1 XML default"/>

After setting variables and tuning routes(see above) type on FS console sofia profile restart all reloadxml to activate changes.

Asterisk Side

You have to define sip peer and dialplan extension.

In sip.conf add:


In extensions.conf, probably in your internal context, add:

exten => _1XXX,1,Dial(SIP/${EXTEN}@freeswitch)

So you will be able to call to default phones (1000-1019) configured on FS.

One Asterisk console type: sip reload and extensions reload to activate changes.

The Easy Way

Assume is FreeSWITCH with extensions of 1000-1019 and is Asterisk with extensions in the range 2000-2019.


We need to route calls made on freeswitch to the 2000-2019 extensions to the asterisk box, we'll use our external sip profile for this but internal should work, as well.

Create $FREESWITCH_HOME/conf/dialplan/default/00_asterisk_extensions.xml:

<extension name="to_asterisk">
<condition field="destination_number" expression="^(20[01]\d)$">
<action application="set" data="hangup_after_bridge=true"/>
<action application="bridge" data="sofia/external/$1@"/>

Now we have to handle calls coming from asterisk, which by default hit the 'public' dialplan.

Create $FREESWITCH_HOME/conf/dialplan/public/00_from_asterisk.xml:

<extension name="from_asterisk">
<condition field="network_addr" expression="" />
<condition field="destination_number" expression="^(10[01]\d)$">
<action application="transfer" data="$1 XML default" />

Asterisk Side

We'll make freeswitch a peer in asterisk Add an entry in /etc/asterisk/sip.conf:

; if using elastix you need the following or all phones will ring when a sip call comes in, in general set this a context where your internal extensions are included

And route calls to the appropriate place based on the extension In /etc/asterisk/extensions.conf:

exten => _10XX,1,Dial(SIP/freeswitch_1/${EXTEN})
exten => _10XX,n,Hangup

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

You should now be able to make calls from the 1000s on FreeSWITCH to the 2000s on asterisk, and vice-versa. If that's all you wanted/needed to do between them, you're Done!

A little more advanced

Instead of routing the calls to freeswitch's public dialplan from asterisk and having to create an appropriate transfer to the default XML dialplan, you could instead allow asterisk calls to directly hit the default XML dialplan on freeswitch. There are a few ways to do this, in this case we're just going to make the internal sip profile on freeswitch use the default context instead of the public context, then set an acl to allow asterisk to use that internal sip profile without authenticating.

First the ACL,

Edit $FREESWITCH_HOME/conf/autoload_configs/acl.conf.xml, adding:

<list name="asterisks" default="deny">
<node type="allow" cidr=""/>

Now, to apply it, In the [settings] section of $FREESWITCH_HOME/conf/sip_profiles/internal.xml, add:

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

Also in $FREESWITCH_HOME/conf/sip_profiles/internal.xml, edit the context to make it default:

<param name="context" value="default"/>

Now you can remove the public/00_from_asterisk.xml file and change the port from 5080 to 5060 in asterisk's sip.conf and you should be able to call any freeswitch extension that you set a route for in asterisk.

Rosetta Stone

See Also: Rosetta Stone