Open-source telephony framework

DIDHub for Asterisk

Add DIDHub as a SIP trunk in Asterisk via chan_pjsip — full pjsip.conf and extensions.conf examples below. Works with Asterisk 18, 20, 21 and beyond.

Why DIDHub + Asterisk

Asterisk is the open-source telephony framework underneath FreePBX, FusionPBX, Issabel, AsteriskNOW, and many commercial PBXs. DIDHub connects via the standard chan_pjsip driver — vanilla SIP, no custom modules. If you're running Asterisk directly without a GUI, this guide gives you the bare config you need.

Most direct-Asterisk users come to DIDHub for embedded telephony in software products (a SaaS that needs to make/receive calls), for AI voice agent infrastructure built on Asterisk + LLM stacks, or for in-house contact-center builds where a GUI like FreePBX would be more constraining than helpful.

Setup — 15 minutes

chan_pjsip-based config. Five steps from a fresh Asterisk install to a working DIDHub trunk.

Verify chan_pjsip is loaded

module show like pjsip — should list res_pjsip, chan_pjsip, res_pjsip_session loaded.

Edit pjsip.conf

Add transport, endpoint, aor, auth, identify, registration sections (see config below).

Edit extensions.conf

Add a context that matches inbound DID and an outbound dialplan that uses the DIDHub endpoint.

Reload pjsip + dialplan

asterisk -rx 'pjsip reload' and 'dialplan reload'. Check 'pjsip show registrations' for OK status.

Test inbound + outbound

Call into the DID; have the dialplan exec to a Playback or to a SIP/extension. Place an outbound through the DIDHub endpoint.

SIP trunk configuration

The exact trunk values DIDHub provisions for your account. Pre-fill these in the Asterisk trunk-config UI:

; pjsip.conf — DIDHub trunk endpoint

[transport-tls]
type=transport
protocol=tls
bind=0.0.0.0:5061
cert_file=/etc/asterisk/keys/your-cert.pem
priv_key_file=/etc/asterisk/keys/your-key.pem

[didhub]
type=endpoint
transport=transport-tls
context=from-didhub
disallow=all
allow=ulaw,alaw,opus
outbound_auth=didhub-auth
aors=didhub
from_user="didhub_xxxxxx"
from_domain=sip.didhub.io
media_encryption=sdes
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
direct_media=no

[didhub-auth]
type=auth
auth_type=userpass
username="didhub_xxxxxx"
password="(provisioned)"

[didhub]
type=aor
contact=sip:sip.didhub.io:5061;transport=tls

[didhub-reg]
type=registration
transport=transport-tls
outbound_auth=didhub-auth
server_uri=sip:sip.didhub.io:5061
client_uri=sip:[email protected]:5061

[identify-didhub]
type=identify
endpoint=didhub
match=sip.didhub.io

; extensions.conf

[from-didhub]
exten => _X.,1,NoOp(Inbound DID: ${EXTEN})
exten => _X.,n,Dial(PJSIP/100,30)
exten => _X.,n,Hangup()

[from-internal]
exten => _NXXXXXXXXX,1,Dial(PJSIP/${EXTEN}@didhub,60)
exten => _NXXXXXXXXX,n,Hangup()

The pjsip endpoint uses outbound auth tied to your DIDHub-provisioned credentials. Replace didhub_xxxxxx with the username DIDHub provisions (visible in your DIDHub dashboard under Trunks). For TLS, you'll need a cert/key pair — DIDHub accepts standard public CAs.

Capabilities verified with Asterisk

Vanilla chan_pjsip

No custom modules, no patches. Pure standards-compliant SIP.

TLS + SRTP

Encrypted signaling and media via standard pjsip transport-tls + media_encryption=sdes.

Asterisk 18+, 20, 21

All currently-supported Asterisk LTS lines work.

AMI / ARI events

Asterisk Manager Interface and Asterisk REST Interface emit standard events for DIDHub trunks — wire to your monitoring.

AGI / Stasis

AGI scripts and Stasis applications work normally for advanced dialplan logic.

STIR/SHAKEN headers

DIDHub injects SHAKEN identity headers on US outbound; Asterisk's AddHeader can be used for compliance customization.

Frequently asked questions

Which Asterisk version?

Asterisk 18 LTS, 20 LTS, or 21+. chan_pjsip is the only supported driver. chan_sip is removed in 21.

Can I use chan_sip with DIDHub?

Technically yes for older Asterisk, but strongly discouraged. chan_sip lacks modern NAT handling, SRTP via DTLS, and is removed from Asterisk 21.

Do I need a public IP?

No. DIDHub handles NAT-traversal via standard SIP rport / Symmetric RTP. Asterisk behind NAT works fine — just set rtp_symmetric=yes, force_rport=yes, rewrite_contact=yes on the endpoint.

How do I handle multiple country trunks?

Multiple endpoint sections in pjsip.conf, one per country. Each has its own auth + aor + registration. The dialplan picks which endpoint to dial out via.

Does DIDHub work with PJSIP-based VoIP frameworks (FastAGI, asterisk-Java)?

Yes. DIDHub speaks standard RFC SIP; any framework that integrates with chan_pjsip works.

Related

FreePBX · FusionPBX · 3CX · Softphones

Ready to get a number?

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