Integration · 5 min read

How to integrate a SIP trunk with Asterisk

Working pjsip.conf and extensions.conf for non-cli.site trunks, with non-CLI and CLI examples.

Prerequisites

  • Asterisk 18+ with PJSIP enabled
  • Trunk credentials from your dashboard (host, username, password)
  • Public IP or proper NAT settings

pjsip.conf

[noncli-transport]
type = transport
protocol = udp
bind = 0.0.0.0:5060

[noncli-trunk]
type = registration
outbound_auth = noncli-auth
server_uri = sip:sip.non-cli.site
client_uri = sip:USERNAME@sip.non-cli.site
retry_interval = 60

[noncli-auth]
type = auth
auth_type = userpass
username = USERNAME
password = PASSWORD

[noncli-trunk]
type = aor
contact = sip:sip.non-cli.site
qualify_frequency = 30

[noncli-trunk]
type = endpoint
transport = noncli-transport
context = from-noncli
disallow = all
allow = ulaw
allow = alaw
allow = g729
outbound_auth = noncli-auth
aors = noncli-trunk
from_user = USERNAME
from_domain = sip.non-cli.site
direct_media = no
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes

[noncli-identify]
type = identify
endpoint = noncli-trunk
match = sip.non-cli.site

extensions.conf

[outbound-noncli]
; Non-CLI route — CLI is stripped upstream
exten => _X.,1,NoOp(Calling ${EXTEN} via non-cli.site)
 same => n,Dial(PJSIP/${EXTEN}@noncli-trunk,60)
 same => n,Hangup()

[outbound-cli]
; CLI route — present your own number
exten => _X.,1,NoOp(Calling ${EXTEN} with CLI)
 same => n,Set(CALLERID(num)=15551234567)
 same => n,Set(CALLERID(name)=Acme)
 same => n,Dial(PJSIP/${EXTEN}@noncli-trunk,60)
 same => n,Hangup()

Test

  1. asterisk -rx "pjsip show registrations" — status should be Registered.
  2. From a softphone, dial an E.164 number (no +, no 00 prefix; just country code + number).
  3. asterisk -rx "pjsip set logger on" to see the SIP trace if anything fails.

Common issues

  • 403 Forbidden — wrong password or your IP isn't authorized. Check the dashboard.
  • No audio — NAT. Set external_media_address and external_signaling_address in transport.
  • 488 Not Acceptable — codec mismatch. Add allow = opus or check destination supports g729.

Related in Integration

Still stuck?

Open a ticket