4  Trunks to the outside world

Making and receiving calls between internal extensions is one thing, but a telephony installation isn’t really and installation if you cant receive make make calls to the outside worlds.

To be able to do these, you will need at least one trunk to the outside world.

This is a simplified guide to give the budding TRIXBOX users some understanding in setting up Trunks.

Points to keep in mind.

Beware!!!   If you are using an ATA, please allow for what the ATA will be sending to asterisk when you are preparing you rules and patterns.  If you want asterisk to take care of all the rules, it is best to ensure that your ATA is sending exactly what you dialed to Asterisk – just delete your dialling rule from your ATA and replace it with (*x.|xx.)

 

4.1  What is a Dial Pattern?

Dial patterns are part of Outbound Routing. They act like a filter for matching numbers dialed with trunks.  A further explanation can be found under Notes.

 The various patterns you can enter are similar to Asterisk's definition of them:

4.2  What is a Trunk?

A trunk is the telephony service line that you will be using to make an external call on, e.g. the Telstra telephone line that you have at home is a trunk (or it can be used as a trunk if you wish but not necessarily so). A VOIP service provider (VSP) that you have signed up with is also a trunk.

If you have paid for VOIP service to enabled you to make calls out through PSTN, you can use this as a trunk for that purpose otherwise, you can only use it for making calls using VOIP between subscribers of the VSP only (unless there are peering arrangements with other VSPs).

You can have several trunks if you want to.  You can have Telstra and/or Optus telephone lines and use them as trunks, and you can also have a few VSPs that you subscribed to as additional trunks. 

To make external, PSTN or VOIP calls; you must have at least one trunk. 

The reason why asterisk users have several trunks can be explained as follows:

A properly planned route will direct the phone calls you make to the appropriate trunk that will provide you with maximum effectiveness and savings.

E.g. When you make a call to a Mobile phone, asterisk will route your call via trunk (c) while it will route your call to trunk (a) if you make a local call.  Similarly, when you make an international call, asterisk will route your call via trunk (b).

To create a new trunk using freePBX, select Setup tab and then select the Trunks option from the vertical menu on the left.

 

4.3  Let’s Create Some Trunks

For this example, let’s create 3 SIP trunks; Pennytel, Oztell and Astratel

  1. Pennytel will be used for all International and mobile calls

  2. Oztell will be used for all local and mobile calls

  3. Astratel will be used for international calls

To create a new Trunk, click on the Add Trunk option (first option on the right of the screen).

General Setting (This applies to all the trunks):

Outbound Caller ID: Insert Your Name” <Your Number>  (Must include the “ “ and <>)

Maximum channels: Leave blank for maximum.

In this example we will create a Pennytel, Oztell and Astratel SIP Trunks, which we will call pennysip, oztellsip and astrasip respectively.  We will also define their dialling patterns.

 

4.3.1  Pennytel

In this example, we will use Pennytel for all international and mobile calls only.

Pennytel requires numbers dialed to follow the international format Country code + area code + phone number.  To call an overseas destination you would normally dial 0011+country code + phone number.  E.g. to call New Zealand is 0011 64 <phone number>, and to dial France is 0011 33 <phone number>.  Since Pennytel only requires the country code and the phone number but does not require the 0011, the route (that we will create later) will not pass the 0011 to the trunk.

We will require the following Outgoing Dialing Rules for this trunk, which instruct the trunk to dial whatever is sent by the appropriate route. This example is for dialing Malaysia with a country code of 60, and Australian Mobile phones.

Pattern

Explanation

601XXXXXXXX

This pattern tells Pennytel to dial all Malaysian Mobile numbers starts with 601 followed by 8 more digits.

60NXXXXXXX

This pattern dials numbers start with 60 followed by a one-digit number in the range of 2-9 followed by 7 more digits.

61+4XXXXXXXX

For dialing Australian Mobile phone.  The 61 is the Australian Country code that will be added to the mobile phone number.

 

