PBX · Asterisk 18+

Register an Asterisk pjsip trunk to DIDHub

A minimal, copy-pasteable pjsip configuration for Asterisk that registers to DIDHub, accepts inbound, and dials outbound. Assumes Asterisk 18+ where pjsip is the standard.

/etc/asterisk/pjsip.conf

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

; Registration to DIDHub
[didhub-reg]
type=registration
outbound_auth=didhub-auth
server_uri=sip:sip.didhub.io
client_uri=sip:[email protected]
retry_interval=60

; Auth credentials
[didhub-auth]
type=auth
auth_type=userpass
username=trunk_xxxxx
password="<PASSWORD>"

; AOR (where the trunk lives)
[didhub-aor]
type=aor
contact=sip:sip.didhub.io:5060
qualify_frequency=30

; Endpoint (the actual trunk)
[didhub]
type=endpoint
transport=transport-udp
context=from-didhub
disallow=all
allow=ulaw,alaw,opus
outbound_auth=didhub-auth
aors=didhub-aor
from_user=trunk_xxxxx
from_domain=sip.didhub.io
direct_media=no
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes

; Identify inbound traffic from DIDHub by source IP
[didhub-identify]
type=identify
endpoint=didhub
match=sip.didhub.io

/etc/asterisk/extensions.conf

; Inbound: send to extension 100
[from-didhub]
exten => +15551234567,1,NoOp(Inbound from DIDHub)
 same => n,Dial(PJSIP/100,30)
 same => n,Hangup()

; Outbound from extensions
[from-internal]
exten => _+X.,1,NoOp(Outbound via DIDHub)
 same => n,Dial(PJSIP/${EXTEN}@didhub,60)
 same => n,Hangup()

Apply & verify

asterisk -rx "pjsip reload"
asterisk -rx "dialplan reload"
asterisk -rx "pjsip show registrations"
asterisk -rx "pjsip show endpoints"

Expected: registration Registered, endpoint Available (Avail).

NAT note

If Asterisk runs behind NAT add external_media_address=<public-ip> and external_signaling_address=<public-ip> to [transport-udp], and forward UDP 10000-20000 (RTP) to the host.

Ready to get a number?

Pick a DID in 130+ countries from $1.99/month. Activates instantly on most numbers.