Inbound and outbound route patterns in FreePBX — common scenarios
Dial patterns are FreePBX®'s way of matching dialed numbers to trunks and matching inbound DIDs to destinations. The syntax is a little obscure if you've never seen it; this article covers the characters, the common patterns you'll need (US/Canada, international, local), and the inbound side.
The pattern characters
| Char | Matches |
|---|---|
X |
any digit 0-9 |
Z |
any digit 1-9 |
N |
any digit 2-9 |
[1235] |
any one of those listed digits |
[1-5] |
any digit 1, 2, 3, 4, or 5 |
. |
one or more of any character (wildcard) |
! |
zero or more (wildcard) |
| |
separator between prefix-to-strip and digits-to-match |
Examples:
NXXNXXXXXX— exactly 10 digits, where the 1st and 4th must be 2-9. Matches any standard US/Canada number.1NXXNXXXXXX— same but with explicit leading 1.011.— anything starting with 011 (US international prefix).9|NXXNXXXXXX— strip a leading 9, then match a 10-digit number. Used for "dial 9 for outside line" scenarios.
Outbound routes — the structure
In Connectivity → Outbound Routes, each route has three columns that matter on the Dial Patterns tab:
| prepend | prefix | match pattern |
|---|---|---|
| A row matches when the dialed digits start with the prefix and the rest matches the pattern. The prefix is stripped, and the prepend is added to what's sent to the trunk. | ||
Common US/Canada (NANP) patterns
The goal: callers can dial either 10-digit (5551234567) or 11-digit (15551234567), and you send 11-digit E.164 (no plus) to the carrier.
| prepend | prefix | match pattern | caller dials | trunk receives |
|---|---|---|---|---|
| 1 | NXXNXXXXXX | 5551234567 | 15551234567 | |
| 1NXXNXXXXXX | 15551234567 | 15551234567 |
Some carriers want the plus prefix:
| prepend | prefix | match pattern | caller dials | trunk receives |
|---|---|---|---|---|
| +1 | NXXNXXXXXX | 5551234567 | +15551234567 | |
| + | 1NXXNXXXXXX | 15551234567 | +15551234567 |
International patterns
US/Canada use 011 as the international prefix. From elsewhere it's 00 or +. Match both at once:
| prepend | prefix | match pattern | example |
|---|---|---|---|
| 011 | X. | 011442012345678 → 442012345678 sent | |
| + | 011 | X. | 011442012345678 → +442012345678 sent |
| + | X. | +442012345678 → +442012345678 sent |
Carriers vary on what they want; check with your carrier's docs or test with one international call.
Emergency numbers — handle these specially
911, 112, 999, etc. should have their own outbound route at the top of the route list (higher priority), routed through whichever trunk has E911 configured. Don't let an emergency call get misdirected to a non-emergency trunk.
| prepend | prefix | match pattern |
|---|---|---|
| 911 | ||
| 933 | ||
| 1911 |
933 is the E911 test number — calling it confirms your registered address comes back as the dispatch location.
Local extension dialing (overlap with PSTN patterns)
If your extensions are 1001-1099 (4-digit), they don't conflict with 10-digit NANP patterns — FreePBX dial extension matching happens before outbound route matching. But if your extensions are 4 digits and start with 1 (1001-1099) AND a caller dials 1-555-..., FreePBX's match-shortest-first might interpret 1001 as the extension. Solutions:
- Use extensions that don't start with 1 (2000+, 3000+, etc.).
- Configure a longer dial timeout so FreePBX waits to see if more digits are coming.
- Use # as a "dialed" terminator on phones — caller types
15551234567#to dial immediately.
Caller ID manipulation in outbound routes
Each outbound route has a Route CID field. If set, this overrides whatever caller ID the extension would normally send.
Use cases:
- Per-trunk caller ID: Trunk A is your main DID, Trunk B is for low-cost international — set Route B's CID to a number registered with Trunk B's carrier.
- Show the main company number, not the extension's DID: useful for outbound calls that should appear as coming from the main line.
- "Force route CID": extension's own CID is ignored entirely. Otherwise the extension's CID wins if set.
Inbound routes
Inbound is simpler: each DID maps to one destination.
- DID Number: exactly what the carrier sends. Test by checking Reports → CDR Reports after an inbound call — the "Number Dialed" column shows the literal value.
- CID Number (optional): filter by caller ID too. Empty matches any caller. Set to a specific number for VIP routing.
- Destination: where the call goes. Extension, IVR, Ring Group, Queue, Voicemail, Conferences, Time Conditions.
Common inbound scenarios
Business hours routing
Calls during business hours go to a ring group; after-hours go to voicemail.
- Create a Time Group: Applications → Time Groups. Define your business hours (e.g. M-F 09:00-17:00).
- Create a Time Condition: Applications → Time Conditions. Match the Time Group; set matched destination to your ring group; set unmatched destination to voicemail.
- In the Inbound Route for the DID, set Destination to the Time Condition.
IVR / auto-attendant
- Record a greeting: Admin → System Recordings → Add. Either record from an extension or upload a WAV/MP3.
- Build the IVR: Applications → IVR → Add IVR. Pick the greeting; define menu entries (1 = sales, 2 = support, 0 = operator).
- Set the Inbound Route's destination to the IVR.
Ring group (multiple phones ring at once)
- Applications → Ring Groups → Add.
- Extension list:
1001-1003(or specific extensions). - Ring Strategy: ringall (all phones ring) or hunt (in order until someone answers).
- Time to ring before failover (typically 20-30 sec).
- Destination if no answer: voicemail.
Testing patterns without making calls
FreePBX has a built-in dial-pattern tester under each Outbound Route — type a sample number and see whether it matches and what gets sent to the trunk. Catches typos before they become "$200 international toll" tickets.
FreePBX® and Asterisk® are registered trademarks of Sangoma Technologies Corporation.
Also Read
Powered by WHMCompleteSolution