How do I connect my PBX to the PSTN (Asterisk Newbie, UK)

I need to figure out rather urgantly how to configure my Asterisk server to make it send and recieve calls on the PSTN (I’m in the UK by the way), I have a zaptel card and it’s plugged into the line. The FreePBX ISO I used to set up Asterisk was “PBX in a Flash” and it created an outbound route “9_outside” with the dial pattern “9|.” with the zap card as the trunk sequence, which I’ve named “ZAP/1” because the FreePBX site told me to.

I’ve specified my caller ID in the trunk configuration, set max channels to 1, outbound dialing prefix to 9, and every page I google about setting this up says the next step is “Set a dial rule you want for this trunk”, all the drop down items talk about US/CAN, what do I type in the dial rule box? please bear in mind I am a complete newbie to phone systems. I have a book on Asterisk, but it’s confusing, aimed at configuring WITHOUT FreePBX (just using config files), and seems to only talk about US dialing codes, I’m in the UK. If I try calling a outside line at the moment the voice says “All circuits are busy now, please try your call again later”

As for inbound routes I haven’t found any information on this yet, but I want it to simply ring all the extentions when a call comes in (once I have it doing that I can worry about anything mor complex), I have 13 SIP extentions set up and have not begun configuring the inbound route. PBX in a flash does not seem to specify a default inbound route.

at the command prompt use asterisk-r to watch the number being sent out to the trunk

I am assuming here you have just a normal British Telecom circuit and not a featureline or going onto another PABX

so if you are dialling 9 01632 964023

you should just see 01632 964023 being dialled out to trunk

or look in /var/log/asterisk/full files and it will show where things are going pear-shaped. if you post any files up here strip out the private info and also use the code tags or the formatting will be all messy…

Also, what is in these files?

/etc/asterisk/zapata.conf
/etc/asterisk/zapata-auto.conf

When I dialed, too much stuff flew by at the asterisk -r prompt to undertstand any of it, here are the files.

{link deleted due to website housekeeping}
{link deleted due to website housekeeping}
{link deleted due to website housekeeping}

I search/replaced the phone numbers we were dialing with PhoneNumberRemoved, if it’s prefixed with 9 in the log it’ll show up as 9PhoneNumberRemoved

your config files look OK but Asterisk is not creating the Zap channel

at Asterisk CLI, type “zap show channels” to check all your zap channels are there

I would suggest also create 4 separate trunks with Zap channel IDs instead of g0 (you will need this for routing the inbound calls as well), and I had similar issues when using g0 group

then in outbound routes you can set the order in which each trunk is used. Try first with one trunk you know is plugged into a working phone line…

zap show channels:

Chan Extension Context Language MOH Interpret
pseudo from-zaptel en default

I don’t know how to set up the channels. Can you please instruct me. We have 4 line (first 3 on the same number and the 4th one a different number) but at the moment only one of the lines is connected to the zap card, it’s connected into channel 1.

thanks

it looks like Zap channels are not there…

(the automatic install of zaptel can be a bit screwy sometimes!)

in zapata.conf

change the line

;Include genzaptelconf configs
#include zapata-channels.conf

to

#include zapata-auto.conf

then use commands at shell prompt

amportal stop
service zaptel restart
amportal start

and try “zap show channels” again from Asterisk CLI…

Thank you. I followed your instructions:

Chan Extension Context Language MOH Interpret
pseudo from-zaptel en default
1 from-zaptel en default
2 from-zaptel en default
3 from-zaptel en default
4 from-zaptel en default

does that look better? Now when I dial 9 and an outside number instead of Asterisk telling be the device is busy, I get BT telling me the number has not been regocnised - which is progress, now at least it’s leaving the local network. :slight_smile:

What do I do next?

yep thats got your trunk working…

did BT provision normal lines or Centrex/Featurelines (where you have to dial 9 anyway like on a PABX) for your project?

check also in the asterisk logs for what number is going out to BT. you should see something like this…

NB: in my case I have had to put the digit 9 back in because of the featureline, 17070 is the BT test number

Called 3/917070
– Zap/3-1 answered SIP/208-b7603de8

I tried calling 17070 and it say in the log “Called 1/917070”

As far as I know, no, this line should not have a 9 on it, the pbx should be stripping off the 9 prefix

I stuck a 9 in a box i shouldn’t have, stupid me. Works fine thanks for your help! :slight_smile:

Do I have to set up anything fancy extra now to handle the multipul numbers, we have lines 1, 2, and 3 on one number, and line 4 on another.

Right now I only have one trunk set up, it’s ZAP/1, i think it may have been called ZAP/g0 or something before I renamed it

incidentally you will need a couple of additions to zapata.conf to make caller ID work correctly…

usecallerid=yes
cidsignalling=v23
cidstart=polarity

