Friday, February 20, 2026

Configuring BSNL SIP Trunk (SIP PRI) on Asterisk with OpenVPN | A Complete PJSIP Guide (2026 Edition)

 


A practical, production-ready guide to configuring BSNL SIP PRI (IMS SIP Trunk) on modern Asterisk (PJSIP) with OpenVPN. Covers authentication, routing, user_eq_phone, scoring logic, debugging, and real-world carrier behavior.

BSNL now delivers SIP PRI over FTTH fiber using IMS-based SIP signaling routed through VPN (OpenVPN or SoftEther).

Key realities:

  • SIP Proxy is reachable only via VPN
  • SIP authentication may use:
  • IMS expects proper user=phone format
  • RTP may traverse different subnets

If your PBX doesn’t support OpenVPN natively, you must deploy a router or gateway device that does.

Article content

🛠 Step 1 – Configure OpenVPN

BSNL provides:

VPN Server Primary IP
VPN Server Secondary IP
Virtual IP (Client)
Gateway
Mask 

After connecting:

ip addr show tun0
ip route
ping 10.x.x.x  # SIP Proxy 

Ensure:

  • VPN interface is UP
  • Route to SIP proxy goes through VPN
  • SIP proxy is reachable


🧩 Step 2 – Configure BSNL SIP Trunk (PJSIP – NOT chan_sip)

Modern Asterisk uses PJSIP, not sip.conf.

Below is a production-ready configuration.


🔐 AUTH Section

[bsnl_auth]
type=auth
auth_type=userpass
username=+91XXXXXXXXXX
password=yourpassword 

📍 AOR Section

If REGISTER trunk:

[bsnl_aor]
type=aor
max_contacts=1
qualify_frequency=30 

If IP-auth trunk:

contact=sip:10.19.15.1:5060 

☎ Endpoint Section (CRITICAL)

[bsnl_endpoint]
type=endpoint
transport=transport-udp
context=from-trunk
disallow=all
allow=ulaw,alaw
auth=bsnl_auth
aors=bsnl_aor
from_user=+91XXXXXXXXXX
from_domain=upe.stbi.ims.bsnl.in
outbound_proxy=sip:10.19.15.1:5060;lr
user_eq_phone=yes
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
dtmf_mode=rfc4733
timers=yes 

🔎 Why user_eq_phone=yes Is Mandatory for India/BSNL

IMS expects:

sip:+91XXXXXXXXXX@domain;user=phone 

Without user_eq_phone=yes, calls may fail even if registration succeeds.


🔁 Registration Block (If Required)

[reg_bsnl]
type=registration
outbound_auth=bsnl_auth
server_uri=sip:upe.stbi.ims.bsnl.in
client_uri=sip:+91XXXXXXXXXX@upe.stbi.ims.bsnl.in
contact_user=+91XXXXXXXXXX
retry_interval=60
expiration=120 

📞 Dialplan Configuration

Inbound

[from-trunk]
exten => +91XXXXXXXXXX,1,NoOp(Incoming BSNL Call)
 same => n,Dial(PJSIP/1001) 

Outbound

[outbound]
exten => _9.,1,NoOp(Outgoing via BSNL)
 same => n,Dial(PJSIP/${EXTEN:1}@bsnl_endpoint) 

🎵 Codec & Media Recommendations

✔ Use only:

ulaw
alaw 

✔ DTMF:

rfc4733 

Avoid transcoding unless absolutely required.


🔍 Debugging & Troubleshooting

Enable SIP debugging:

asterisk -rvvv
pjsip set logger on
pjsip show registrations
pjsip show endpoint bsnl_endpoint
pjsip show contacts 

Network-level debugging:

tcpdump -i tun0 port 5060 

📊 Carrier-Grade Monitoring Best Practice

In production systems:

  • Don’t rely only on REGISTER
  • Score trunk health using:
  • Avoid marking trunk DOWN on single failure
  • Use grace period logic

This avoids false negatives in telecom environments.


⚠ Common BSNL SIP Issues

ProblemCauseRegistered but no outgoing callsMissing user_eq_phone=yes403 ForbiddenWrong From headerNo audioRTP routing via wrong interfaceFlapping trunkVPN route instabilityWorks after reload onlyIncorrect AOR / section ID mismatch


🧠 Final Thoughts

BSNL SIP PRI is not “just another SIP trunk.” It behaves like IMS telecom infrastructure.

