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.)
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:
X — Refers to any digit between 0 and 9
N — Refers to any digit between 2 and 9
Z — Any digit that is not zero. (E.g. 1 to 9)
[Various] — Match only one character that
matches any of the one in the square brackets. (E.g. [02-68*#] would match
0, any number between 2 and 6 inclusive, 8, * and #. Or, another way of
saying this would be 'Match * or #, or a number that isn't 1,7 or 9') –Avoid
using this notation in your Trunk Dial Rule as it does not seem to work. Use
this only in your Outgoing Route Dial Pattern.
.
—
Wildcard. Match any number of anything. Must match *something*.
| — This lets you use a '0 to dial out' (or '9' in
the US) by matching anything before the line, but not sending it to the
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:
Trunk (a) charges the best rate for Local calls but is expensive for Mobile calls and not so great for international calls.
Trunk (b) has great rate for international call.
Trunk (c ) has good mobile rate and will allow 1300 numbers while the other 2 do not.
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.
For
this example, let’s create 3 SIP trunks; Pennytel, Oztell and Astratel
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.
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 |
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 |
In the User Context,
enter the Pennytel User ID:
888XXXXX
|
In
the User Details we will have the |
canreinvite=no |
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
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. |
Next we need to create the Outgoing Setting, Incoming Settings and Registration for Oztell.
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 |
In the User Context,
enter the Oztell User ID: 899060XXXXX
|
In the User Details enter the following: |
canreinvite=no |
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.
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.
In the Trunk Name, enter the name of this
trunk: oztelliax (as an example)
|
Note:
You must enable all the codecs that you want to use through
Oztell’s web page. |
allow=ulaw&alaw |
In the User Context,
enter the Oztell User ID: 899060XXXXX
|
|
context=from-trunk |
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.
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 |
|
|
8888XXXX |
Next we need to create the Outgoing Setting, Incoming Settings and Registration.
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 |
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 |
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.