Connecting Asterisk to Hero

Registering using the SIP Protocol

Asterisk is a very popular open source PBX which will work well with our platforms. Other variants/forks of Asterisk include FreePBX, Trixbox and Callweaver. You can connect to our service using either the SIP or IAX2 protocol. The way you configure your Asterisk server is up to you, but the following provides a good template to start making calls through Hero.

Since examples are always the best way to illustrate configuration guides, here is an example configuration where obviously you should replace the 'yournumber' with your actual Hero number (e.g. 442034567890) and 'yourpassword' with your Hero password.

sip.conf

[general]

registerattempts=0
registertimeout=20

; Register line should be somewhere inside your general section

register => yournumber:yourpassword@phone.herotel.uk/yournumber

[Hero]

type=friend
username=yournumber
fromuser=yournumber
secret=yourpassword
host=phone.herotel.uk
context=default ; or your own selected context if desired
dtmfmode=rfc2833
disallow=all
allow=alaw
allow=ulaw
;allow=g729 ; only if you have licenses to use it
nat=yes
canreinvite=no
insecure=invite,port ; use very in older versions of Asterisk such as v1.4

extensions.conf

[default]

;receive incoming calls to a connected phone

exten => s,1,Dial(SIP/yournumber)

; outbound calls (outside of your own PBX)

exten => _X.*,1,Dial(SIP/${EXTEN}@Hero)


If you are still having problems connecting to our service then please log a support ticket at https://portal.herotel.uk/whups for assistance.

Registering using the IAX2 Protocol

Hero also support the IAX2 Protocol aimed at customers with an Asterisk based IP-PBX system including Asterisk, Trixbox, FreePBX, Callweaver and others.

If your IP-PBX, gateway or phone supports the IAX2 protocol then it should be compatible with our IAX2 service. IAX2 has a number of advantages over the SIP protocol including:
  • IAX2 trunking is more efficient with your Internet bandwidth when making multiple calls - often using less than half the bandwidth of the equivalent SIP calls using the same voice codec. For example eight G.729 calls using SIP will use around 250kbps with SIP but less than 100kbps using IAX2 trunking.
  • With IAX2 it is easier to connect to us when behind a router or firewall as a single port number is used for both signalling (call setup information) and media (voice traffic). This removes the complexity of traversing some problematic firewalls etc. and removes problems with no audio or one way audio etc.
  • DTMF traffic is always out of band removing any confusion about which DTMF method to use
For more benefits of IAX2 over SIP visit:
http://www.voip-info.org/wiki/view/IAX+versus+SIP

Below is a basic example configuration in the Asterisk 'iax.conf' file where the customer phone number is 442034567890 and password is 'yourpassword'. Obviously you replace these with your own phone number and password.

[general]

bandwidth=low
disallow=all
allow=gsm
allow=alaw
allow=ulaw
allow=ilbc
trunkfreq=20
trunktimestamps=yes
tos=ef

register => 442034567890:yourpassword@phone.herotel.uk

[442034567890]
type=friend
username=442034567890
trunk=yes
context=from-trunk (* See below note on context)
host=phone.herotel.uk
secret=yourpassword
auth=md5
disallow=all
allow=gsm
allow=alaw
allow=ulaw (specify your own codec preferences in the allow's here)

* If your context for incoming calls is not 'from-trunk' then you will need to login to the Hero Portal and change your 'IAX2 context' under the 'Preferences' area and then the 'Voice Quality & Networking' section. Here you can specify your own context string used for incoming IAX2 calls. By default Trixbox/FreePBX servers tend to use 'from-trunk' which is why we have made this the default context setting for IAX2 trunks.

NOTE: If you wish to have multiple numbers presented over IAX2 then you need to create a 'register' and 'peer' entry for each number in your IAX configuration file since each line on your account acts independantly.

Trixbox Settings

Trixbox configuration is done slightly differently than standard Asterisk configurations. Below is an example IAX2 configuration for Trixbox. Obviously you will need to change the phone number 442034567890 and password 'yourpassword' to be your own phone number and password. The example also assume g729 is used as the codec. If you do not have a license for this codec then substitute this for gsm, alaw or ulaw etc.:

[Peer Details]
username=442034567890
type=friend
secret=yourpassword
nat=route
insecure=port,invite ; or use very here for older versions of Asterisk
host=phone.herotel.uk
fromuser=442034567890
disallow=all
trunk=yes
context=from-trunk
canreinvite=no
bandwidth=low
allow=g729 ; Replace the codec with gsm or alaw if you do not have the g729 codec supported
requirecalltoken=no ; Required for Asterisk 1.6+ compatibility

[User Details]
username=442034567890
type=friend
secret=yourpassword
nat=route
insecure=port,invite ; or use very here for older versions of Asterisk
host=phone.herotel.uk
context=from-pstn

[Registration]
442034567890:yourpassword@phone.herotel.uk

Also a couple of other points to note:
  • If you have previously enabled 'SIP trunking/peering' on your account then you first need to disable this to use the IAX2 trunking service since SIP trunking takes precedence over the IAX2 routing.
  • You MUST name your IAX trunk the same as your username. So if your login name is 442034567890 then you should also name your trunk this as well. Using a separate name for your trunk/peer definition will cause problems with calls.
  • You should also put an explicit 'context=xxxx' line (where xxxx is your preferred context) in your peer definition. (NOTE: Also be aware that there seems to be a bug some freepbx versions whereby if you change ONLY the context line in your IAX trunk definition, it doesn't write the changes out to the iax_additional file and if your context doesn't match up with the Hero context, then calls will be rejected)

You then need to update your dial plan and replace the 'Dial' command(s) to use IAX2 instead of SIP. For example:

exten => _X.,1,Dial(IAX2/442034567890/${EXTEN})