Ctrl K
ring2all.com

Outbound Routes Module Documentation

Table of Contents

  1. Module Overview (Technical)
  2. Module Overview (Commercial/Business)
  3. Module Overview (End User/Administrator)
  4. Configuration Fields Reference
  5. Dial Patterns
  6. Routing Strategies
  7. Common Scenarios & Examples
  8. Limitations & Important Notes
  9. Troubleshooting Tips
  10. Glossary

---

1. Module Overview (Technical)

What Are Outbound Routes?

Outbound Routes define how external calls are routed from the PBX to SIP gateways. They match dialed numbers against patterns and select gateways based on priority, weight, and routing strategy.

Architecture

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│                  Outbound Routes System                         │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  User dials: 918005551212                                       │
│       │                                                         │
│       ▼                                                         │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │              route_with_fallback.lua                     │   │
│  │                                                          │   │
│  │  1. Check dialplan_registry (extensions, features)       │   │
│  │  2. No match → Check outbound_route_patterns             │   │
│  │  3. Match pattern: ^9\d{10}$ → "National Calls"          │   │
│  │  4. Strip 1 digit (9) → 18005551212                     │   │
│  │  5. Prepend: +1 → +118005551212                         │   │
│  │  6. Select gateway based on strategy                     │   │
│  │                                                          │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼                                                         │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │        Gateway Selection (Failover Strategy)             │   │
│  │                                                          │   │
│  │  Priority 1: carrier_primary  ──→ Try first             │   │
│  │  Priority 2: carrier_backup   ──→ If primary fails      │   │
│  │  Priority 3: carrier_tertiary ──→ Last resort           │   │
│  │                                                          │   │
│  └──────────────────────────────────────────────────────────┘   │
│       │                                                         │
│       ▼                                                         │
│  sofia/gateway/carrier_primary/+118005551212                    │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Key Tables

TablePurpose
public.outbound_routesRoute definitions
public.outbound_route_patternsDial patterns
public.outbound_route_gatewaysGateway assignments
public.gatewaysAvailable gateways
public.pin_listsOptional PIN protection

Key Files

FileDescription
admin/apps/web/src/modules/outboundRoutes/Frontend module
admin/apps/web/src/i18n/en/outboundRoutes.jsonTranslations
telephony/freeswitch/lua/main/xml_handlers/dialplan/route_with_fallback.luaMain routing handler
---

2. Module Overview (Commercial/Business)

Business Value

Outbound Routes enable intelligent external call routing:

Without Outbound RoutesWith Outbound Routes
Single gatewayMultiple carrier support
No cost optimizationLeast-cost routing
No redundancyAutomatic failover
No access controlPIN-protected routes

Use Cases

  1. Least-Cost Routing
- Route by destination prefix

- Different carriers for local/long-distance/international

  1. Carrier Failover
- Primary carrier unreachable → automatic switch

- No manual intervention

  1. Access Control
- PIN-protect expensive routes

- Restrict international dialing

  1. Number Manipulation
- Strip access codes (9)

- Prepend country codes (+1)

Feature Highlights

FeatureBenefit
Pattern MatchingRegex or simplified (9XXX)
Strip/PrependNumber manipulation
3 StrategiesFailover, Round Robin, Load Balance
Priority-basedRoute evaluation order
PIN ProtectionAccess control
Gateway FailoverAutomatic redundancy
---

3. Module Overview (End User/Administrator)

What Can You Do?

  • Create outbound routes with names
  • Define dial patterns (prefix or regex)
  • Configure number manipulation (strip/prepend)
  • Assign multiple gateways with priorities
  • Choose routing strategy
  • Add PIN protection

Administrator Workflow

