FreePBX SIP Trunk Setup: Complete Configuration Guide | NetviaVoice

๐Ÿ”ง FreePBX SIP Trunk Setup: Complete Configuration Guide

Summary: This comprehensive guide walks you through configuring a SIP trunk in FreePBX โ€“ from choosing the right SIP driver (PJSIP vs chan_sip) to setting up registration, inbound/outbound routing, and troubleshooting common issues. Whether you're connecting to a major provider or a custom SIP carrier, this step-by-step tutorial ensures a smooth setup for your business phone system.

๐Ÿ” Understanding FreePBX SIP Trunks

A SIP trunk in FreePBX is a virtual connection that links your PBX to external networks, such as a telephone service provider or another PBX system[reference:0]. It allows you to make and receive calls over the internet using the Session Initiation Protocol (SIP). FreePBX supports two primary SIP channel drivers: chan_sip (the legacy driver) and chan_pjsip (the modern, recommended driver)[reference:1].

๐Ÿ”น What a SIP Trunk Does

  • Outbound Calling: Routes internal extension calls to external phone numbers via your provider.
  • Inbound Calling: Receives external calls and routes them to extensions, ring groups, or IVRs.
  • DID Support: Handles multiple Direct Inward Dialing (DID) numbers on a single trunk.
  • Cost Savings: Replaces traditional PRI or analog lines with affordable VoIP connectivity.

๐Ÿ”น When to Use a SIP Trunk

  • You need to connect your FreePBX to an external VoIP provider.
  • You want to eliminate traditional phone lines and reduce costs.
  • You require scalability โ€“ add or remove channels as your business grows.
  • You need advanced features like failover routing and multiple DIDs.

โš–๏ธ PJSIP vs chan_sip: Which Driver to Use?

FreePBX offers two SIP channel drivers. Here's how they compare:

FeaturePJSIP (chan_pjsip)chan_sip (Legacy)
StatusModern, actively developedLegacy, being phased out
PerformanceBetter performance, lower latency[reference:2]Good but less efficient
NAT HandlingEnhanced NAT traversal[reference:3]Requires more configuration
Multiple RegistrationsImproved support[reference:4]Limited
ConfigurationMore intuitive GUIRequires manual peer/user details
Recommendationโœ… Recommended for all new setups[reference:5]Only for legacy compatibility

๐Ÿ’ก Recommendation: For all new FreePBX installations, use PJSIP (chan_pjsip). It offers better performance, security, and future-proofing. The legacy chan_sip driver is still available but is gradually being deprecated[reference:6].

๐Ÿ“‹ Prerequisites & Preparation

Before you begin, ensure you have the following:

โœ… System Requirements

  • FreePBX installed and running (version 15 or higher recommended)
  • Administrative access to the FreePBX web console[reference:7]
  • A SIP trunk account from a provider (e.g., NetviaVoice, Telnyx, Twilio)
  • Provider credentials: SIP server, username, password (or IP whitelist)
  • At least one DID (Direct Inward Dialing) number assigned

๐Ÿ” Network & Firewall

  • SIP Port: UDP/TCP 5060 (default) โ€“ ensure open[reference:8]
  • RTP Ports: 10000-20000 or 20000-27999 (configurable)[reference:9]
  • SIP ALG: Disable SIP ALG on your router if present[reference:10]
  • NAT: Enable Consistent NAT if behind NAT[reference:11]
  • Firewall: FreePBX firewall auto-discovers trunks[reference:12]

โš ๏ธ Important: If your router has a SIP ALG (Application Layer Gateway) option, it is almost always better to TURN IT OFF. SIP ALG often causes more problems than it solves[reference:13].

๐Ÿ“ Step-by-Step SIP Trunk Configuration

