Asterisk PBX SIP Trunk Configuration

How to configure SIP Trunking for Asterisk IP PBX based systems


Our service is 100% compatible with Asterisk using either standard SIP registration or IP authentication where SIP trunks are configured as such. Asterisk is the base software behind many open-source PBX distributions, including FreePBX, Trixbox and Elastix, and is also the enabler behind many other ITSPs and commercial PABX manufacturers.

This guide is aimed at Asterisk's SIP stack via the sip.conf file, it does not deal with real-time configuration via a back-end database, however, the principles are the same and the appropriate options should be transposed as such. The configuration of SIP trunks for the PJSIP stack within Asterisk versions 12, 13 and greater is forthcoming and will be posted in a separate FAQ entry.

Once you have set up and configured Asterisk, you can use the following details to start making calls.

These details are visible on your customer control panel if you have been allocated a SIP trunk.

Asterisk sip.conf SIP configuration using SIP registration

You should have the following in your sip.conf file:

[general]
register => username:password@<INSERT VOICEHOST FQDN HERE>

[voicehost]
host=<INSERT VOICEHOST FQDN HERE>
defaultuser=[sip-trunk-username]
secret=[sip-trunk-password]
type=peer
disallow=all
allow=alaw
allow=ulaw
allow=g722
allow=gsm
context=inbound
insecure=port,invite
qualify=no 

These options are explained as follows:

  • register => <sip-trunk-username>:<sip-trunk-password>@<domain> ; Specifies Asterisk registers with given username, password and domain hostname or IP address, note this is not needed for SIP trunks configured for IP authentication
  • host=<domain> ; VoiceHost domain hostname
  • defaultuser=<REPLACEME>; Username of the VoiceHost SIP trunk is entered here (less the <> characters), note this is not needed for SIP trunks configured for IP authentication
  • secret=<REPLACEME>; Password of the VoiceHost SIP trunk is entered here (less the <> characters), note this is not needed for SIP trunks configured for IP authentication
  • type=peer ; This specifies the SIP endpoint to be contacted for call handling, type=peer is usually used for SIP trunk connectivity, type=friend for IP phones authenticating per call to Asterisk
  • disallow=all ; Codec settings specifying no codecs, usually this is first in the list with allow= fields below it which then specify codecs permitted
  • allow=alaw ; Specify G.711a on INVITE and responses for calls
  • allow=ulaw ; Specify G.711u on INVITE and responses for calls
  • allow=g722 ; Specify G.722 on INVITE and responses fourth in the priority list
  • allow=gsm ; Specify GSM 6.10 Full Rate on INVITE and responses for calls
  • context=inbound ; Context within the dialplan to which calls into this trunk will be matched
  • insecure=port,invite ; Specifies Asterisk to accept the call without requesting authorisation
  • qualify=<integer> ; Sends OPTIONS SIP request to the host value every 15 seconds (value is in milliseconds, e.g. 15000 is 15 seconds)

For Asterisk major versions 1.6 and older, replace the "defaultuser=" option with "username=", otherwise authentication on outbound calls will fail.

You should have something similar to the following in your extensions.conf file to receive inbound calls:

exten => _X.,1,Dial(SIP/100) ; Directs incoming calls via SIP to extension 100 within the dialplan

Please note: Incorrectly setting the 'context' can lead to vulnerabilities open to attack from hackers. Please check your configuration thoroughly as VoiceHost does not accept any liability for fraudulent use of your Asterisk system.

Inbound telephone numbers need to be mapped in the Asterisk system in E.164 format to receive calls correctly, e.g. +441603904090

If you require any further assistance, please feel free to contact VoiceHost Support who will be happy to answer any questions you may have.

 


Troubleshooting Asterisk configurations

Calls to VoiceHost error with "all circuits busy" or "congestion" - this is the default configuration of Asterisk regardless of the actual error generated unless Asterisk is updated to send back the real error rather than the changed error. This error most commonly occurs when the call is not authenticating properly, at which point check the above in the SIP trunk configuration within Asterisk, and swap username= for defaultuser= to see if this solves the issue. Just because a trunk is showing as registered does not mean it will authenticate correctly. For inbound calls, ensure the mapping is correct and a viable destination set in the PBX, e.g. voicemail or auto-attendant.

Outbound calls to VoiceHost fail with SIP error 488 (Not Accepted Here) or I-SUP errors 58 (bearer capability not available) or 88 (incompatible destination) - check the codecs allowed in the SIP trunk configuration above, VoiceHost only supports:

  • alaw (G.711 alaw)
  • ulaw (G.711 ulaw)
  • g722 (G.722 wideband codec)
  • gsm (GSM 6.10 Full Rate)

If a codec is defined in Asterisk that is not one of the above, or is offering a differing sample rate or interval rate (e.g. 8000/20i - 8000Hz at 20ms cannot interwork with 16000/30i - 16000Hz at 30ms) and the call attempted the call will fail. The codecs in the SIP trunk configuration within Asterisk need to be aligned to use one of the above codecs. As a minimum, offer both alaw and ulaw codecs when sending and receiving calls for widest compatibility with fixed line and mobile operators. alaw should be first on the list for calls to and from the UK PSTN.

Inbound calls to Asterisk fail with SIP error 408 (Request Timeout) - check the inbound number is mapped in the system correctly, if necessary the SIP trunk on the portal can be configured to strip the plus when sending calls to Asterisk, e.g. if Asterisk is configured to use plus logic somewhere else. Check the trunk is registered. Ascertain how long the 408 error took to come back, if it was immediate the trunk is usually unregistered, if it took a few seconds the number is usually not mapped correctly.

Calls fail to VoiceHost with SIP error 503 (Service unavailable), I-SUP errors 34 (No circuit available) or 38 (Network out of order) - If the VoiceHost platform replies back with SIP error 503 it usually means one of two things: the SIP trunk has exceeded the Calls-Per-Second (CPS) limit, or the gateway has rejected the call for some other reason.

Calls fail into Asterisk with SIP error 403 Forbidden (Bad Auth) - authentication is being requested from a VoiceHost gateway that is not recognised or not authorised in the SIP configuration, this usually happens if the SIP trunk configuration is set with insecure=very and host=st.sipconvergence.co.uk or st.voicehost.co.uk. Change type=peer, insecure=port,invite within the SIP configuration, and re-test inbound calls upon successfully re-registering. If calls continue to fail to change the host= value from the domain to a public IP address under the domain

Help Tags: 

Videos

Call Encryption - TLS/SRTP walkthrough
Embedded thumbnail for Call Encryption - TLS/SRTP walkthrough
Hosted Directory LDAP - Lightweight Directory Access Protocol
Embedded thumbnail for Hosted Directory LDAP - Lightweight Directory Access Protocol
Cloud PBX Explainer
Embedded thumbnail for Cloud PBX Explainer
Zoiper Softphone Configuration
Embedded thumbnail for Zoiper Softphone Configuration
Call Conferencing
Embedded thumbnail for Call Conferencing
Receptionist Console
Embedded thumbnail for Receptionist Console

Search Help Portal

Get in touch

VoiceHost Limited
Norfolk Tower
Surrey Street
Norwich
NR1 3PA

UK Freephone 0800 2 545454

International +44 1603904090

support [at] voicehost.co.uk

Connect With Us

Download the iOS App from the Apple App Store

Get the Android app from the Google Play store