How to configure FreeSWITCH with iCall

This quick tutorial will talk you through installing FreeSWITCH, setting up iCall as a gateway, and configuring outbound and inbound services. For the purposes of this walk through, we'll assume that you're using a Linux-based system. For Windows, FreeBSD, or OSX - all instructions other than the basic installation process are identical.

Getting FreeSWITCH

To download and install FreeSWITCH, perform the following. Note that the uncompressed directory name will change depending on the build version.
# wget http://latest.freeswitch.org/freeswitch-1.0.5-latest.tar.gz # tar zxvf freeswitch-1.0.5-latest.tar.gz # cd freeswitch-1.0.5-XXXX # ./configure # make # make install
FreeSWITCH should now be installed in /usr/local/freeswitch.

Making some basic changes

By default, FreeSWITCH puts its "external" SIP profile on port 5080. While technically it will work fine, it's a bit confusing. At iCall, we default to 5060 but can handle any SIP port you'd like to use. Let's change some of the defaults to use port 5060 for the external profile. Open up /usr/local/freeswitch/conf/vars.xml. Change the following lines:
<X-PRE-PROCESS cmd="set" data="internal_sip_port=5060"/> <X-PRE-PROCESS cmd="set" data="internal_tls_port=5061"/> ... <X-PRE-PROCESS cmd="set" data="external_sip_port=5080"/> <X-PRE-PROCESS cmd="set" data="external_tls_port=5081"/>
To the following:
<X-PRE-PROCESS cmd="set" data="internal_sip_port=5080"/> <X-PRE-PROCESS cmd="set" data="internal_tls_port=5081"/> ... <X-PRE-PROCESS cmd="set" data="external_sip_port=5060"/> <X-PRE-PROCESS cmd="set" data="external_tls_port=5061"/>

Adding the iCall gateways

Now that we have the system installed, we need to setup the iCall gateways. To do this, create a file in/usr/local/freeswitch/conf/sip_profiles/external/ called icall.xml. Put the following in the file:
<include> <gateway name="icall"> <!-- Replace these value with your iCall Carrier Services username and password. --> <!-- Even if you use an IP-based sub-account, FreeSWITCH needs these values --> <param name="username" value="cust_USERNAME" /> <param name="password" value="PASSWORD" /> <param name="from-user" value="cust_USERNAME" /> <param name="proxy" value="sbc01-car.dal.us.icall.net" /> <param name="realm" value="sbc01-car.dal.us.icall.net" /> <!-- Set to "false" for IP-based accounts, or "true" for registration based --> <param name="register" value="false" /> </gateway> <gateway name="icall_international"> <!-- Replace these value with your iCall Carrier Services username and password. --> <!-- Even if you use an IP-based sub-account, FreeSWITCH needs these values --> <param name="username" value="cust_USERNAME" /> <param name="password" value="PASSWORD" /> <param name="from-user" value="cust_USERNAME" /> <param name="proxy" value="gw01-car.dal.us.icall.net" /> <param name="realm" value="gw01-car.dal.us.icall.net" /> <!-- Set to "false" for IP-based accounts, or "true" for registration based --> <param name="register" value="false" /> </gateway> </include>

Setting up an inbound number

There are a number of ways to configure inbound DIDs, but the easiest is to put the number handling in icall.xml in the/usr/local/freeswitch/conf/public/ directory. Once you create this file, FreeSWITCH will automatically include it in the global configuration. Below is a sample of handling an inbound call to 2125551212 and echoing back all audio. Note: Since we're using the "public" context, anyone call call these numbers - not just iCall or your other SIP provider.
<include> <extension name="icall_inbound"> <condition field="destination_number" expression="^2125551212$"> <action application="answer"/> <action application="echo" /> </condition> </extension> </include>

Outbound dialing

The outbound dialplan syntax is identical to the inbound. One important thing is to make sure that you put your outbound dialing in a context that only your registered phones, customer, or other SIP devices have access to. Setting a "user_context" variable on each directory user will limit them to the specified context. For this example, we will assume that you've set the context on those users to "outbound". Place the following in /usr/local/freeswitch/conf/dialplan/outbound.xml.
<include> <context name="outbound"> <extension name="outbound_international"> <condition field="destination_number" expression="^011?(\d+)$"> <action application="bridge" data="sofia/gateway/icall_international/011$1"/> </condition> </extension> <extension name="outbound_domestic"> <condition field="destination_number" expression="^1?(\d{10})$"> <action application="bridge" data="sofia/gateway/icall/1$1"/> </condition> </extension> </context> </include>
The dialplan above tells FreeSWITCH to bridge any calls starting with "011" to iCall's international call gateway. Any calls that are 10-digit numbers, with or without a beginning "1", will be sent to the domestic gateway. Note that there are some 10-digit international destinations, so it's up to you to filter those out separately as needed.

Running FreeSWITCH

To run FreeSWITCH, simply type:
# /usr/local/freeswitch/bin/freeswitch
To exit, simply type "...". To run FreeSWITCH in the background then connect to the console, run:
# /usr/local/freeswitch/bin/freeswitch # /usr/local/freeswitch/bin/fs_cli

Comments

Popular posts from this blog

PHPMixBill V5 mikrotik Billing Solutions

How to install Asterisk and A2billing on Ubuntu Server 12.04LTS

odbcinst: SQLGetPrivateProfileString failed with