A SIP trunk connects your self-hosted PBX to the public telephone network, letting you make and receive real phone calls rather than only internal extension-to-extension calling.
What a SIP Trunk Provides
SIP trunking replaces traditional physical phone lines with a VoIP connection to a provider that bridges calls to and from the standard telephone network — your PBX connects to the provider's SIP servers over the internet.
Step 1 — Choose a SIP Trunk Provider
Several commercial SIP trunk providers exist — compare pricing (per-minute vs flat rate), supported codecs, and geographic coverage for the phone numbers/regions you need.
Step 2 — Obtain Trunk Credentials
Your provider issues connection details: a SIP server address, username/password (or IP-based authentication), and your assigned phone number(s).
Step 3 — Configure the Trunk in FreePBX
Under Connectivity → Trunks, add a new SIP trunk, entering your provider's connection details:
Trunk Name: my-sip-provider
Hostname: sip.provider.com
Username: your-username
Secret: your-password
Step 3 (Alternative) — Configure the Trunk in Raw Asterisk (pjsip.conf)
[my-trunk]
type=endpoint
transport=transport-udp
context=from-trunk
disallow=all
allow=ulaw
allow=alaw
outbound_auth=my-trunk-auth
aors=my-trunk-aor
[my-trunk-auth]
type=auth
auth_type=userpass
username=your-username
password=your-password
[my-trunk-aor]
type=aor
contact=sip:sip.provider.com
Step 4 — Configure Outbound Routes
Define rules determining which trunk handles outbound calls based on the dialed number pattern — important if using multiple trunks for cost optimization or redundancy.
Step 5 — Configure Inbound Routes
Map incoming calls on your trunk's phone number(s) to a specific extension, ring group, or IVR menu within your PBX.
Step 6 — Test Outbound Calling
Place a test call to an external number and verify audio quality in both directions.
Step 7 — Test Inbound Calling
Call your trunk's phone number from an external line and verify it correctly routes to the configured destination within your PBX.
Understanding Codec Negotiation
See Understanding VoIP Codecs and Bandwidth Requirements — ensure your PBX and trunk provider support compatible codecs, since a mismatch prevents calls from connecting or causes quality issues.
Registering Multiple Trunks for Redundancy
For business-critical phone systems, consider configuring multiple SIP trunks (from different providers) with failover routing, so a single provider outage doesn't take down your entire phone system.
Common Errors
Outbound calls fail with a "no route" error — verify your outbound route's dial pattern correctly matches the number format you're actually dialing (with or without a leading digit, country code format, etc.).
Registration fails with the trunk provider — verify credentials are exactly correct, and check whether your provider requires IP-based authentication instead of username/password, which is configured differently.
Continue Reading
- Understanding VoIP Codecs and Bandwidth Requirements
- How to Troubleshoot Common VoIP Quality Issues (Jitter, Latency, Packet Loss)
- How to Set Up SRTP and TLS Encryption for Secure VoIP
Browse more articles in VoIP & Communication Servers.