Plaintext
┌─────────────────────────────────────────────────────────────────┐
│              Creating an Outbound Route                         │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Tab 1: General Settings                                        │
│  ├─ Route Name: "National Calls"                               │
│  ├─ Description: "US domestic calls via primary carrier"       │
│  ├─ Priority: 100                                              │
│  ├─ Routing Strategy: Failover                                 │
│  └─ Enabled: ✓                                                 │
│                                                                 │
│  Tab 2: Dial Patterns                                           │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │ Pattern: 9NXXNXXXXXX | Strip: 1 | Prepend: +1 | ✓         │  │
│  │ Pattern: 91NXXNXXXXXX | Strip: 1 | Prepend: + | ✓         │  │
│  └───────────────────────────────────────────────────────────┘  │
│  [+ Add Pattern]                                                │
│                                                                 │
│  Tab 3: Gateways & Failover                                     │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │ ≡ carrier_primary   | Priority: 1 | Weight: 100 | ✓       │  │
│  │ ≡ carrier_backup    | Priority: 2 | Weight: 100 | ✓       │  │
│  └───────────────────────────────────────────────────────────┘  │
│  [+ Add Gateway]                                                │
│                                                                 │
│  Tab 4: Advanced Options                                        │
│  ├─ PIN List: (optional)                                       │
│  ├─ Failover Module: Terminate                                 │
│  └─ Failover Destination: Hangup                               │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Quick Tips

TIP
Use Simplified Patterns: 9XXX is easier than ^9\d{3}$.
TIP
Lower Priority = Higher Precedence: Route with priority 50 is checked before 100.
CAUTION
Strip Count: Make sure strip count doesn't remove too many digits.

---

4. Configuration Fields Reference

Route Fields

FieldDescriptionExample
Route NameUnique identifierNational Calls
DescriptionOptional descriptionUS domestic calls
PriorityEvaluation order (lower = first)100
Routing StrategyGateway selection methodFailover
EnabledRoute active statusOn/Off
Dial ProfileOptional Dial Profile template to execute dialplan variables before bridging(select list)
PIN ListOptional PIN protection(select list)
Failover ModuleAction when all failTerminate
Failover DestinationSpecific actionHangup

Pattern Fields

FieldDescriptionExample
PatternDial pattern to match9NXXNXXXXXX
Strip DigitsDigits to remove from start1
PrependDigits to add after strip+1
DescriptionPattern descriptionLocal calls
PriorityOrder within route1
EnabledPattern activeOn/Off

Gateway Fields

FieldDescription
GatewaySelected gateway
PriorityOrder for failover (1=first)
WeightLoad balance weighting
DescriptionOptional note
EnabledGateway in use
---

5. Dial Patterns

Pattern Syntax

Simplified Patterns:
SymbolMeaningExample
XAny digit (0-9)9XXX = 9000-9999
ZDigit 1-99ZXXX = 91000-99999
NDigit 2-99NXXX = 92000-99999
Regex Patterns:
PatternMatches
^9\d{10}$9 + 10 digits
^011.International (011...)
^1[2-9]\d{9}$1 + 10 digit US

Pattern Examples

PurposePatternStripPrependResult
Local (7-digit)9NXXXXXX1+1305Dial 95551234 → +13055551234
National (10-digit)9NXXNXXXXXX1+1Dial 93055551234 → +13055551234
Toll-Free91800NXXXXXX1+Dial 918005551234 → +18005551234
International9011.1+Dial 901152... → +52...
---

6. Routing Strategies

Strategy Comparison

StrategyDescriptionBest For
FailoverTry gateways in priority orderReliability
Round RobinRotate through gatewaysLoad distribution
Load BalanceWeighted distributionProportional traffic

Failover Strategy

Plaintext
Call comes in
    │
    ▼
Try Gateway 1 (Priority 1)
    │
    ├── Success → Call connected
    │
    └── Fail → Try Gateway 2 (Priority 2)
                    │
                    ├── Success → Call connected
                    │
                    └── Fail → Failover destination

Round Robin Strategy

