Failover Routing: Primary & Secondary Trunk Setup | NetViaVoice
📞 +1 201 979 3825  |  🇵🇰 +92 333 5908806  |  ✉️ support@netviavoice.com
Business Continuity Guide 2026

Failover Routing:
Primary & Secondary Trunk Setup

The complete 2026 guide to building bullet-proof SIP trunk failover — configure primary and secondary trunks in FreePBX and Asterisk so your business never drops a call, even when your main trunk fails.

0Dropped Calls with Failover
<5sAutomatic Failover Speed
99.9%Uptime with Dual Trunks
3 LayersFailover Depth Available
$0Failover Config Cost
📋 Article Summary

SIP trunk failover routing is the mechanism that automatically switches your outbound and inbound calls from a failing primary trunk to a healthy secondary trunk — without any manual intervention, without callers noticing, and without dropping calls in progress. For businesses that depend on telephone communications, a single SIP trunk is a single point of failure. A second trunk, configured as a failover, eliminates that risk entirely. This guide covers every aspect of failover routing: why you need it, how failover triggers work, how to configure primary and secondary trunks in FreePBX and Asterisk, how to handle both outbound and inbound failover scenarios, and how to test that your failover actually works before you need it. Read this once and your phone system becomes genuinely redundant.

1. Why Single-Trunk VoIP Is a Business Risk

When a business runs all of its telephone traffic through a single SIP trunk, that trunk is a single point of failure. If the trunk provider experiences an outage — even for 15 minutes — every inbound call reaches a fast busy signal and every outbound call attempt fails. For a sales team, a 15-minute outage during peak hours could mean dozens of lost leads. For a medical practice or emergency service, it could be significantly worse.

SIP trunk outages are more common than most businesses assume. Even well-established carriers experience scheduled maintenance windows, unexpected routing failures, DDoS attacks on signalling infrastructure, and regional internet disruptions that affect SIP service delivery. No carrier guarantees 100% uptime — the realistic SLA for a single SIP trunk provider is 99.9%, which translates to approximately 8.7 hours of potential downtime per year. For many businesses, that is an unacceptable level of risk.

The solution is failover routing — a second SIP trunk, configured to automatically receive calls when the primary trunk becomes unavailable. When properly implemented, the failover is transparent to callers and invisible to your team. From the outside, your business phone system appears to have 100% uptime. From the inside, the system has automatically switched providers and is operating normally on the secondary trunk. This same principle applies to inbound call routing design — read our full guide on Inbound Call Routing: Route Selection & Failover for the inbound-side perspective.

8.7 hrsDowntime/Year at 99.9% SLA
SingleTrunk = Single Point of Failure
DualTrunks = Near 100% Uptime
<5sAutomatic Failover Activation

Set Up Dual-Trunk Failover With NetViaVoice Today

NetViaVoice provides primary and secondary SIP trunks with automatic failover configuration — protecting your business communications with zero-downtime redundancy and same-day expert setup support.

2. How SIP Trunk Failover Works

SIP trunk failover is implemented at two levels: PBX-level failover (where your FreePBX or Asterisk system manages the switch between trunks) and carrier-level failover (where your SIP trunk provider re-routes calls at the network level before they even reach your PBX). Understanding both levels — and ideally implementing both — gives you the most comprehensive protection.

🔄 Failover Routing Decision Flow — Call Attempt
📞 Outbound Call InitiatedUser dials external number
🔗 Primary SIP Trunk AttemptedTrunk Sequence 0 — NetViaVoice PrimaryAttempt #1
↓ FAILS (503 / Timeout / Unreachable)
⚡ Automatic Failover TriggeredPBX detects failure, moves to next sequence
🔗 Secondary SIP Trunk AttemptedTrunk Sequence 1 — Backup ProviderAttempt #2
✅ Call Connects via Secondary TrunkCaller hears ringing — failover complete and transparent

At the PBX level, failover works through the trunk sequence ordering in your outbound route configuration. Your PBX attempts the primary trunk and if it receives a failure response (503 Service Unavailable, 408 Request Timeout, or no response within the timeout window), it automatically tries the next trunk in the sequence. This entire process typically completes within 3–8 seconds, depending on timeout configuration — fast enough that most callers experience only a brief pause before hearing a ring tone.

