Setup guide · GUI / PJSIP
Connect a SIP trunk to FreePBX
FreePBX writes the PJSIP config for you. You create a chan_pjsip trunk in the GUI, add an outbound route that uses it, and an inbound route for each DID. Field names below match FreePBX 16 and 17.
Before you start
What you need
- FreePBX 16 or 17 with the PJSIP driver enabled (Settings › Asterisk SIP Settings)
- Your public IP and local networks entered in Asterisk SIP Settings › General
- Your SIPTrunkHub account details: SIP server, auth method, tech prefix if any
- Admin access to the FreePBX web interface
IP auth or register auth?
IP authentication
RecommendedSet Authentication to None and Registration to None. We whitelist your public IP. FreePBX matches our calls by the SIP server address.
Register (digest) authentication
Set Authentication to Outbound and Registration to Send, then fill in username and secret.
Step by step
Configure FreePBX
sip.example-host.net and 203.0.113.10 are documentation placeholders. Replace them, and the username, password and tech prefix, with the values from your account.
- 01
Check NAT settings
Go to Settings › Asterisk SIP Settings › General. Click Detect Network Settings, confirm the external address is your public IP and every private subnet is listed under Local Networks. Submit and apply.
- 02
Add the trunk
Connectivity › Trunks › Add Trunk › Add SIP (chan_pjsip) Trunk. On the General tab fill in the trunk name, outbound caller ID and maximum channels.
General tab (field → value) Trunk Name ............ SIPTrunkHub Outbound CallerID ..... 442079460000 CID Options ........... Allow Any CID Maximum Channels ...... 30 (your account limit) - 03
Fill in pjsip Settings
On pjsip Settings › General enter the server. For IP auth leave username and secret empty. On the Advanced sub-tab set From Domain and add our IP to Match (Permit).
pjsip Settings (field → value) Username .............. YOUR_SIP_USERNAME (register auth only) Secret ................ YOUR_SIP_PASSWORD (register auth only) Authentication ........ None | Outbound Registration .......... None | Send SIP Server ............ sip.example-host.net SIP Server Port ....... 5060 Context ............... from-pstn Transport ............. 0.0.0.0-udp Advanced: From Domain ........... sip.example-host.net Match (Permit) ........ 203.0.113.10 Qualify Frequency ..... 30 Send RPID/PAI ......... Send P-Asserted-Identity header - 04
Set codecs
On the Codecs sub-tab tick ulaw, alaw and g729 and drag them into that order. Untick everything else so negotiation stays predictable.
- 05
Create an outbound route
Connectivity › Outbound Routes › Add. Pick the trunk under Trunk Sequence, then add dial patterns that strip 00 and, if needed, prepend your tech prefix.
Dial patterns (prepend | prefix | match pattern) ( ) | 00 | X. international: 00 44 20... → 4420... (44) | 0 | NXXXXXXXXX UK national: 020... → 4420... (1234#) | 00 | X. same, with tech prefix 1234# - 06
Create inbound routes
Connectivity › Inbound Routes › Add. Enter the DID exactly as we deliver it (E.164 without +), then pick the destination. Submit and Apply Config.
Media
Codec order
- FreePBX offers codecs in the order shown on the trunk Codecs tab. Drag ulaw/alaw above g729.
- If a phone only supports g729 and the trunk sends alaw, Asterisk transcodes. That costs CPU on busy systems.
- For fax, create a separate trunk or inbound route with alaw only and T.38 enabled in Asterisk SIP Settings.
NAT notes
- External Address and Local Networks in Asterisk SIP Settings are required behind NAT. Re-run Detect after any IP change.
- Default RTP range is 10000–20000. Open it inbound in the FreePBX firewall and on your edge firewall.
- In the FreePBX Firewall module, add 203.0.113.10 to Trusted networks so responsive firewall does not block us.
- Disable SIP ALG on the router.
Verify
Test the trunk
Reports › Asterisk Info › Registries should show Registered (register auth). For IP auth, check the contact status from the CLI, then place a test call and watch the log.
fwconsole reload
asterisk -rx "pjsip show endpoint SIPTrunkHub"
asterisk -rx "pjsip set logger on"
tail -f /var/log/asterisk/fullTroubleshooting
Common SIP errors
What each response means and what to check first on FreePBX. If you still need help, send the Call-ID and timestamp to the NOC.
| Code | Meaning | Likely cause | Fix on FreePBX |
|---|---|---|---|
| 401 | Unauthorized | We challenged the INVITE or REGISTER and the credentials were wrong or missing. With IP auth it usually means the call arrived from an IP we have not whitelisted. | Authentication must be Outbound, not Both, and the secret must have no trailing spaces. |
| 403 | Forbidden | Authenticated, but not allowed: wrong or missing tech prefix, zero prepaid balance, destination blocked on your account, or an invalid caller ID. | Check CID Options. Our network rejects an empty or invalid caller ID. Set Outbound CallerID on the trunk. |
| 404 | Not Found | The dialled number is not in a format we can route: missing country code, an extra 00 or +, or a local trunk prefix left in. | Your dial pattern is not stripping 00. Check the prefix column of the outbound route. |
| 408 | Request Timeout | No response came back. Usually a firewall, wrong port or transport, a DNS failure, or SIP ALG on the router eating packets. | Confirm UDP/TCP 5060 is open outbound and to 203.0.113.10. Disable SIP ALG. Test with an OPTIONS ping. |
| 480 | Temporarily Unavailable | The far end could not be reached: handset off, out of coverage, or the route for that prefix is temporarily down. | Retry later or route to another trunk. If it hits one prefix repeatedly, send examples to the NOC. |
| 486 | Busy Here | The called party is busy, or you reached the concurrent-channel limit on your account. | Treat as a normal busy. If every call returns 486, check your active channel count against your limit. |
| 503 | Service Unavailable | Capacity limit hit (calls per second or channels), or every route for that destination failed. | Pace your dialer to the agreed CPS. Configure a second trunk for failover. Ask the NOC if it persists. |
Seeing one-way audio instead of an error? Read One-Way Audio on VoIP Calls.
FAQ
FreePBX questions
Should I use chan_sip or chan_pjsip?
chan_pjsip. chan_sip is deprecated and removed in Asterisk 21, which FreePBX 17 can run on.
Inbound calls hit “The number you have dialled is not in service”. Why?
No inbound route matches the DID. Check the exact DID format in the log and use it in the inbound route, or add a catch-all route.
Can I run two SIPTrunkHub trunks for failover?
Yes. Add the second trunk and list it under Trunk Sequence in the outbound route. FreePBX tries it when the first fails.
Popular destinations
SIP Trunk United States+1
SIP Trunk United Kingdom+44
SIP Trunk Germany+49
SIP Trunk United Arab Emirates+971
SIP Trunk Philippines+63
SIP Trunk Australia+61
Stuck on a step?