Simple Asterisk Dialplan
Trunks and Outbound routing often cause confusion for the newbie to Asterisk so lets start off by laying down some ground rules 
Understanding Outbound routes and Trunks.
We want to make it simple for our users to make outgoing calls. They should not need to dial specific codes to use specific trunks / service providers. They should be able to dial local numbers and where necessary the exchange should insert the full long distance code.
The number dialed should always be checked with ENUM to see if we can connect directly and bypass a trunk call charge.
I live in an area where local calls consist of 5 or 6 digits and the area code is 01483 (Guildford). When making calls through one of my voip providers (voipstunt) I need to send the full number in International format i.e. 441483765432 which equates to 01483 765432.
In the Outbound routes I have specified :-

This specifies that a user dialing 01, 02, 03 and 00 plus 0500, 0508, 0800 and 0808 plus any number between 20000 and 999999 should all be passed to the ENUM trunk. If the call cannot be connected via ENUM then use the VOIPSTUNT trunk followed by the SMSDISCOUNT trunk. This also removes the initial 0 if dialed i.e. long distance or International.
In the ENUM trunk I have :-

The trunk will automatically add the country code 44 for all numbers passed starting with 1, 2, 3, 5, 8 (plus following digits) and it will add 441483 to numbers starting 2-9 followed by 5 or more digits.
If the trunk is passed a 0 then strip this off (00 is international access code in the UK) and process the rest of the numbers
The VOIPSTUNT trunk is extremely similar :-

VOIPSTUNT want the numbers passed in the UK international format so all UK calls are sent starting with 0044 added. Local calls have 00441483 added and International calls have 0 added (the original 0 was stripped off by the Outbound route).
Now my users just dial either local, long distance or international and Asterisk checks all calls using enum and then passes the call to voipstunt if enum fails and to smsdiscount if voipstunt fails.