to create the individual trunks, go to “Add Zap Trunk” and where it says “zap channel identifier” enter the channel number. You will need these for the inbound routing.

when you have 4 trunks set up, you can assign them all DIDs via “Zap Channel DIDs” on freePBX.

Usually this will be the telephone number of each trunk. Then you can use these numbers for inbound routes in FreePBX. If you have the same number on several trunks, use the “hidden” or DDI number that BT usually provision alongside it.

Okay I’ll need to look in to this and get the lines hooked up to the pbx before I can continue, I probably wont be replying to this thread again today. Thanks for all your help, I’ll probably need more help tommorow though.

By the way, do if I have 4 trunks then when I’m mkaing an external call how do I make my first number (choose whichever is free form 1, 2 and 3) I’ll get back to this tommorow. Thanks again. :slight_smile:

in the outbound routes you can set the order in which the trunks are used… I have 3 on my system but for various reasons they are not used as “1,2,3” order but “3,1,2” (bear in mind outbound caller ID will be any of the numbers provisioned to your trunks, you may need to advise those you call about this issue)

We’ll only be using lines 1, 2, and 3 for outbound calls, 1, 2, 3, and 4 for inbound (4 is on a diferent number), so if lines 1, 2 and 3 are busy and we attempt an outgoing call it should say the lines are busy, so our caller id should always be the first one.

Is this posable?

Also, sorry I can’t figure this out but if you create 4 trunks under Basic > Trunks, then how does it know which one is for which channel in the zap card (and of course, if you have more than one card, as we may be adding adding another for a 5th line, how does it know which card), does it know this from the value in “Zap Identifier (trunk name)”? And should I start numbering them ZAP/g0 and up, or ZAP/0 and up, or ZAP/1 and up? I think need to know this to specify the trunk sequence for outgoing routes (so I can make it lines 1, 2, and 3 but not 4)

I’m a bit confused about how the trunks work.


Also, at them moment I have the outgoing dialing pattern set to “9|.” without quotes if I want it not to require a prefix, then do I set it to “.” or just leave it blank, I found that setting it to “.” works but will this break anything? (Someone who worked with asterisk told me they had a problem when the first 3 digits of area code of the outside number they dial coincidentally matches one of your extentions) Is there a more correct way to do it?

Zap identifier is a single digit corresponding to each channel as identified in the “zap show channels”. Don’t use g0 as thats the entire group of 4 trunks.

Once you have done this, you can set the “Zaptel DIDs”. Now if all your lines are on the same number i.e 964001, there should also be an individual DDI number for each one (at least there is on the BT circuits we have with this arrangement). If you ask the BT lot nicely they should give this to you.

NB: these numbers are not consecutive but randomly picked from the allocation at your local exchange.

Whilst I think you may be able to allocate multiple zaptel trunk to the same DDI / DID I haven’t tested this but created a separate DID on the individual number. (This was more also so I could keep track of physical cabling a bit easier)

If you don’t want to use the last line for outbound, then don’t put it in the trunk outbound routes, just use the first three.

You can try dialling without a prefix but that will (as you mentioned) cause problems when the first few digits of any outbound number collide with that of a extension or feature code. Most phone systems in the UK start numbering from “level 2” (i.e) 200 or 2000 upwards, as do normal telephone exchanges so there is bound to be a collision, especially when people dial local numbers on just 6 digits.

You might be able to do clever stuff in the dial plan of a local device such as IP phone or ATA but it varies depending on each device. TBH you are better off IMO keeping to the standard convention of using 9 as an escape digit to the PSTN.

I’m in the UK and I use ‘no prefix’ dialling, with internal extensions starting from 200.

Possibly this is just luck as my local exchange does not have any numbers beginning 2, but it does seem to also work for customers on other exchanges so far…

My outbound routes are like:
0[1278]X.
47XXXX
48XXXX
5XXXXX
7XXXXX

The first line handles the none-locals I want to permit on that trunk (01 02 07 and 08 numbers), the rest cover the valid local six digit numbers.

I also have a separate emergency route that accepts 999 & 112, which uses all trunks including fax line etc.

One other tip, make sure you have the Zaptel drivers properly configured for the UK.
In your /etc/modprobe.conf you should have ‘options (drivername) opermode=UK’ for whatever driver you Digium card uses,
ie. if it’s a TDM400 which uses the WCTDM driver,
add
options wctdm opermode=UK
before
install wctdm /sbin/modprobe --ignore-install wctdm && /sbin/ztcfg

if it’s a TDM2400 add
options wctdm24xxp opermode=UK
before
install wctdm24xxp /sbin/modprobe --ignore-install wctdm24xxp && /sbin/ztcfg

and so on.

Also check that the loadzone & defaultzone parameters in /etc/zaptel.conf are set to UK

And, finally, run
fxotune -i 1
to set up the line matching (and again after any connection changes).