To deploy it correctly:

  • Understand VPN routing
  • Use proper PJSIP sections
  • Align endpoint IDs correctly
  • Format Indian numbers properly
  • Monitor with carrier-grade logic

When configured properly, it is extremely stable.


If you're building multi-tenant PBX systems, telecom billing engines, or AI-driven calling platforms, mastering IMS-style SIP trunks is essential.

Happy Building 🚀

SIP Trunk Registered but No Calls?


 

The Hidden Asterisk + PJSIP + IMS Trap (BSNL Case Study)

Why a perfectly registered SIP trunk can still make ZERO calls — and how to fix it


Most SIP engineers panic when they see this:

REGISTER → 401 → 200 OK
Status: Registered

…and then nothing happens.

No outbound calls. No INVITE. No SIP logs. No errors.

I recently debugged a BSNL IMS SIP trunk on Asterisk 20 (PJSIP) that worked flawlessly on another PBX — yet refused to place calls here.

👉 Credentials were correct 👉 Registration was successful 👉 Network & NAT were fine

Still: no calls left the system

This article explains why this happens, how to diagnose it, and how to fix it permanently.


🔍 The Illusion of “Trunk Working”

In Asterisk, registration success does NOT mean call routing success.

You can have:

✅ pjsip show registrations → Registered ❌ Zero outbound SIP traffic

Because registration ≠ dialing.


🧠 The Real Root Cause (90% of Such Issues)

Your dialplan never dials the trunk

In modern PBX architectures (especially API-driven ones), outbound calls often flow like this:

Extension
 → Outbound policy
   → Stasis (Node.js / API)
     → (nothing originates a trunk call)

So Asterisk happily waits… while the trunk sits idle.

No INVITE is ever generated.


🚫 The Silent Killer: Stasis Without Originate

In my case, the outbound dialplan ended with:

Stasis(clixxo,outbound,${ORIG_EXTEN},${DIALED_NUM})
Hangup()

That looks “advanced” but unless your Stasis app explicitly originates a call, the trunk will never be used.

This is why:

  • pjsip logger shows nothing
  • Provider sees no traffic
  • Engineers blame SIP credentials 😅


✅ Two Correct Ways to Fix It

Option 1 — Classic Asterisk Dialplan (Fastest Fix)

If you want Asterisk to control calls:

Dial(PJSIP/${DIALED_NUM}@tr_BSNL,60)

This immediately generates:

INVITE sip:number@proxy

Perfect for stable production PBXs.


Option 2 — API-Controlled PBX (Modern Architecture)

If you’re using Node.js / Stasis / ARI, then your app must originate the call:

ari.channels.originate({
  endpoint: `PJSIP/${number}@tr_BSNL`,
  callerId: '911202210100',
  app: 'pbx'
});

Without this, registration is meaningless.


📡 BSNL IMS-Specific Lessons (Very Important)

BSNL (and most IMS providers) are strict:

❌ Public DNS won’t resolve IMS domains

*.ims.bsnl.in often requires:

  • Private DNS
  • VPN DNS
  • Or direct proxy IP

❌ +91 breaks many IMS trunks

Use:

911202210100

NOT:

+911202210100

❌ Realm in trunk auth

IMS trunks usually do NOT want a local PBX realm


🔥 Golden Rule of SIP Debugging

If auth works on another PBX but not on yours, 90% of the time it’s NOT credentials it’s headers or dialplan flow.

Compare:

  • REGISTER headers
  • INVITE headers
  • From / Contact / Request-URI

Byte-for-byte.


🎯 Key Takeaways for PBX Architects

  • Registration ≠ routing
  • Stasis ≠ magic
  • No Dial() or originate → no call
  • IMS trunks are unforgiving
  • Asterisk does exactly what you tell it nothing more


🚀 Why This Matters

Modern PBXs are no longer just dialplans. They’re distributed telecom systems with:

  • APIs
  • Web dashboards
  • Policy engines
  • Real-time analytics

If you don’t understand where SIP actually leaves the box, you’ll lose days debugging ghosts.


💬 Final Thought

If you’re building:

  • Multi-tenant PBX platforms
  • IMS-based SIP integrations
  • Node.js + Asterisk systems

👉 Design outbound call flow explicitly don’t assume it.

Stuck on your project? Get expert guidance for under $10. Let's talk.

Name

Email *

Message *

The Future of GenAI, Cybersecurity, and VoIP: What You Need to Know

I Delivered the Automation. The Final Test Changed Everything

  Freelance engineering projects rarely fail because of code alone. Sometimes the architecture works. The deployment works. The integrations...