3. Failover Triggers: What Causes the Switch

Understanding what specifically causes a failover to activate helps you configure timeouts appropriately and diagnose failover behaviour. Different failure modes produce different SIP response codes, and not all of them trigger automatic failover by default:

Failure ConditionSIP ResponseDefault Failover?Failover SpeedAction Required
Trunk unregisteredN/A (no registration)✓ Immediate<1 secondNone — automatic
Provider unreachable408 Timeout✓ After timeout32 seconds*Reduce SIP timer T1
Service unavailable503✓ Immediate<1 secondNone — automatic
Not found404✓ Immediate<1 secondNone — automatic
All circuits busy486 / 600✗ No (by default)N/AEnable retry on 486
Authentication fail401 / 407✗ No — credential issueN/AFix credentials
Network congestion503 / 480✓ After timeout3–8 secondsNone — automatic

Important — The 408 Timeout Problem: By default, Asterisk waits up to 32 seconds for a 408 timeout before failing over. This is too long for most businesses. Reduce this by setting t1min=500 in sip.conf [general] or configuring timer_t1=500 on the PJSIP transport — cutting the failover time to under 3 seconds for unreachable trunk scenarios.

4. Types of Failover: Outbound vs Inbound vs Both

📤

Outbound Call Failover

When your primary trunk fails, outbound calls automatically route through the secondary trunk. Configured through trunk sequence ordering in outbound routes. Handled entirely at the PBX level.

📥

Inbound Call Failover

When your primary SIP trunk becomes unreachable, inbound calls must be redirected at the carrier level — before they reach your PBX. Requires a backup DID or carrier-level forwarding rule.

🌐

Carrier-Level Failover

Some SIP trunk providers (including NetViaVoice) offer network-level failover — automatically re-routing calls to a backup SIP endpoint if your primary PBX registration lapses.

🔌

Internet Connection Failover

If your internet fails entirely, both outbound and inbound SIP fail. Solution: configure a secondary internet connection (4G/LTE failover router) as a backup path for SIP traffic.

📱

PSTN Mobile Failover

Configure carrier-level DID forwarding to a mobile number as the ultimate last-resort failover. Works even when both internet connections fail — calls reach a mobile device unconditionally.

🏢

Geographic Redundancy

For enterprise deployments: primary and secondary trunks on different physical carrier infrastructures and geographic regions, eliminating shared failure modes between the two paths.

5. Choosing the Right Secondary Trunk Provider

Your secondary trunk should not be from the same provider as your primary trunk. If your primary provider has a network-wide outage, using the same provider for failover means both trunks fail simultaneously — completely defeating the purpose of redundancy. Choose a secondary provider with genuinely different infrastructure, different carrier interconnects, and ideally different geographic data centres.

Selection CriteriaRecommendationWhy It Matters
Different providerRequired — not same as primaryEliminates shared failure modes
Different network infrastructureTier-1 carrier interconnectsPrimary & secondary fail for different reasons
Cost per minuteSlightly higher is acceptableFailover is rarely used — premium cost is minimal
Compatible codecsMust support G.711 U-Law minimumCodec mismatch causes audio failure at failover
Inbound DID supportRequired for inbound failoverNeeds to deliver calls to your backup SIP endpoint
SIP registrationStandard SIP/credentialsMust integrate with FreePBX/Asterisk standard trunk config
Geographic diversityStrongly RecommendedEliminates regional internet outage risk

6. Configuring Outbound Failover in FreePBX

FreePBX handles outbound failover through the Trunk Sequence on each outbound route. You add multiple trunks in priority order — FreePBX tries Trunk 0 first, and if it fails, automatically tries Trunk 1, then Trunk 2, and so on. Here is the complete setup:

1

Set Up Both Trunks in FreePBX

Go to Connectivity → Trunks. Create your primary trunk (e.g., NetViaVoice-Primary) with your primary SIP credentials. Create your secondary trunk (e.g., BackupProvider-Secondary) with the failover provider's credentials. Verify both show as registered in the Asterisk Info panel before proceeding.

