Redirect PSTN call to Voip Provider

Hi Guys,

I am new to asterisk and I am trying to redirect calls from PSTN to a VoIP provider through IAX. I have read some articles from voip-info.org but still not clear to me(some of the commands). Would someone explain the third line of below config.

; Unconditional Call Forward
;
; create call forward
exten => _21X.,1,GotoIf($[${EXTEN:-1} = #]?2:3)
exten => _21X.,2,StripLSD(1)
exten => _21X.,3,DBput(CFIM/${CALLERIDNUM}=${EXTEN:4})
exten => _21X.,4,Hangup
;

I would highly appreciate if someone will provide a sample(working) configuration.

Thank you.

-Silver

The idea is to put a number, to where the user wants to redirect his phone, in AstDB database, that is a part of Asterisk. So this way the number to where the redirection is made is saved in permanent storage. You can retrieve this information when you are writing the Asterisk DialPlan that takes care of incoming calls to an extension.

Thank you for sharing your idea. I can now start to figure out this thing.

-Silver

Hi dejanst,

Thank you for your idea. I get your point in putting the number to the AstDB. In my case I am forwarding it to a provider on IAX Trunk, would that mean I will store the Channel Name(iax.conf) of that trunk to the asterisk Database? Is it possible to retrieve the Channel Name(in iax.conf) to be used in extension.conf? I am still trying to gather the right pieces of info right now.

Any suggestion/clarification is very highly appreciated. Thank you.

-Silver

Can someone explain the third line of the configuration? Thanks

You have to do everything in the Dialplan (extensions.conf).

  • read about Asterisk applications for reading/writing in AstDB
  • have a thought on how you should use the information from AstDB in the Dialplan
  • try to write the Dialplan. If you get stuck, ask here for help

Strip the first 4 digits off the extension number and store the rest of the extension in astdb entry CFIM/xxxxx where xxxxx is the value of the variable CALLERIDNUM. I don’t know how CALLERIDNUM gets set as there is a function that would return the caller ID number, so I wouldn’t expect there to be a standard variable of that name. I can’t tell you how the stored information is used, without seeing the rest of the dialplan, although my guess is that it is for the reason already explained.

In particular note that this code seems to be about providing a means to change the forwarded to number, not about the forwarding. You will not need to use AstDB if you always forward to the same number.

Also note that, when people start repeating questions, essentially unchanged, after getting a valid answer, it generally means that they don’t understand enough of how Asterisk works to benefit from asking the question in the first place.

Thank you for all your replies. It was a big help in the progress of my learning.

-Silver

Always happy to help a man that wants to learn how to fish on his own :wink: