Help for Asterisk newbie - PSTN and SIP redirections

Hi all,

I have installed sucsessfully Astericks and Zaptel on low end Linux machine with X100P clone (Motorola SM56) and the basic setup is working (i have called to the connected X100P line and i have heard the demo).

My final setup requirments: call to my girlfriend in mexico from israel, with my mobile phone through asterisks and voipbuster SIP server.

The Flow:

  1. I want to call from local PSTN or mobile phone to the local X100P line (that one i have tested the demo with)
  2. (Optional, pass authorization),
  3. (Optional, hang the call, and callback to the caller),
  4. Enter International number (lets say, in mexico),
  5. connect to SIP server and dial through it to the mexican number,
  6. Connecting the incoming PSTN caller to the desired mexican destination.

I have been reading asterisk config files for hours… but i still need some help.
in the first version
Where should I start?
Do you need additional info?

Thanks alot!

Well, I’d break up the project into parts where you can succeed at each quicker, then do it all at the end.

  1. have two extensions that work and call each other.
  2. Setup PSTN that an extension can call out of.
  3. Have incoming call from PSTN call an extension.
  4. Have an extension call using SIP provider to mexico. (assuming that you have it setup and working)
  5. Create the “glue” extension than when called will offer dial tone to use the SIP provider.
  6. Now call into PSTN and call to Mexico.

First of all, thanks for the replay.

about step 1: the extentions are only virtual, right? so how can i call from one to another?
the extentions.conf contains the demo extentions. do i need to keep it? overwrite the whole file?

the first thing to keep in mind- EXTENSIONS ARE NOT CHANNELS.
Asterisk considers an extension (something you dial) and a channel (somewhere to send the call) as two VERY different things. THis makes things complicated, but adds MUCH flexibility. You are correct, extensions are virtual. Channels are real. You call from one to the other by making extensions for them, ie
exten => 1234,1,Dial(SIP/1234,20) ; rings sip acct 1234 for 20sec
exten => 1234,1,VoiceMail(1234@context) ; voicemail for 1234@context

second- extensions.conf is your friend. This is where 99% of this will happen. I will make the following assumptions: You have correctly configured the X100 card as zap channel 1, which is in the context [x100-in] (zapata.conf). You have correctly set up your SIP service provider, which is defined in sip.conf under the [voipbuster] heading. You also have a dial-out context, from which one can make outgoing calls.

last- the way extensions.conf works is with contexts. Every call/channel is ‘in’ a context, and a user on that call/channel can punch in any extension in the context they are in, and any contexts include =>'d in it.

So on to extensions.conf

for the [x100-in] context, you would probably want some kind of IVR to greet callers. You use extension s for this (start). If they push a button to react to the IVR, then they are dialing an ‘extension’ and must be handled accordingly. Remember, extensions can exist for them to dial that the audio files don’t tell them about.
exten => s,1,Background(someaudiofile)
exten => s,2,Background(someotheraudiofile)
exten => 1,1,Dial(SIP/1234) ; they push 1
exten => 2,1,Dial(SIP/1235) ; they push 2

exten => 9999,1,VMAuthenticate(1234@context) ; if they push 9999, it prompts them for the password. They must enter mailbox 1234’s VM password to continue.
exten => 9999,2,DISA(no-password,dial-out) ; if they put in a password, it gives DISA (direct inward system access), AKA a dialtone. They are now in the dial-out context and can dial any extension in or included to the dial-out context. If dial-out allows a call to be made through voipbuster, they can now do it.

Then you could put something like
exten => _011.,1,Dial(SIP/voipbuster/${EXTEN}) ; _ starting means it is a pattern which can match things. . at the end means ‘anything else’. So this will take any number that starts with 011, and send it to voipbuster.
exten => _1NXXNXXXXXX,1,Dial(SIP/voipbuster/${EXTEN}) ; dial any american style number through voipbuster (you may want to change that pattern to match Israel numbers)

The result of all this-
you can dial your x100 line, and when the thing picks up and starts playing messages, dial 9999. It will ask you for a password, put in your voicemail password for mailbox 1234. when you do this you will get a dialtone (which is being sent from *). You can then dial anything in dial-out, and as my example has it any number starting with 011 goes out through voipbuster, as does any 11 digit american style number. If you change that to your number style, then you can make long distance calls thru your cell and voipbuster to save money over dialing direct from your cell