2

Open Your Outbound Route

Navigate to Connectivity → Outbound Routes. Open the outbound route you want to add failover to (e.g., your US local calls route). Go to the Trunk Sequence tab.

3

Add Both Trunks in Priority Order

From the dropdown at Sequence 0, select your primary trunk. Click the + button to add a second sequence slot. Select your secondary trunk at Sequence 1. Sequence 0 is always tried first — Sequence 1 only activates if Sequence 0 fails.

4

Enable Retry on 486 (Optional but Recommended)

In the primary trunk's settings (Connectivity → Trunks → [Primary] → Advanced Settings), look for "Retry on 486" and set it to YES. This causes FreePBX to fail over even when the carrier returns a "busy" signal, preventing calls from being dropped unnecessarily.

5

Apply Config and Test

Click Submit → Apply Config. Make a test outbound call. Then temporarily disable your primary trunk (Connectivity → Trunks → [Primary] → Toggle to Disabled) and make another test call — it should complete successfully via the secondary trunk. Re-enable the primary after testing. For outbound routing dial patterns, see: FreePBX Outbound Routes Guide.

7. Configuring Inbound Failover in FreePBX

Inbound failover is fundamentally different from outbound failover because inbound calls arrive at your PBX — they cannot be re-routed at the PBX level if the PBX is unreachable. True inbound failover requires carrier-level configuration plus a secondary DID or forwarding rule. Here is a layered approach to inbound failover:

📥 Three-Layer Inbound Failover Strategy

  • Layer 1 — Primary DID on Primary Trunk: Normal operation. All inbound calls arrive on your main DID via your primary SIP trunk and are routed by FreePBX normally.
  • Layer 2 — Secondary DID on Secondary Trunk: Register a second DID on your failover provider. Both DIDs point to the same destination in FreePBX. Publish your secondary DID to key contacts as a backup. If primary fails, these contacts can reach you on the secondary number.
  • Layer 3 — Carrier-Level Forwarding (Emergency): Configure in your NetViaVoice portal: if your SIP registration lapses for 60+ seconds, forward all inbound calls on your primary DID to either (a) your secondary SIP trunk endpoint, or (b) a mobile phone number. This activates even if your PBX and internet are both down.

Best Practice: Configure carrier-level failover as a standard part of every DID setup — not as an emergency measure. In your NetViaVoice portal, set a backup forwarding number for every DID. This adds zero cost and zero complexity but protects you against total internet/PBX outage scenarios that PBX-level routing cannot handle.

8. Asterisk Dialplan Failover Configuration

For deployments using raw Asterisk (without FreePBX), failover is configured directly in the dialplan using the Dial() application's trunk sequence and the TrySystem() / Goto() logic after failure. Here is a practical example:

📄 extensions.conf — Outbound Failover with PJSIP
; Outbound route with automatic trunk failover
[outbound-calls]
; Try primary trunk first (NetViaVoice)
exten => _NXXNXXXXXX,1,Set(DIALSTATUS=)
exten => _NXXNXXXXXX,n,Dial(PJSIP/1${EXTEN}@netviavoice-endpoint,30,g)
exten => _NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" != "ANSWER"]?failover,1)
exten => _NXXNXXXXXX,n,Hangup()

; Failover to secondary trunk
[outbound-calls]
exten => failover,1,Verbose(1,Primary trunk failed - trying secondary)
exten => failover,n,Dial(PJSIP/1${EXTEN}@backup-endpoint,30)
exten => failover,n,GotoIf($["${DIALSTATUS}" != "ANSWER"]?final-failover,1)
exten => failover,n,Hangup()

; Final failover — voicemail or mobile
exten => final-failover,1,Playback(all-circuits-busy-now)
exten => final-failover,n,Hangup()
📄 pjsip.conf — Dual Trunk Configuration
; ===== Primary Trunk (NetViaVoice) =====
[netviavoice-endpoint]
type=endpoint
transport=transport-udp
context=from-trunk
disallow=all
allow=ulaw,alaw
auth=netviavoice-auth
aors=netviavoice-aor
direct_media=no