Follow these steps to add a SIP trunk to your FreePBX system using the recommended PJSIP driver[reference:14][reference:15]:

  • 1 Log in to FreePBX Admin โ€“ Open your FreePBX web interface and log in with administrator credentials[reference:16].
  • 2 Navigate to Trunks โ€“ Go to Connectivity โ†’ Trunks from the top menu[reference:17].
  • 3 Add a New Trunk โ€“ Click Add Trunk and select Add SIP (chan_pjsip) Trunk[reference:18][reference:19].
  • 4 General Settings โ€“ On the General tab:
    • Trunk Name: Enter a descriptive name (e.g., "NetviaVoice-Primary")[reference:20].
    • Outbound Caller ID: Set your business caller ID number[reference:21].
    • Maximum Channels: Leave blank for unlimited (or set a limit)[reference:22].
  • 5 PJSIP Settings โ€“ On the pjsip Settings tab:
    • Username: Your SIP provider username[reference:23].
    • Secret: Your SIP provider password[reference:24].
    • SIP Server: Your provider's SIP domain or IP address[reference:25].
    • Context: Set to from-internal for internal-origin calls[reference:26].
    • Authentication: Set to "Outbound"[reference:27].
    • Registration: Set to "Send" to enable registration[reference:28].
    • Port: Default is 5060[reference:29].
  • 6 Codecs โ€“ Scroll down and allow ulaw and alaw codecs (at minimum)[reference:30].
  • 7 Submit & Apply โ€“ Click Submit, then Apply Config to save changes[reference:31].

๐Ÿ’ก IP-Based Trunks: If your provider uses IP-based authentication (whitelisting), set Registration to "None" and ensure your public IP is whitelisted[reference:32].

๐Ÿ“ž Configuring Inbound Routes

Inbound routes tell FreePBX what to do when a call comes in on your DID number[reference:33]:

  • 1 Go to Connectivity โ†’ Inbound Routes[reference:34].
  • 2 Click Add Inbound Route[reference:35].
  • 3 Under General:
    • Description: A descriptive name (e.g., "Main Line")[reference:36].
    • DID Number: Your 10-digit incoming number[reference:37].
    • Set Destination: Choose where to route calls โ€“ extension, ring group, IVR, or queue[reference:38].
  • 4 Click Submit, then Apply Config[reference:39].

โš ๏ธ Note: If your DID is set to "Server" in your provider's portal, create the inbound route using the DID in E.164 format (e.g., 12125551234)[reference:40]. If set to "Device", use the SIP endpoint username[reference:41].

๐Ÿ“ค Configuring Outbound Routes

Outbound routes define how calls from extensions are routed to the outside world via your SIP trunk[reference:42]:

  • 1 Go to Connectivity โ†’ Outbound Routes[reference:43].
  • 2 Click Add Outbound Route[reference:44].
  • 3 Under Route Settings:
    • Route Name: A descriptive name (e.g., "Default Route")[reference:45].
    • CID: Your outbound caller ID (must match a number on the trunk)[reference:46].
  • 4 Trunk Sequence: Select your newly created trunk[reference:47].
  • 5 Dial Patterns: Add patterns for numbers to route:
    • 1NXXNXXXXXX โ€“ US 10-digit numbers[reference:48]
    • NXXNXXXXXX โ€“ 7-digit local numbers[reference:49]
    • [3-9]11 โ€“ Emergency/services (911, 411)[reference:50]
    • 011. โ€“ International calls (optional)[reference:51]
  • 6 Click Submit, then Apply Config[reference:52].

๐Ÿงช Testing Your SIP Trunk

After configuration, test your trunk to ensure everything works[reference:53]:

๐Ÿ“ž Inbound Test

  • Dial your DID number from an external phone (mobile or landline).
  • Check if the call reaches the destination you set in the inbound route.
  • Verify caller ID display and audio quality.

๐Ÿ“ค Outbound Test

  • Dial an external number from any extension.
  • Confirm the call connects and audio works both ways.
  • Check that the correct outbound route is applied.

๐Ÿ’ก Pro Tip: Check Reports โ†’ Asterisk Log or /var/log/asterisk/full for detailed call logs and error messages if something isn't working.

๐Ÿš€ Need Expert Help with FreePBX? NetviaVoice Can Assist

Our VoIP specialists can help you configure SIP trunks, optimize your FreePBX system, and troubleshoot any issues โ€“ ensuring a reliable and cost-effective phone system.

๐Ÿ“ž +1 201 979 3825
๐Ÿ’ฌ WhatsApp US
๐Ÿ“ž +92 333 5908806 (Global)
๐ŸŒ Our Services
Visit NetviaVoice

