Need Help Adding Additional DIDs to Existing SIP Trunk (Expanded from 30 to 60 Channels)

Hi everyone,

I’ve been running an Asterisk setup using PJSIP for a while now. It’s been working fine with a SIP trunk that currently has around 30 channels and 200 caller IDs inbound and outbound both are stable.

Recently, my provider added another 30 channels and around 200 more caller IDs, so now I have about 60 channels and 400 DIDs in total.

I’m trying to figure out the right way to add these new DIDs into my existing setup without breaking what’s already working.

Note: All IPs, Caller IDs, and passwords below are masked for security. This is just a reference version of the configuration.

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

[transport-ws]
type=transport
protocol=ws
bind=0.0.0.0:8088

[transport-wss]
type=transport
protocol=wss
bind=0.0.0.0:8089
cert_file=/etc/asterisk/keys/asterisk.pem
priv_key_file=/etc/asterisk/keys/asterisk.key
method=tlsv1_2

[mytrunk-identify]
type=identify
endpoint=mytrunk-endpoint
match=10.X.X.X/24

[mytrunk-registration]
type=registration
outbound_proxy=sip:10.X.X.X:5060
server_uri=sip:trunkXXXX@example.sip.provider
client_uri=sip:trunkXXXX@example.sip.provider
retry_interval=30

[mytrunk-endpoint]
type = endpoint
context = inbound
transport=transport-udp
disallow = all
allow = ulaw,alaw
aors = mytrunk-aors
direct_media=no
outbound_proxy=sip:10.X.X.X:5060
force_rport=yes
rtp_symmetric=yes
rewrite_contact=yes
dtmf_mode=auto
qualify=yes
qualify_frequency=30

[mytrunk-aors]
type = aor
contact = sip:trunkXXXX@example.sip.provider
max_contacts=1
remove_existing = yes

[065XXXXX]
type=endpoint
context=vozcare
transport=transport-ws
allow=ulaw
webrtc=yes
auth=auth065XXXXX
aors=065XXXXX
direct_media=no
rtp_symmetric=yes
rewrite_contact=yes
force_rport=yes
rtptimeout=30
rtpholdtimeout=60
rtp_keepalive=15

[auth065XXXXX]
type=auth
auth_type=userpass
password=XXXX
username=065XXXXX

What I’m trying to figure out:

  1. For the new DID range and additional 30 channels — should I create a new endpoint/identify section, or just extend everything in the same trunk and handle it in extensions.conf?

  2. Any best practices for handling 400+ DIDs efficiently in PJSIP?

  3. Since I’m using PostgreSQL RealTime (ARA), is there an ideal structure to store or manage large DID pools?

  • Asterisk version: 20.x

  • Database: PostgreSQL RealTime (ARA)

  • Using WebRTC + UDP endpoints

  • Provider: Enterprise SIP trunk

Goal:

I want to integrate all the new DIDs smoothly without affecting the current inbound/outbound call flow or registration stability.

Also, if anyone can share relevant documentation, example configurations, or even community projects/tutorials that explain how large-scale DID setups are usually handled in Asterisk, I’d really appreciate it

Thanks a lot for your time and guidance!
MJ

“channels” aren’t a concept in SIP. They’re a billing or policy thing. To that end for channels you do nothing. For DIDs you adjust extensions.conf to route them how you wish.

There is nothing special about that number of DIDs, or anything specific. You just… configure Asterisk to route them how you want.

Most people find this will break their proxy. Does your proxy really understand the deprecated strict routing framework.

This doesn’t make sense, and there is a slight risk that it might be implemented in a way that allows an attacker to go man-in-the middle for your outgoing calls (I don’t know whether explicit contacts get priority over registered ones).

Thanks a lot, sir that makes sense about the channels not being a SIP concept.

I wanted to share my current extensions.conf setup so you (or anyone else) could suggest the best way to integrate the new DID range cleanly without breaking what’s working.

I currently have one SIP trunk (mytrunk-endpoint) registered and working perfectly for the first DID range 0651615XXX.
Recently, my provider added another range 0659952XXX under the same trunk.

[inbound]
exten => _XXXXXX.,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(file_name=vozcare_INCOMING-${CALLERID(num)}-${EPOCH})
same => n,Set(CDR(accountcode)=${file_name})
same => n,MixMonitor(${file_name}.wav)
same => n,Set(dest_endpoint=PJSIP/${EXTEN})
same => n,Set(dest_state=${DEVICE_STATE(${dest_endpoint})})
same => n,GotoIf($[“${dest_state}”!=“INUSE”&“${dest_state}”!=“UNAVAILABLE”&“${dest_state}”!=“RINGING”]?dial:busy)
same => n(busy),Queue(${EXTEN},r,30)
same => n,Hangup()
same => n(dial),Dial(${dest_endpoint},30)
same => n,Hangup()

I was thinking of adding something like:
exten => _0651615XXX,1,Goto(inbound,${EXTEN},1)
exten => _0659952XXX,1,Goto(inbound,${EXTEN},1)

Or maybe it’s better to handle this dynamically using func_odbc with PostgreSQL (since I already use RealTime ARA)?

My goal is just to make sure both ranges (old and new) continue to route properly and can scale easily if more DIDs get added later.

Any guidance or examples from others running large DID pools in PJSIP would be super helpful
MJ

Better is relative to your own goals, knowledge, and how you want to manage things. You’re not going to find guidance or examples covering that. Adding simple lines to dialplan is one approach.

Got it, sir that makes perfect sense.
I think I’ll start with the simple dialplan approach for now since it’s stable and easy to verify.