Set up a SIP trunk

How to set up a SIP trunk in FreePBX

 

Learn how to connect a SIP trunk to FreePBX for incoming and outgoing calls with zero fixed cost.  FreePBX is an open source user interface (UI) for Asterisk, an open source telephony server.

In this article we will go through how you can set up a SIP-trunk in FreePBX in a matter of minutes.

Get the free SIP trunk

You can have your new SIP trunk up and running in a few minutes – at zero fixed cost – by following these steps:

  • Create a free account
    Sign up for a free account here.
  • Get a free phone number for testing
    On the phone numbers page you can select a free trial number. This allows you to test things a few days for free. If you also install a free Business Messenger at your website (for answering customer questions), you can have the phone number free forever.
  • Redirect incoming calls to your SIP address
    Configure your free trial number to send incoming calls to the SIP address of your server (see below).
  • Configure FreePBX
    Follow the steps in the next section to configure your FreePBX to receive and make calls via your new SIP trunk.

 

Your free test account comes with some free credit in your prepaid account for making some test calls. Calls are deducted at the call rates shown here. Please note that Premium gives you 40% discount on calls.

 

 

Whitelist your IPs for outgoing calls

To allow outbound calls, you need to get the Public IPs of your servers whitelisted.

  • Send your public IPs
    Send your server Public IP addresses to support@sonetel.com so that they can be whitelisted.
  • Whitelist IPs in your Firewall
    Whitelist Sonetel ‘s IP addresses in your FreePBX firewall and under pjsip trunk. 

 

Whitelist IPs in FreePBX for incoming calls

To allow incoming calls to reach your FreePBX you need to whitelist the IPs that the calls (and audio) will originate from.

See the below screenshots for reference.

 

 

 

 

Inbound call settings in FreePBX

Next, you need to configure the inbound call settings in your FreePBX to ensure that incoming calls across your SIP trunk can be answered.

  • Create an Inbound SIP Trunk and an Inbound route for receiving calls.
  • First Create a pjsip trunk for inbound calls using IP Based authentication. Go to Connectivity -> Trunks create a new trunk selecting “Add SIP (chan_pjsip) Trunk” type. Add below details in trunk configuration.
  • General Settings
    • Trunk Name: Any name (Sonetel Inbound)
    • Set outbound Caller ID: Sonetel Number
  • PJSIP-> General Settings
    • Authentication: None
    • Registration: None
  • Advanced settings
    • Match (Permit): Enter the IP addresses.
    • Outbound Proxy: sip:sip.sonetel.com
  • Submit
    After making the changes click on Submit and apply the configuration to save the settings.

See the below screenshots for reference.

 

 

 

 

 

 

 

Create an Inbound Route in FreePBX

Option 1: Do it per phone number

Create Inbound routes for your DIDs (phone numbers) to allow the FreePBX Server to receive incoming calls.

Follow the below steps for each DID.

  • Add incoming route
    Go to the Incoming Routes section, and then click Add Incoming Route.
  • Give it a name
    In the Description field, enter a description. Give the name for the inbound route.
  • Enter the number
    In the DID Number field, enter your DID number in this format “_.19172592253”
  • Leave Caller ID blank
    Leave the Caller ID Number field blank and make no other changes to the rest of the route.
  • Configure call destination
    Set the destination to where you would like the incoming calls to go to. For example, this might be a Ring Group, IVR, Extension, etc.
  • Submit
    Submit your changes, and then click Apply Configuration Changes at the top of the screen.

Repeat each step above for each phone number (DID) for which you want to create separate route.

 

 

Please note that the DID (phone number) should be in this format: “_.19172592253”

 

Option 2: Create an inbound route that works for all numbers

If you want to create a single inbound route for all phone numbers, simply leave the field DID number blank . This will mean that all incoming calls on all phone numbers will be handled by the inbound route.

 

 

 

 

Point the phone numbers to your FreePBX

The following settings need be made in your free Sonetel account for the DID (Phone number), to get inbound calls sent to your FreePBX.

Configure the DID to forward calls to the SIP address you want to forward the calls to (your FreePBX). In the above case, the call is forwarded to Ring Group (9999).

 

 

 

Enable outbound calls from your FreePBX

To be able to make calls from our FreePBX, via the SIP trunk, to any mobile or landline worldwide – follow these steps.

  • Create a chan_SIP
    First Create a chan_SIP for outbound calls using IP Based authentication.
  • Add trunk configuration
    Go to Connectivity -> Trunks” create a new trunk selecting “Add SIP (chan_sip) Trunk” type. Add these details in the trunk configuration.
  • Trunk Name
    Sonetel_outbound_trunk
  • Outbound CallerID
    Sonetel number

    • Under SIP Settings-> OutgoingUnder peers’ details: [sonetel]

      type=friend

      username= user_name

      fromdomain=domain.com

      host=sonetel.com

      outboundproxy=sip.sonetel.com

      disallow=all

      allow=ulaw,alaw

      qualify=yes

      dtmf=rfc2833

      nat=auto_force_rport

      canreinvite=no

      insecure=invite,port

      context=sonetel

      sendrpid=yes

 

 

 

Create an outbound Route

Create an outbound route on your FreePBX server to make calls via the new SIP Trunk and to set the right dial pattern.

  • Add outbound route
    Go to the Incoming Routes section, and then click Add outbound Route.
  • Give it a name
    Enter the name of the Route Name: Sonetel_Outbound_Route
  • Matched route
    Trunk Sequence for matched route: Sonetel_Outbound_Trunk
  • Dial pattern
    Dial pattern: enter ( .X )
  • Submit
    Submit the settings and apply the config.
  • Test
    Test calls to check if the calls are working via Sonetel trunk.

 

 

 

 

Things you can do next

If you are happy with your new SIP-trunk, you may consider taking additional steps.

  • Add some funds to your prepaid account
    Charges for calls are deducted from your Sonetel prepaid account which can be refilled with credit card, PayPal and more.
  • Add some more phone numbers
    You can get more phone numbers in your hometown or anywhere else worldwide, and connect them to your Asterisk via your SIP trunk. You can also port existing numbers to Sonetel.
  • Set up an Avalanche message
    Consider preparing a message using the Voice apps, that can be played to callers in case your Asterisk server becomes unavailable at any point in time.
  • Use the lower Intra-EU rates
    If you make calls to European countries, consider using the methods available for minimizing your cost for calls.