FreeSwitch Configuration for OnSIP Trunking


Step 1: Gather information for the OnSIP Trunking User

You will need the following information from the OnSIP Trunking User in the Admin portal:

  • Username
  • Auth Username
  • SIP Password
  • Domain

You can find this information in the user detail pages under the Users tab in the Phone Configuration section.

Step 2: Create an OnSIP Trunking user profile with OnSIP Trunking details

In your $PREFIX/freeswitch/conf/sip_profiles/external/ directory create a file
such as "onsip-trunk.xml" and populate the following parameters with your OnSIP Trunking credentials, for example:

     <!--gateway name required, you will use this in the outbound dialplan -->
       <gateway name="">
         <!--/// set to onsip auth_username ///-->
         <param name="username" value="example_hiro"/>
         <!--/// set to onsip user_name ///-->
         <param name="from-user" value="hiro"/>
         <!--/// set to onsip domain ///-->
         <param name="from-domain" value=""/>
         <param name="realm" value=""/>
         <!--/// set to onsip password ///-->
         <param name="password" value="VPG3hockrifv"/>
         <!--/// *optional* set to your inbound extension ///-->
         <param name="extension" value="15135555555"/>
         <!--/// don't change these ///-->
         <param name="outbound-proxy" value=""/>
         <param name="expire-seconds" value="3600"/>
         <param name="caller-id-in-from" value="true"/>
         <!--/// if behind weird firewall, uncomment : ///-->
         <!--<param name="ping" value="25"/>-->

Save and exit your "onsip-trunk.xml" file.
Reload mod_sofia with the new OnSIP Trunk details using reload mod_sofia from the FreeSwitch cli.

Verify registration from the FreeSwitch cli by typing:
sofia status

Step 3: Edit your outbound dialplan in the $PREFIX/conf/dialplan/ directory with outbound dialing modifications.

In your outbound dialplan set the outbound CallerID name.

  • The outbound "From:" section of an outbound SIP Invite request should look like this:
    From: "15135555555" < >;tag=as04cfd8df

    Where 15135555555 is your inbound DID.

    This can generally be accomplished by a line such as:
    <action application="set" data="effective_caller_id_name=15135555555"/>

Where "" is a defined and registered external gateway.

Here is a sample configuration :

  <extension name="">
    <!-- The following line detects 11 digit outbound calls -->
    <condition field="destination_number" expression="^(\d{11})$">
      <!-- This sets the outbound Caller ID as "15135555555"-->
      <action application="set" data="effective_caller_id_name=15135555555"/>
      <!-- This sets the outbound gateway as "" , 
           which was defined in your OnSIP Trunking user profile  
           as the "gateway name" parameter.-->
      <action application="bridge" data="sofia/gateway/$1"/>

Save and exit your outbound dial plan configuration.

Reload the new dial plan by using reload mod_dialplan_xml from the FreeSwitch cli.

Step 4: Edit your inbound dial plan in $PREFIX/conf/dialplan/ directory to route inbound calls

Now that outbound calls work, you should make sure that your inbound dial plan appropriately routes incoming calls. This can generally be accomplished by a line such as:
<condition field="destination_number" expression="^(15135555555)$">

Which will match the telephone number in the inbound SIP invite.
Where “15135555555” is the number routed to your account.

Here is a sample configuration:

  <extension name="public_did">
    <!-- This identifies the incoming call destined for 15135555555 -->
    <condition field="destination_number" expression="^(15135555555)$">
      <action application="set" data="domain_name=$${domain}"/>
      <!-- This transfers the call to the "default" context 
           and passes along a data parameter of "1000". -->
      <action application="transfer" data="1000 XML default"/>

      <!-- Alternatively the following line will route the call
           directly to the internal extension "1000".
           The "%" is used to indicate that the end point is 
           registered locally. -->
      <action application="bridge" data="sofia/internal/1000%" />


Save and exit your inbound dial plan configuration.
Reload the new dial plan by using reload mod_dialplan_xml from the FreeSwitch cli.

Step 5: Make test calls

Verify connectivity and correct signaling by placing test calls against a land line or cell phone.
You may need to make minor adjustments to your dialplan depending on your individual configuration.


Was this article helpful?
0 out of 0 found this helpful