问题
I have configured Asterisk 13.13.1 with PJProject 2.5.5 and enable PJSIP as SIP driver (without compiling chan_sip).
I have the fully configured system and it's working but I have some problems with incoming calls. I have few numbers connected with my host and when I calling from any public number I noticed this info on asterisk remote console:
[Feb 24 14:27:16] NOTICE[5291]: res_pjsip/pjsip_distributor.c:525 log_failed_request: Request 'INVITE' from '"zzzzz" <sip:zzzzz@192.168.34.1>' failed for '192.168.34.1:5062' (callid: 0e07e7607f8f62dd225347363173bb9f@192.168.34.1:5062) - No matching endpoint found
And if I add the number which is calling to my Asterisk to endpoints then it's working - I can pick up this call.
How to add the possibility to allow all inbound calls?
回答1:
You need to create an anonymous endpoint to accept inbound calls from unknown endpoints.
Be aware that adding an anonymous endpoint opens the system to extension scanning attacks where scanners try to find out which extensions you have configured in your system. They do this either to spam you with advertising calls, or exploit call transferring to call long distance numbers, or for some other ulterior motive.
After creating an anonymous endpoint, associate it with a context different from that used by your extensions. This prevents them from dialing long-distance through your trunks.
To add an anonymous endpoint in pjsip.conf
, add the following lines:
[anonymous]
type=endpoint
context=anonymous
disallow=all
allow=speex,g726,g722,ilbc,gsm,alaw
In the dialplan extensions.conf
:
[anonymous]
exten => _XXXXX,1,GotoIf(${DIALPLAN_EXISTS(local-extensions,${EXTEN},1)}?local-extensions,${EXTEN},1)
same => n,Hangup(1)
local-extensions
is the context listing your local extensions.
回答2:
It looks like your missing something from you pjsip
config. My basic config is as follows and is based on a sipgate setup with an internal extension. This config has been extracted from a running box (though usernames & passwords have been removed);
pjsip.conf
[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0
[reg_sipgate_premium]
type = registration
retry_interval = 20
max_retries = 10
contact_user = 0000000
expiration = 120
transport = transport-udp
outbound_auth = auth_sipgate_premium
client_uri = sip:0000000@sipgate.co.uk:5060
server_uri = sip:sipgate.co.uk:5060
[auth_sipgate_premium]
type = auth
username = 0000000
password = password
[sipgate_aor_premium]
type = aor
contact = sip:0000000@sipgate.co.uk
[sipgate-preimum]
type = endpoint
context = incomingsipgate
dtmf_mode = rfc4733
disallow = all
allow = alaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
timers = yes
from_user = 0000000
from_domain = sipgate.co.uk
language = en
outbound_auth = auth_sipgate_premium
aors = sipgate_aor_premium
extensions.conf
[incomingsipgate]
exten => 0000000,1,Goto(sipgate-in-premium,0000000,1)
[sipgate-in-premium]
exten => 0000000,1,Verbose(Incoming call from Sipgate line CallerID=${CALLERID(all)})
exten => 0000000,2,Goto(internal-ext,120,1)
[internal-ext]
exten => 120,1,Dial(SCCP/120,20,o,CallerID=${CALLERID(all)})
This line is used to catch any free phone (0500) number and route it via sipgate when a user internally dials 90500xxxxxxx;
exten => _90500.,1,Dial(PJSIP/${EXTEN:1}@sipgate-preimum)
回答3:
For sure, the problem is in your incoming line operator context. The problem is not in pjsip - it is in dialplan. Please check your trunk (or registration context value to understand proper dialplan section:
[outer]
exten=>_1234567,1,NoOp(Incoming call to public number 1234567)
exten=>_1234567,n,GoTo(outer,3333,1)
exten=>_1234567,n,Hangup()
exten=>_3333,1,NoOp(Transfered from public context to local extension 3333)
exten=>_3333,n,Dial(PJSIP/${EXTEN},180)
exten=>_3333,n,Hangup()
Change 1234567 to your public number and 3333 to the local number that has to receive this incoming call. And of course, set outer
as context for incoming calls number provider registration (trunk).
来源:https://stackoverflow.com/questions/42439846/how-to-allow-inbound-calls-in-pjsip-and-asterisk-13