Skip to main content
Asterisk PBX SIP Trunk Configuration

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:

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

qualify=see below

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
  • 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)

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 or 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