Plaintext
Call 1 → Gateway A
Call 2 → Gateway B
Call 3 → Gateway C
Call 4 → Gateway A (restart)

Load Balance Strategy

Plaintext
Weights: Gateway A = 70, Gateway B = 30

~70% of calls → Gateway A
~30% of calls → Gateway B

---

7. Common Scenarios & Examples

Scenario 1: US National Calling

Route: "National Calls"
SettingValue
Priority100
StrategyFailover
Patterns:
PatternStripPrependDescription
9NXXNXXXXXX1+110-digit national
91NXXNXXXXXX1+11-digit with 1
Gateways:
GatewayPriority
primary_carrier1
backup_carrier2

Scenario 2: International with PIN

Route: "International"
SettingValue
Priority200
StrategyFailover
PIN ListInternational PIN
Patterns:
PatternStripPrependDescription
9011.1+International

Scenario 3: Load-Balanced Multi-Carrier

Route: "Multi-Carrier"
SettingValue
Priority100
StrategyLoad Balance
Gateways:
GatewayWeight
carrier_a50
carrier_b30
carrier_c20
---

8. Limitations & Important Notes

Technical Notes

NOTE
Route Priority: Lower number = higher priority (checked first).
WARNING
Pattern Overlap: If patterns overlap, the first matching route wins.
WARNING
Strip Count: Stripping too many digits will break the dialed number.

Best Practices

  1. Order Routes Carefully: Most specific patterns first
  2. Test Patterns: Verify patterns match intended numbers
  3. Set Failover: Always have a backup gateway
  4. Use PIN for Expensive Routes: Protect international calling
  5. Document Routes: Use descriptions for future reference

---

9. Troubleshooting Tips

Common Issues

SymptomPossible CauseSolution
Call not routingPattern doesn't matchTest pattern regex
Wrong carrier usedRoute priority wrongAdjust route priority
Number format wrongStrip/prepend incorrectReview manipulation
No failoverAll gateways disabledEnable backup gateway
PIN always requiredPINless not enabledCheck extension settings

Diagnostic SQL

List outbound routes:

Sql
SELECT id, name, priority, routing_strategy, enabled
FROM public.outbound_routes
WHERE domain_id = [domain_id]
ORDER BY priority;

Check route patterns:

Sql
SELECT r.name as route, p.pattern, p.strip_digits, p.prepend, p.enabled
FROM public.outbound_route_patterns p
JOIN public.outbound_routes r ON p.route_id = r.id
WHERE r.domain_id = [domain_id]
ORDER BY r.priority, p.priority;

Check route gateways:

Sql
SELECT r.name as route, g.name as gateway, org.priority, org.weight
FROM public.outbound_route_gateways org
JOIN public.outbound_routes r ON org.route_id = r.id
JOIN public.gateways g ON org.gateway_id = g.id
WHERE r.domain_id = [domain_id]
ORDER BY r.name, org.priority;

FreeSWITCH Logs

Bash
# Enable debug logging
fs_cli -x "sofia loglevel all 9"

# Check outbound call routing
grep "route_with_fallback" /var/log/freeswitch/freeswitch.log

---

10. Glossary

TermDefinition
Outbound RouteRule for routing external calls
Dial PatternRegex or simplified pattern to match
Strip DigitsRemove N digits from start of number
PrependAdd digits before the number
FailoverTry next gateway on failure
Round RobinRotate through gateways
Load BalanceDistribute calls by weight
PIN ListAccess control via numeric codes
---

Lua Script Status ✅

Already Correct

ScriptStatus
route_with_fallback.lua✅ Uses public.outbound_routes, public.outbound_route_patterns, public.outbound_route_gateways, public.gateways, public.pin_lists, public.sip_extensions
No Lua fixes needed!

---

Documentation last updated: January 2026*

AI Assistant

👋 Hello! I'm your Ring2All documentation assistant. I can help you find information about configuring and using the Ring2All PBX platform.

How can I help you today?