In your Outgoing Dial Rules box, we will enter the following;

601XXXXXXXX
60NXXXXXXX
61+4XXXXXXXX

Next we need to create the Outgoing Setting, Incoming Settings and Registration for Pennytel. 

Outgoing Settings

In the Trunk Name field we will enter the name of this trunk: pennytelsip  

In the Peer Details enter the following;

Pennytel preferred codecs are: g729, gsm and g723 but g729 and g723 are not installed as default in TRIXBOX

 

allow=alaw&ulaw&gsm
canredirect=no
canreinvite=no
disallow=all
host=sip.pennytel.com
insecure=very
secret= Password
type=peer
username=8880XXXX

Incoming Settings 

In the User Context, enter the Pennytel User ID: 888XXXXX 

 

In the User Details we will have the following:

canreinvite=no
context=from-trunk
fromuser=888XXXXX
qualify=no
secret= Password
type=user
username=888XXXXX

 Registration

 In the registration field, enter the following: 

888XXXXX:Password@sip.pennytel.com/888XXXXX

 After all these have been done, click on the Submit Changes button and click on the red bar across the top of the screen.

 ** Note: It seems that Pennytel is rejecting Asterisk.  To overcome this problem, it is necessary to add the following in the general section of your sip.conf.

useragent = MyPABX 

*Note: The useragent can be any name, as long as it is NOT Asterisk. 

My sip.conf looks like this; 

; Note: If your SIP devices are behind a NAT and your Asterisk
;  server isn't, try adding "nat=1" to each peer definition to
;  solve translation problems.

