VoIP.info Guide

Asterisk dialplan fundamentals

Use contexts, extensions and priorities to build a small internal call path with explicit permissions.

Reviewed 2026-09-07Asterisk 22 LTSIntermediateDocumentation based · not lab tested

A program that executes for a channel

The dialplan organizes actions into contexts. An endpoint's incoming context determines where its requests begin. Inside that context, an extension selects actions and priorities establish order. A dialplan extension can be a named behavior; it is not necessarily a physical phone.

Treat contexts as permission boundaries. A caller entering from a carrier should not automatically gain the same reachable destinations as a trusted internal extension. Review include relationships, because a permissive included context can undermine an otherwise restricted starting context.

A call follows a dialplan context
An incoming channel enters a context, matches an extension and then runs applications in priority order. A permitted destination can be another endpoint, a trunk or voicemail.

Contexts form a call-permission boundary. Keep untrusted inbound routes separate from privileged outbound patterns.

A two-phone internal example

The fragment below allows calls to two named PJSIP endpoints and ends processing afterward. It assumes those endpoints already exist. The timeout is an editorial lab choice, not a universal business setting. There is no outside route.

If a handset dials an unlisted number, that does not mean the PBX is broken. The restricted example intentionally supports only its defined destinations. Add real business behavior after deciding permissions and fallback handling.

/etc/asterisk/extensions.conf — internal lab only
[lab-internal]
exten => 2101,1,Dial(PJSIP/2101,20)
 same => n,Hangup()
exten => 2102,1,Dial(PJSIP/2102,20)
 same => n,Hangup()

Observe the loaded program

After a supported dialplan reload, inspect dialplan show lab-internal. Confirm the extensions and priorities appear as intended. Place one call and follow its actual context and destination in a bounded log session.

A phone can register successfully while its calls enter an unexpected context. Verify the endpoint's loaded context when the dialplan seems correct but a call is rejected or takes another path.

Grow without opening a toll route

Use explicit numbering and review patterns before adding a trunk. Decide who may dial premium, international or forwarded destinations. Handle no-answer and unavailable cases intentionally. Keep a before-and-after copy so a failed routing change can be reverted without reconstructing the old rules from memory.

Watch the explanation

Asterisk Tutorial 06 - Asterisk Dialplan Introduction [english]pascom GmbH · 11:55 · Legacy

Starts with an extension-not-found error, then builds a small context and follows its priorities in the Asterisk console. A concrete introduction to how an incoming channel finds dialplan instructions.

Read applicability and editorial notes →
Watch this video here

Historical 2014 tutorial. Contexts and priorities remain relevant; the chan_sip endpoint commands do not apply to Asterisk 22. Review used the available transcript and primary references; audio and screen readability remain unverified.

The player loads only when you choose Watch here. Playback uses YouTube’s privacy-enhanced embed; YouTube processes playback data.

Sources & applicability

Primary references for the technical details above. Operational examples and planning checklists are VoIP.info editorial guidance.

Examples require adaptation to your topology. No live PBX or hardware testing is claimed.