Hope that helps!

I can say that thanks to you, i got the half flow working.
I am calling from the outside, authenticating, and getting dialtone!

no matter what am i pressing when i have dial tone, immiaditaly, i getting the busy tone.
and from the console:
– Executing DISA(“Zap/1-1”, “no-password|dial-out”) in new stack
== Spawn extension (x100-in, 9999, 2) exited non-zero on ‘Zap/1-1’
– Hungup ‘Zap/1-1’

how can i check the SIP configurations?
from the sip.conf:

at that point, should the [voipbuster] be a channel? how can i see the available channels?

i didnt try to call from one exten to the other (i dont know how to do it…).
one more question, how can i debug the whole thing without really calling over the PSTN?

Can anyone help?

You have an X100 PCI card that acts like an FXO interface. You plug a PSTN line into it, a line with dial tone on it. For extensions you need FSX interface. FXS expects a telephone set, not a line. An ATA adapter usually hass two FXS ports and will give you two extensions to use with your asterisk.

Any old telephone adapter from Vonage, packet8 etc might work if you have access to the adminsitrator login. Many people have manged to acquire it and have recycled them into other uses like for extensions on their * box. Then trot to Walmart or what ever you have to sell you a $5 tellephone and plug it in whith the RJ11 connector.

In demo file there is a [1234] extension already setup. Use that and its secret to set up the ATA for username and password and save to the ATA. Within a minute or two it should indicate it is registered on its display web page.

His problem is from what i can tell that his DISA isnt working, not that he needs extensions…

post yoru dial-out context from extensions.conf…

here is my dial out:

exten => .,1,Dial(SIP/voipbuster/${EXTEN})

i see what you are trying to do but that will not work. If you are specifying a pattern (a line taht can match more than one possible dialed exten) you must first include a _. It is also a VERY BAD idea to make _. (match ANYTHING), you should put a mask that matches your country’s phone numbers, ie for USA its 1NXXNXXXXXX.

The pattern match is for the authorized numbers (destination), not for the caller number (source), right?

Hi all,

I happen to have viewed this post and was wondering, when setting up a situation like this would we only need the one x100p card because it seems like another channel/line will be needed but i could be seeing ithis incorrectly. I, too, am considering a setup like this for myself but wondered if the next call would still be reliant upon one of my channels (Zap/1) or would the call be accessing a sip protocol through voipbuster and also using one of thier channels [ i only have one channel].

Need a little more clarification, somewhat confused?



One X100 is needed for each PSTN connection. In this case, ONE. The other line is SIP and asterisk handles that via IP and needs NO adapter.

avivgr- yes an exten => XXXX is something that a caller can dial, or something that can happen.

extensions.conf takes the following format:

include => someothercontext
exten => extension,priority,Application(arguments)

Every call or channel is ‘in’ a context. When a call is in a context, it can dial any extension in that context or any context included to the context it’s in (ie someothercontext). When caller dials an extension, it will look up priority 1 for that exten and execute that application. When that application is done it will look for the next priority.
For example: (s is the ‘start’ exten, used to match incoming calls usually)

exten => s,1,Answer() ; answers the line
exten => s,2,Playback(welcome) ; plays back the ‘welcome’ sound
exten => s,3,Background(ivr-menu) ; plays a caller the ‘ivr-menu’ sound, listening for caller to dial something
exten => s,4,WaitExten(5) ; does nothing for 5sec, listening for caller to dial something

exten => 1,1,Goto(sales-ivr,s,1) ; if caller pushes ‘1’ it sends them to [sales-ivr], exten s, priority 1

exten => 1234,1,Dial(SIP/1234,20) ; if caller dials 1234, it rings SIP/1234 for 20sec
exten => 1234,2,VoiceMail(1234) ; if nobody picked up it then goes to their voice mail

As Prayer says, one needs a channel (of some kind) for each line / active call. If you need to have a call come in and go out again, that takes two channels.
The poster here has one POTS analog channel (knockoff x100 card) and a SIP trunk to a provider. THis is his 2nd channel.