; ===== Secondary Trunk (Backup Provider) =====
[backup-endpoint]
type=endpoint
transport=transport-udp
context=from-trunk
disallow=all
allow=ulaw,alaw
auth=backup-auth
aors=backup-aor
direct_media=no

9. Multi-Layer Failover: 3-Tier Redundancy Architecture

For businesses requiring the highest level of telecommunications resilience — call centres, healthcare providers, financial services firms, and emergency services — a three-tier failover architecture provides near-absolute uptime protection:

🏗️ Three-Tier SIP Trunk Redundancy Architecture

Tier 1: Primary SIP Trunk

Provider: NetViaVoice Primary SIP Trunk — main carrier for all outbound and inbound calls. HD voice, full feature set, optimised routing. Carries 100% of traffic under normal operation.

Tier 2: Secondary SIP Trunk (Hot Standby)

Provider: Different SIP carrier with independent infrastructure. Registered and ready to receive calls immediately — no activation delay. PBX automatically routes here on primary failure. Carries 100% of traffic during primary outage.

Tier 3: PSTN Analogue or Mobile Failover (Cold Standby)

Provider: Traditional PSTN line or mobile number as ultimate fallback. Configured at the carrier level in the NetViaVoice portal — activates if both SIP trunks fail simultaneously. No internet connection required. Protects against total internet or power outage.

Internet Redundancy (Supporting Layer)

Configuration: Dual WAN router with primary fibre/cable connection and secondary 4G/LTE backup. SIP QoS rules applied to both connections. Router automatically switches voice traffic to 4G if primary internet fails — without requiring any PBX configuration change.

📊 Business Uptime Impact: Single Trunk vs Dual Trunk vs Three-Tier
Single SIP Trunk
99.9% uptime — 8.7 hrs/yr downtime
Dual SIP Trunk
99.99% uptime — ~52 min/yr downtime
Three-Tier + Dual Internet
99.999%+ uptime — ~5 min/yr downtime

10. Testing Your Failover — Before You Need It

A failover system that has never been tested is a failover system you cannot trust. Many businesses configure failover and assume it works — only to discover during a real outage that a misconfiguration prevents it from activating. Schedule a quarterly failover test to verify everything works as designed:

Test ScenarioHow to TestExpected ResultFrequency
Outbound failover (primary trunk down)Disable primary trunk in FreePBX, make outbound callCall completes via secondary trunk in <8sMonthly
Inbound failover (PBX unreachable)Stop Asterisk service, call your DID from a mobileCall reaches carrier-configured fallback numberMonthly
Internet failover (ISP down)Disconnect primary internet, attempt callsSIP routes via 4G backup; calls complete normallyQuarterly
Full failover stackDisable primary trunk AND disconnect primary internetCalls route via secondary trunk on 4G backupQuarterly
Failover speedTime from primary failure to secondary call connectionShould be under 8 seconds for 408 timeoutMonthly
Inbound DID forwardingVerify NetViaVoice portal forwarding activates correctlyCalls reach designated mobile within 60 seconds of lapseMonthly

For the DTMF aspects of call routing that interact with your failover configuration, see our guide: FreePBX DTMF Configuration. And for advanced call routing strategies that complement your failover setup, read: Least Cost Routing — Complete Guide.

11. Frequently Asked Questions

❓ How do I set up a secondary SIP trunk for failover in FreePBX?

Setting up a secondary SIP trunk for failover in FreePBX involves three steps:

  • Step 1 — Add the secondary trunk: Go to Connectivity → Trunks → Add SIP Trunk. Enter the credentials from your secondary SIP provider. Save and verify it registers successfully (check Admin → Asterisk Info → Peers).
  • Step 2 — Add it to your outbound route: Go to Connectivity → Outbound Routes → [Your Route] → Trunk Sequence tab. Your primary trunk should be at Sequence 0. Click the + button to add your secondary trunk at Sequence 1.
  • Step 3 — Apply and test: Click Submit → Apply Config. Test by temporarily disabling your primary trunk (Connectivity → Trunks → [Primary] → scroll to bottom → "Toggle to Disabled") and making an outbound call. It should complete via the secondary trunk. Re-enable the primary after testing.

