Configuring SIP Trunk with Freeswitch

Created by Daniel Kauffer, Modified on Mon, 24 Feb at 3:40 PM by Daniel Kauffer

Configuring Freeswitch for Megacall.


Key to the information which appears in the example:


  • 111111: Your SIP number from your personal account.
  • Password:  Your password of the SIP number from the section "SIP Connection" personal account.
  • 1000: Freeswitch extension number that connects to the softphone / ip-phone, to receive incoming calls and make outgoing calls.



1. Create a file /etc/freeswitch/sip_profiles/external/megacall.xml 


<include>
    <gateway name="zadarma">
        <param name="username" value="111111"/>
        <param name="password" value="Password"/>
        <param name="realm" value="sip.zadarma.com"/>
        <param name="from-user" value="111111"/>
        <param name="from-domain" value="sip.zadarma.com"/>
        <param name="proxy" value="sip.zadarma.com"/>
        <param name="expire-seconds" value="300"/>
        <param name="register" value="true"/>
        <param name="register-transport" value="udp"/>
        <param name="context" value="zadarma"/>
    </gateway>
</include>



2. Create a configuration file Dialplan /etc/freeswitch/dialplan/megacall.xml 


<?xml version="1.0" encoding="UTF-8"?>
<include>
    <context name="megacall">
        <extension name="unloop">
            <condition field="$${unroll_loops}" expression="^true$" />
            <condition field="${sip_looped_call}" expression="^true$">
                <action application="deflect" data="${destination_number}" />
            </condition>
        </extension>
        <extension name="in-megacall">
            <condition field="destination_number" expression="^(111111)$">
                <action application="bridge" data="user/1000@$${domain}"/>
                <action application="hangup"/>
            </condition>
        </extension>
        <extension name="out-megacall">
            <condition field="destination_number" expression="^(\d{10,15})$">
                <action application="bridge" data="sofia/gateway/megacall/$1"/>
                <action application="hangup"/>
            </condition>
        </extension>
        <extension name="local">
            <condition field="destination_number" expression="^\d{4}$">
                <action application="answer" />
                <action application="sleep" data="1000" />
                <action application="bridge" data="user/${destination_number}@$${domain}" />
                <action application="hangup" />
            </condition>
        </extension>
    </context>
</include>



3. Create a Freeswitch extension number that connects to the softphone / ip-phone to receive incoming calls and make outgoing calls. Edit the file /etc/freeswitch/directory/default/1000.xml 


<include>
    <user id="1000">
        <params>
            <param name="password" value="your_hard_pasword"/>
            <param name="vm-password" value="1000"/>
        </params>
        <variables>
            <variable name="toll_allow" value="domestic,international,local"/>
            <variable name="accountcode" value="1000"/>
            <variable name="user_context" value="megacall"/>
            <variable name="effective_caller_id_name" value="Extension 1000"/>
            <variable name="effective_caller_id_number" value="1000"/>
            <variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
            <variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
            <variable name="callgroup" value="techsupport"/>
        </variables>
    </user>
</include>



To reload XML execute the console command: fs_cli reloadxml

The configuration is complete.



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article