Blocking outgoing calls

Hi everybody.

I’m quite new to Asterisk, so I’m sorry if the question is quite stupid :smile:
I\m running Asterisk Asterisk 1.8.18.0. I set up Asterisk to block all outgoing calls except some predefined destinations. I also add default code for local calls if it wasn’t specified by user. So I have following lines in my extensions.conf:
[outbound]
exten => _XXXXXXX,1,GoTo(8351${EXTEN},1)
exten => _[78]35[12].,1,NoOp()
same => n,Dial(SIP/sipnet/98${EXTEN:1},60,TM(answer))
same => n,Hangup

Now I need to add another outbound pattern which is completely different, it is 8800XXXXXXX. What do I need to add to my configuraion? Thanks for your help in advance.

Repeat the second line with the new pattern. Use wildcards for the third and fourth lines.

Thanks a lot! Yes, I already tried to add the new pattern to the second line, so my config file looks like this:
[outbound]
exten => _XXXXXXX,1,GoTo(8351${EXTEN},1)
exten => _[78]35[12].,1,NoOp()
exten => _8800XXXXXXX,1,NoOp()
same => n,Dial(SIP/sipnet/98${EXTEN:1},60,TM(answer))
same => n,Hangup
But it doesn’t work as expected because as you said I need to use wildcards for the last two lines. What did you mean by this?

same is _8800XXXXXXX, which is not as wild a wild card as I meant. That is the effect of using same, here.

Please read up on dialplans, as I think you are stabbing in the dark, rather than doing this with any understanding.

Well, I understand that in that config _[78]35[12]. will never be dialed, only _8800XXXXXXX. I’ll try to figure the solution out by reading more docs.

Study this chapter several times and you will achieve your task
asteriskdocs.org/en/2nd_Edition/ … P-5-SECT-1

Thanks for the link, this manual is really clear and understandable. So If I got it right I can just repeat the last two lines for the new pattern and get the config like this:
[outbound]
exten => _XXXXXXX,1,GoTo(8351${EXTEN},1)
exten => _[78]35[12].,1,NoOp()
same => n,Dial(SIP/sipnet/98${EXTEN:1},60,TM(answer))
same => n,Hangup
exten => _8800XXXXXXX,1,NoOp()
same => n,Dial(SIP/sipnet/98${EXTEN:1},60,TM(answer))
same => n,Hangup

It’s quite straightforward, but it doesn’t look neat. I read about macros and wrote the following:
[outbound]
exten => _XXXXXXX,1,GoTo(8351${EXTEN},1)
exten => _[78]35[12].,1,Macro(macro-dial,${EXTEN})
exten => _8800XXXXXXX,1,Macro(macro-dial,${EXTEN})

[macro-dial]
exten => s,1,Dial(SIP/sipnet/98${ARG1:1},60,TM(answer))
exten => s,n,Hangup

I like the solution with macro but wonder, If there’s a better and simpler way to do that.

Nacros are deprecated, you should use subroutines. However what I was trying to get you to learn was:

exten => _XXXXXXX,1,GoTo(8351${EXTEN},1)
exten => _[78]35[12].,1,NoOp()
exten => _8800XXXXXXX,1,NoOp()
exten => _X.,n,Dial(SIP/sipnet/98${EXTEN:1},60,TM(answer))
same => n,Hangup

Although note that the Hangup line has been redundant since Asterisk 1.4.

I thought about using _X. pattern for the last two lines. However, what I couldn’t realize is that if I set priority “n” this extension will be used only if one of the previous patterns were matched. Thank you very much for helping me to understand the logic here!