How to allow inbound calls in pjsip and Asterisk 13?

10,553

Solution 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.

Solution 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:[email protected]:5060
server_uri = sip:sipgate.co.uk:5060

[auth_sipgate_premium]
type = auth
username = 0000000
password = password

[sipgate_aor_premium]
type = aor
contact = sip:[email protected]

[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)
Share:
10,553
user3025978
Author by

user3025978

Updated on June 29, 2022

Comments

  • user3025978
    user3025978 almost 2 years

    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:[email protected]>' failed for '192.168.34.1:5062' (callid: [email protected]: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?

    • user3788685
      user3788685 about 7 years
      Can you update your question with the relevant bits from your sip config files and dial plan please. I have working configs which I can check later for you.
    • user3025978
      user3025978 about 7 years
      @user3788685 hi - I have nothing special in my config. Dialplan is only Dial function. Can you give me youur config? pjsip.conf and trunks config? I have realtime endpoints (postgres).
    • user3788685
      user3788685 about 7 years
      done - let me know if you have any problems and I can update/change the info in the answer below - my config is static, no db stuff at all - sorry. Should get you going though
    • user3788685
      user3788685 about 7 years
      did you manage to get it working?