Block outgoing calls

Hi.
I wonder if I can block outgoing calls to certain pattern ?

I also wonder how its possible for a stranger in another country to make calls trough my asterisk ?
Dosent the extension he use match my sip.conf ?
I see in the cdr logfile (mysql actually) that the call was made from “sip/xxx.xxx.xxx.xxx-xxxxxx” instead of one of my phones/extensions. How is it possible ?
And, how do I prevent that in the future ?

Lets say I want to allow all call except the one that starts with 44, how will i write that in my extensions.conf ?

Edit: Forgot, the version i run is: Asterisk 1.6.0.5
Run it on Ubuntu server

[code]SIP.CONF:

[general]
context=default
port=5060 ; UDP port for Asterisk
bindaddr=0.0.0.0
externip=<MY_DOMAIN>
localnet=192.168.1.0/255.255.255.0
srvlookup=yes ; Enable DNS SRV server
nat=no
disallow=all
allow=ulaw
register => USER:PASSWD@<MY_VOIP_PROVIDER>/200

[call_out]
type=friend
host=<VOIP_PROVIDER_SERVER>
fromdomain=<VOIP_PROVIDER_DOMAIN>
progressinband=yes
nat=no
canreinvite=no
qualify=yes
insecure=port,invite
username=
fromuser=
secret=
dtmfmode=inband
disallow=all
allow=ulaw

[200]
type=friend
secret=
nat=no ; Telephone without NAT
insecure=port,invite
host=dynamic ; the devices can be registered with different IPs each time
canreinvite=no ; Asterisk by default redirects
disallow=all
allow=ulaw



.
---------------------------------------------------------------[/code]

[code]

EXTENSIONS.CONF

[general]
static=yes
writeprotect=no
clearglobalvars=no

[default]

include => day,10:31-23:59,mon,,
include => day,,tue-thu,,*
include => day,07:00-14:29,fri,,
include => helg,,sat-sun,,*
include => helg,00:01-10:30,mon,,
include => helg,14:30-23:59,fri,,

; Computer basement
exten => 200,1,Wait(1)
exten => 200,2,Dial(SIP/200,60)
exten => 200,3,Hangup

; Call out
; exten => _044X.,1,Hangup
exten => _0X.,1,Dial(SIP/${EXTEN:1}@call_out,r)
exten => _0X.,n,Hangup

[day]
exten => 200,1,Wait(1)
exten => 200,2,Dial(SIP/400,60)
exten => 200,3,Hangup

[helg]
exten => 200,1,Wait(1)
exten => 200,2,Dial(SIP/200,60)
exten => 200,3,Hangup
---------------------------------------------------------------[/code]

See the “Howto Allow Only One SIP Trunk” for pointers to information on locking down Asterisk.

See Asterisk The Future of Telephony for how to write dial plans.

[quote=“david55”]See the “Howto Allow Only One SIP Trunk” for pointers to information on locking down Asterisk.

See Asterisk The Future of Telephony for how to write dial plans.[/quote]

Ahh, thanks.
Hopefully that will hold the chinese people out for a while.
I’ve missed allowguest, also my firewall was open on 5060 from ALL because i used to travel alot before, and i never know what address i had. Now it’s open only to my VOIP-provider.

About the dialplan, i now has something to read tonight. Thanks

Hello… did you solve the issue?? about blocking outgoing calls that starts with 06 for exapmle??

Blocking calls that begin wtih 06 is a trivial bit of dialplan programming. If you don’t know how to do it, you need to re-read the dialplan section in the Definitive Guide.

Lets say I want to allow all call except the one that starts with 44, how will i write that in my extensions.conf ?
=>
Add following in your dialplan before you dial out,
same =>n,GotoIf($["${EXTEN:0:2}" = “44”]?:block,s,1)
… …
[block]
exten => s,1, Hangup()

–Satish Barot

Define an extension, using a pattern than matches more specifically for the unwanted number block, than the pattern that matches for outgoing calls, and have it dispose of the call as you see fit. Again, if you need to know how, you do not understand dialplans well enough to be writing them.

I have tried that thing today mate, it does not really work out, what happened is that it blocked incoming calls from 44 not the other way around. :face_with_raised_eyebrow:

Show us your Asterisk cli output for the failed call and dialplan.

1 Like
[block]
exten => s,1,Hangup()

[internal]
exten => _1XX,1,Answer
exten => _11X,n,GotoIf($["SIP/{EXTEN:0:3}" = "123"]?:block,s,1)


exten => _1XX,n,MixMonitor(/home/$HOME/${CALLERID(num)}-${CALLERID(dnid)}-${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)}.wav,B)
exten => _1XX,n,NoOp(internal-phone-call)
exten => _1XX,n,Dial(SIP/${EXTEN},12,r)
exten => _1XX,n,Voicemail(${EXTEN}@internal-vm)
exten => _1XX,n,StopMixMoniot()
exten => _1XX,n,Hangup()


The condition will never be true, because the second digit will always be 1, given the pattern. Also given what you have asked in other threads, you want to block when the condition matches, but you would actually continue here. Combining the two, this code will always send numbers beginning with 11 to the blocking code.

You need to understand what the suggestions are doing, not copy them blindly, otherwise you won’t be able to maintain them without further free consultancy.

I just saw that as you wrote it out.

Even when it is fixed it still does not work. :face_with_raised_eyebrow: