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.
π Step 1 β Configure OpenVPN
BSNL provides:
VPN Server Primary IP
VPN Server Secondary IP
Virtual IP (Client)
Gateway
MaskAfter connecting:
ip addr show tun0
ip route
ping 10.x.x.x # SIP ProxyEnsure:
- 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=30If 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=phoneWithout 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:
rfc4733Avoid 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 contactsNetwork-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 π
If you're exploring similar solutions or want to implement this in your business, Iβm open to a quick discussion. Letβs evaluate your use case and identify the most efficient approach to get results.