For certain ext allow only certain calls and restrict all

Dear all,
I am very new on asterisk
trying to play with it.
Configured what i want BUT,
I need to restrict certain ext to allow only certain calls and block all calls.
here is the code waht i used.

in extensions.conf

[for-skt-office]
exten => _5XXX!,n,GotoIf($["${CALLERID(num)}" = “5005”]?blocked-calls:${EXTEN},1)

[blocked-calls]
exten => _X.,1,Congestion()

IF EXT 5005 call then allow only 5XXX ext and block all ext

in sip.conf

[5005]
type=friend
host=dynamic
username=5005
secret=5005
canreinvite=no
nat=yes
context=for-skt-office
dtmfmode=rfc2833
allow=all

Pleas point out my mistake.

my requirement is :

I have 5XXX ext,
If call came from ext 5005 then allow to call only on 5XXX and block all other outgoing.

Thanks in advance.

-ashok

you are thinking to complex , use contexts for this config

make 5005 lock to internblock in sip.conf and the rest member of intern and use include to asign numberplans
[intern]
include=internal
include=external

[internblock]

include=internal

[internal]

dialpan for internal use
[external]

dialplan for external

My thought might be complex but I am very new on asterisk, so your language is too advance to understand

should I define contex, internal and external and on those contex define respective dialplan.

like:

in extensions.conf

[internal]
exten => _5XXX,1,Dial(SIP/${EXTEN},10)

[external]
exten => _[469].,1,Dial(SIP/${EXTEN}@sip-proxy-netphone)

and in sip.conf

[5005]
type=friend
host=dynamic
username=5005
secret=5005
canreinvite=no
nat=yes
context=internal
dtmfmode=rfc2833
allow=all

is it ok or need to do something other.

I just configured dialplan, ext and can call, and also used SIP proxy to dial international calls, beyond this i cant do anything trying to but fail.

I had reviewed the future of Telephony Asterisk book don’t find my requirement.

I want to block all other extensions or number except specified one to particular extension.

thanks in advance

Hi Ashokgtm,

Sander4000 has given you the answer to your question but I will give you another example.

I don’t know what your dialplan looks like so it’s a bit of a guess.
I am assuming you have an outgoing context?

If the cllerid is 5005 goto context outgoing priority 3.

[outgoing]
exten => _X.,1,GotoIf($["${CALLERID(num)}" = “5005”]?outgoing,${EXTEN},3)
exten => _X.,2,Dial(${PSTN-TRUNK}/${EXTEN},30)
exten => _X.,3,Hangup()

You may nee to change it to suite your needs.

Brett

hello brett/bwilks

I was also thinking like that before but doing so it will restrict all outgoing call for the 5005 ext, I want to allow local extensions and other certain pstn numbers also, beside those specified number all outgoing should be blocked.

your syntex work but it will restrict all outgoing.
I want to block all outgoing except certain dial plans.

waiting for your reply.

-ashok

[internal]
exten => _5XXX,1,Dial(SIP/${EXTEN},10)

[external]
exten => _[469].,1,Dial(SIP/${EXTEN}@sip-proxy-netphone)

and in sip.conf

[5005]
type=friend
host=dynamic
username=5005
secret=5005
canreinvite=no
nat=yes
context=internal
dtmfmode=rfc2833
allow=all

this will make 5005 ony call internal numbers but if you asign your sip client to a empty context you can do many configurations
[fullrights]

include=internal
include=external

[onlyinternal]

include=internal

[internal]
exten => _5XXX,1,Dial(SIP/${EXTEN},10)

[external]
exten => _[469].,1,Dial(SIP/${EXTEN}@sip-proxy-netphone)

and in sip.conf

[5005]
type=friend
host=dynamic
username=5005
secret=5005
canreinvite=no
nat=yes
context=onlyinternal
dtmfmode=rfc2833
allow=all

[5006]
type=friend
host=dynamic
username=5005
secret=5005
canreinvite=no
nat=yes
context=fullrights
dtmfmode=rfc2833
allow=all

in this situation 5005 can only call the defined dialplan in internal
5006 can call both dialplans

with this you make many different levels, you can add many rules like this just put all the dialplans in seperate contexts a context is [lalalala name does not matter]
and use include= to give the users access to the dialplan. so you can make a dialplan that allows calls to mobile numbers local numbers etc etc.

good luck

Hi,

Have you got it working? Do you need more help?

Brett

thanks,

Its working for me.

-ashok