[general

port = 5060           ; Port to bind to (SIP is 5060)
bindaddr = 0.0.0.0    ;
Address to bind to (all addresses on machine)
disallow=all
allow=ulaw
allow=alaw
;
; If you need to answer unauthenticated calls, you should change this
; next line to 'from-trunk', rather than 'from-sip-external'.
; You'll know this is happening if when you call in you get a message
; saying "The number you have dialed is not in service. Please check the
; number and try again."
;

context = from-sip-external ;
Send unknown SIP callers to this context
callerid = Unknown
tos=0x68

useragent = MyPABX

; #, in this configuration file, is NOT A COMMENT. This is exactly
; how it should be.

#include sip_nat.conf
#include sip_custom.conf
#include sip_additional.conf

 

4.3.2  Oztell (SIP)

Oztell requires the numbers dialled to follow international format Country code + area code + phone number.  To call Sydney 67541234, Oztell requires it in the following format 61 267541234. To use Oztell family cheap rate you can also prefix it with 09. Therefore the dialling rule will be in this form:

We need various patterns here:

Pattern

Explanation

899060X.

This pattern tells Oztell to dial the inter Oztell’s numbers

60ZXX.

This pattern dials numbers start with 60 followed by a one digit number 1-9 followed by other numbers minimum of 2 digits from 0 -9.  This can be an international number with a Country code of 60 followed by a number between 1 and 9 inclusive.

06612+NXXXXXXX

Using the Oztell 06 rate to dial any NSW number.

0661+NXXXXXXXX

Using Oztell 06 rate to dial any Australian number.

61+1300XXXXXX

Dials 1300 numbers

61+13ZXXX

Dials 13 numbers

61+1800XXXXXX

Dials 1800 numbers

 

In your Outgoing Dial Rules box, it will look like this: – this is simply an example based on my setting, yours will no doubt be different.

899060X.
60ZXX.
06612+NXXXXXXX
0661+NXXXXXXXX
61+1300XXXXXX
61+13ZXXX
61+1800XXXXXX

Next we need to create the Outgoing Setting, Incoming Settings and Registration for Oztell.

Outgoing Settings

In the Trunk Name, enter the name of this trunk: oztellsip (as an example) 

 

In the Peer Details we will need the following;

You must enable all the codecs that you want to use through Oztell’s web page.

allow=ulaw&alaw
canredirect=no
disallow=all
fromuser=899060xxxxx
dtmfmode=rfc2833
host=sip2.syd.net2max.com
insecure=very
secret=Password
type=peer
username=899060XXXXX

Incoming Settings 

In the User Context, enter the Oztell User ID:  899060XXXXX 

 

In the User Details enter the following:

canreinvite=no
context=from-trunk
fromuser=899060XXXXX
insecure=very
qualify=no
secret=Password
type=user
username=899060XXXXX

Registration 

In the registration field, enter the following:

899060XXXXX:Password@sip2.syd.net2max.com/899060XXXXX

 After all have been done, click on the Submit Changes button and click on the red bar across the top of the screen.

 

4.3.3  Oztell (IAX)

 Since I only have IAX trunk with Oztell, I might as well include my Oztell IAX trunk setting here for general information.

 Note*  Don’t forget to Forward UDP Port 4569 to your Asterisk IP address and edit your iax.conf file.

Outgoing Settings

In the Trunk Name, enter the name of this trunk: oztelliax (as an example) 

   
In the Peer Details we will need the following;

Note: You must enable all the codecs that you want to use through Oztell’s web page.

allow=ulaw&alaw
disallow=all
host=iax2.syd.net2max.com
secret=Password
type=peer
username=899060XXXXX

Incoming Settings 

In the User Context, enter the Oztell User ID:  899060XXXXX 

 
In the User Details enter the following:

context=from-trunk
secret=Password
type=user

 Registration 

In the registration field, enter the following: 

899060XXXXX:Password@iax2.syd.net2max.com

After all have been done, click on the Submit Changes button and click on the red bar across the top of the screen. 

 

4.3.4  Astratel

To make an international call, Astratel requires the numbers dialed to follow the international format Access Code (0011) + Country code + area code + phone number e.g. 0011 60 6123456.  To call an Australian number e.g. Sydney 67541234, Astratel requires it in the following Australian format, Area Code + Phone number e.g. 02 67541234. Therefore the dialing rule will be in this form: 

We need several patterns here: 

Pattern

Explanation

8888XXXX

This pattern tells Astratel to dial the inter Astratel’s numbers

0011+ZXX.

This pattern dials all international numbers by prefixing it with 0011 since the Outgoing routing stripped the 0011 before the number is sent to the trunk.

0+4XXXXXXXX

Using Astratel to dial any Australian Mobile number

 

 
Your Outgoing Dial Rules box will look like this;

8888XXXX
0011+ZXX.
0+4XXXXXXXX

Next we need to create the Outgoing Setting, Incoming Settings and Registration.

Outgoing Settings 

In the Trunk Name field we will enter the name of this trunk: astrasip (you can call it whatever you like)

In the Peer Details we will have the following;

*Note:  Astratel requires fromdomain=sip03.astrasip.com.au without which it may not work. Entries in bold are mandatory, while the rest can be left out.

allow=alaw&ulaw
disallow=all

fromdomain=sip03.astrasip.com.au

fromuser=8888XXXX

host=sip03.astrasip.com.au
insecure=very
secret= Password
type=peer
username=8888XXXX

Incoming Settings 

In the User Context, we enter the Astratel issued User ID: 8888XXXX 

 

In the User Details we will have the following (entries in bold are mandatory. Others can be left out).

 

canreinvite=no
context=from-trunk

fromuser=8888XXXX
insecure=very
qualify=no
secret=Password

type=user

username=8888XXXX

Registration 

In the registration field, we will enter the following:

8888XXXX:Password@sip03.astrasip.com.au/8888XXXX

After all these have been done, click on the Submit Changes button and click on the red bar across the top of the screen.

The Trunks screen in freePBX will look like the following illustration below:

 * For more trunk settings, please refer to APPENDIX  B

 Now that you know what the trunk will do, you may proceed to the next chapters to create the Inbound and outbound routes.