Set up a SIP trunk

SIP trunk for Asterisk

 

Connecting your Asterisk server to a SIP trunk for incoming and outgoing calls can be done easily – and at a low cost.

In this article we will go through how you can connect a SIP-trunk to your Asterisk server in a matter of minutes.

 

Step-by-step setup of SIP-trunk

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

  1. Get a free Sonetel account
    You can sign up for a free account here.
  2. Get a phone number for testing
    On the phone numbers page you can select a free trial number, that allows you to test things a few days for free. 
  3. Redirect incoming calls to your SIP address
    Configure your free trial number to send incoming calls to the SIP address of your Asterisk.
  4. Send us your IPs for outbound calls
    Send the IP addresses of your SIP servers to support@sonetel.com so that we can whitelist them on our side for allowing your outbound calls.
  5. Whitelist our IPs in your Asterisk
    Whitelist all Sonetel IP’s on your Asterisk phone system.
  6. Set up your Asterisk
    Follow the steps in the next section to configure your Asterisk to receive and make calls via your new SIP trunk.

 

Your free test account comes with some free credit in your Sonetel 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.

 

Configure your Asterisk server to use the SIP trunk

Follow the steps below to configure your Asterisk server to use your new SIP trunk.

  1. pjsip.conf
    Add the following configuration to your pjsip.conf file (or copy it from this text file).

    [sip.sonetel.com]
    type=endpoint
    transport=transport-udp
    context=sonetel
    disallow=all
    allow=ulaw,alaw
    aors=sip.sonetel.com
    
    [sip.sonetel.com]
    type=aor
    qualify_frequency=60
    contact=sip:sip.sonetel.com:5060
    
    [sip.sonetel.com]
    type=identify
    endpoint=sip.sonetel.com
    match=sip.sonetel.com

    .

  2. Set up IP phones
    Setup your IP phones to make test calls via your Asterisk.

    [1001]                   ; replace with a name or digits of your choice
    type=friend
    host=dynamic
    secret=password          ;<password of your choice>
    allow=ulaw,alaw
    context=sonetel
    
    
  3. Update the dial plan
    Update the dial plan to instruct your Asterisk to send calls from your IP phones out via the new SIP-trunk. You can update the dial plan in extensions.conf.

    [sonetel]
    exten => _X.,1,NoOp(${EXTEN:1})
    exten => _X.,n,Set(CALLERID(num)=+NUMBER
    exten => _X.,n,Dial(SIP/${EXTEN}@sip.sonetel.com)

 

+NUMBER in step 3 above should be a phone number in your Sonetel account that can be used as caller ID in outgoing calls. If you wish to use numbers that you own outside Sonetel as your caller ID, please assign a static IP to your Asterisk server and contact support@sonetel.com.
The above configuration is verified on Asterisk version 16,18 and 19.

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.