For detailed outbound route configuration, see: FreePBX Outbound Routes Guide.

❓ What happens to active calls when a SIP trunk fails?

This is one of the most important questions about SIP trunk failover — and the answer distinguishes between two types of failure scenarios:

  • Calls in progress at the moment of trunk failure: In most cases, calls that are already connected when a trunk fails will continue — because the audio (RTP) is flowing directly between the Asterisk RTP stack and the remote party, not continuously through the SIP trunk's signalling layer. The SIP session is already established. Short network interruptions may cause brief audio disruption but not disconnection. Prolonged trunk failure (carrier network going completely offline) may eventually terminate active calls.
  • New calls attempted while trunk is down: These are the calls that failover routing handles. FreePBX detects the failure on the first call attempt and automatically routes new calls through the secondary trunk from that point onward.

Failover routing protects new call attempts — not calls already in progress. For full protection of in-progress calls, you need SIP session border controller (SBC) technology with active-active trunk redundancy, which is an enterprise-grade solution beyond standard PBX configuration.

❓ Should my primary and secondary SIP trunks be from different providers?

Yes — using the same provider for both primary and secondary trunks defeats the purpose of failover. If your provider has a network-wide outage, both trunks fail simultaneously, and you have no redundancy at all.

For effective failover, your secondary trunk should be from a provider with:

  • Different carrier infrastructure: Different tier-1 carrier interconnects and upstream providers
  • Different geographic infrastructure: Data centres in different regions or cities
  • Different network routes: If possible, different internet exchanges (IX) for carrier connectivity

A practical approach many businesses use: NetViaVoice as the primary trunk (with competitive rates, full feature set, and excellent support) and a major national carrier or a local VoIP provider as the secondary. The secondary trunk carries zero traffic under normal operation — so you only pay for the secondary when you use it, making cost a minimal consideration in provider selection.

❓ How fast does SIP trunk failover happen in FreePBX?

The speed of SIP trunk failover in FreePBX depends on what type of failure causes it:

  • Trunk unregistered / 503 Service Unavailable: Failover is near-instant — typically under 1 second. FreePBX knows the trunk is unavailable before the call is even placed and routes directly to the secondary.
  • 404 Not Found / immediate rejection: Under 1 second — the carrier responds immediately with a rejection and FreePBX tries the next trunk.
  • 408 Request Timeout (no response): This is the slow one. By default, Asterisk waits up to 32 seconds for a response before declaring failure. To speed this up: set t1min=500 in sip.conf or configure timer_t1=500 on the PJSIP transport. With this setting, 408 timeout failover completes in approximately 3–5 seconds.

For a caller, a sub-5-second failover is typically experienced as a brief pause before hearing a ring tone — acceptable in most business scenarios. Configure the t1min setting immediately when setting up your failover system.

❓ Can inbound calls failover automatically if my internet connection goes down?

Yes — but only if you configure carrier-level failover, not just PBX-level failover. If your internet connection fails, your PBX becomes unreachable and cannot receive or process any inbound SIP calls. No PBX-based routing rule can help you at that point.

The solution is to configure failover directly with your SIP trunk provider:

  • In your NetViaVoice portal, navigate to your DID settings
  • Set a Backup Forwarding Number — typically your mobile phone
  • Configure the trigger: "Forward to [mobile] if SIP registration has not been seen for [60] seconds"
  • NetViaVoice monitors your SIP registration status and automatically forwards all inbound calls to your mobile if registration lapses

This carrier-level protection activates within 60–90 seconds of your internet going down and requires no action from you. It works independently of your PBX — your SIP provider handles the call diversion before the call ever tries to reach your server. This is a non-negotiable component of any genuine business continuity plan.

🛡️ Build Bulletproof Call Failover With NetViaVoice

NetViaVoice provides primary and secondary SIP trunks, carrier-level failover configuration, and expert setup support — ensuring your business phone system achieves genuine 99.99% uptime with automatic, transparent failover that protects every call, every day.