๐Ÿ”ง Common Issues & Troubleshooting

IssuePossible CauseSolution
Trunk not registeringIncorrect username/password, wrong SIP server, firewall blocking port 5060Double-check credentials. Verify SIP server domain. Ensure port 5060 is open[reference:54].
Inbound calls not workingDID not configured correctly, inbound route missing or misconfiguredVerify DID number in trunk and inbound route. Check provider's DID routing[reference:55].
Outbound calls failDial pattern mismatch, outbound route not assigned to trunkReview dial patterns. Ensure trunk is selected in the outbound route[reference:56].
Audio issues (one-way or no audio)Firewall blocking RTP ports, NAT issuesOpen RTP ports (10000-20000). Configure NAT settings in Asterisk SIP Settings[reference:57].
Registration failed โ€“ authentication errorIncorrect secret or username formatVerify the username and secret exactly as provided by your carrier[reference:58].

๐Ÿ’ก Quick Troubleshooting: Always check the Asterisk Log (Reports โ†’ Asterisk Log or /var/log/asterisk/full) for detailed error messages โ€“ this is the best place to start diagnosing issues.

๐Ÿ† Best Practices for FreePBX SIP Trunks

๐Ÿ”น Security

  • Use TLS/SIPS for encrypted SIP signaling.
  • Enable SRTP for encrypted media.
  • Set strong passwords for SIP credentials.
  • Disable SIP ALG on your router[reference:59].
  • Use failover trunks for redundancy.

๐Ÿ”น Performance

  • Use PJSIP driver for better performance[reference:60].
  • Configure codec preferences (ulaw/alaw first).
  • Set appropriate RTP port ranges in Asterisk SIP Settings.
  • Monitor call quality and adjust as needed.

๐Ÿ”น Maintenance

  • Keep FreePBX modules updated.
  • Regularly test failover trunks (if configured).
  • Review CDR (Call Detail Records) for billing and analysis.
  • Document trunk configuration for future reference.

๐Ÿ”น Network

  • Use a static public IP or reliable DDNS for IP-based trunks.
  • Configure QoS to prioritize SIP/RTP traffic.
  • Ensure sufficient bandwidth for concurrent calls.
  • Consider VPN for secure inter-site trunking.

โ“ Frequently Asked Questions

1. What is the difference between PJSIP and chan_sip in FreePBX?

PJSIP is the modern SIP channel driver in FreePBX, offering better performance, enhanced NAT handling, and improved support for multiple registrations. chan_sip is the older driver, still supported but gradually being phased out. PJSIP is recommended for all new FreePBX installations[reference:61].

2. How do I add a SIP trunk in FreePBX?

Log in to FreePBX Admin, go to Connectivity > Trunks, click Add Trunk, and select Add SIP (chan_pjsip) Trunk. Enter the trunk name, username, password, SIP server, and configure authentication settings. Then create inbound and outbound routes to complete the setup[reference:62][reference:63].

3. What SIP ports need to be open for FreePBX?

SIP signaling uses port 5060 (UDP/TCP) by default. RTP media ports typically range from 10000-20000 or 20000-27999 (configurable in Asterisk SIP Settings). Ensure these ports are open in your firewall for proper call flow[reference:64].

4. Why is my FreePBX SIP trunk not registering?

Common causes include incorrect username/password, wrong SIP server domain, firewall blocking port 5060, or NAT issues. Check the Asterisk log (/var/log/asterisk/full) for detailed error messages. Also verify that your provider's IP is whitelisted if using IP-based authentication[reference:65].

5. How do I configure inbound routes for my SIP trunk in FreePBX?

Go to Connectivity > Inbound Routes, click Add Inbound Route. Enter a description, set the DID Number (your incoming number), and choose a destination (extension, ring group, IVR, etc.). Save and apply configuration. Repeat for each DID number you have[reference:66].

๐Ÿ“ข Need help setting up your FreePBX SIP trunk? Let NetviaVoice guide you.

ยฉ 2025 NetviaVoice โ€” FreePBX Configuration Experts, SIP Trunking & Cloud Communications.

FreePBX is a registered trademark of Sangoma Technologies. NetviaVoice provides SIP trunk services and integration support for FreePBX and other PBX systems.