ViciDial SIP Carrier Setup: Trunks, Dialplan Entry and Failover

vicidial sip carrier setup - custom-vdcar-featured.png

Nothing dials until ViciDial knows how to reach the phone network. That connection is a carrier (a SIP trunk to a
wholesale provider), configured under Admin → Carriers. Each carrier has an account entry (how Asterisk talks to the
provider) and a dialplan entry (which numbers go out through it).

This guide covers a single carrier end to end, then failover. Pair it with the
caller ID guide and, when you scale out, the
cluster architecture where each dial server holds its own trunks.

Note: field names and template dialplan lines vary slightly between ViciDial builds. Treat the snippets as a working pattern and compare with the template your version pre-fills.

How a Call Leaves ViciDial

The campaign adds a dial prefix, Asterisk matches the resulting number against the carrier’s dialplan entry, and that entry dials out through the trunk.

architecturecall-path.txt
  campaign dial prefix '9' + 5551234567
      --> dialplan entry matches _9NXXNXXXXXX
      --> Dial(SIP/provider/5551234567)
      --> provider --> PSTN
Outbound call path
Campaign, dialplan, trunk

Gather Provider Details First

Get these from the provider before touching ViciDial: signalling host or IP, authentication method (IP whitelist or username/password), supported codecs, channel or CPS limits, and the number format they expect.

TipAsk for the provider’s source IP ranges too, so you can allow them in the firewall and reject SIP from everywhere else.
Provider checklist
Host, auth, codecs, limits

Add the Carrier in Admin

Open Admin → Carriers → Add A New Carrier. Set a Carrier ID and name, the protocol, and the dial server that owns the trunk. Leave Active at N until you finish and test.

NoteIn a cluster, the carrier belongs to one dial server. Add it on each server that should be able to dial through this provider.
Add carrier form
Identity, protocol, server

Write the Account Entry

The account entry is a peer definition that Asterisk loads. For an IP-authenticated provider it is short; password providers add credentials.

iniAccount Entry (pattern)
[provider1]
type=peer
host=sip.provider.example
dtmfmode=rfc2833
disallow=all
allow=ulaw
allow=alaw
canreinvite=no
insecure=port,invite
qualify=yes
WarningOnly allow codecs your provider supports; a mismatch shows up as calls that connect with no audio.
Account entry
Peer definition

Write the Dialplan Entry

Match the campaign’s prefixed number, log the call through ViciDial’s AGI first, then dial the trunk with the prefix stripped.

iniDialplan Entry (pattern)
exten => _9NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _9NXXNXXXXXX,2,Dial(SIP/provider1/${EXTEN:1},,tTo)
exten => _9NXXNXXXXXX,3,Hangup
Note${EXTEN:1} drops the leading dial prefix. If your carrier wants a different prefix or E.164 format, change the strip length and match pattern together.
Dialplan entry
Match, log, dial

Add a Registration String If Required

Providers that authenticate by username and password expect Asterisk to register. IP-authenticated providers do not need this at all.

iniRegistration String
register => username:[email protected]
bashverify from the Asterisk CLI
asterisk -rx "sip show registry"
asterisk -rx "sip show peers" | grep provider1
Registration
Only for password providers

Activate and Test With a Real Call

Set the carrier Active, reload, and place a manual dial from a test campaign to a phone you control. Confirm audio both ways and that the call appears in the log.

bashwatch the call
asterisk -rx "core show channels"
asterisk -rx "sip set debug ip sip.provider.example"
sqlconfirm the log row
SELECT call_date, phone_number, status FROM vicidial_log ORDER BY call_date DESC LIMIT 5;
Test call
Dial, watch the CLI, check the log

Plan Carrier Failover

A single carrier is a single point of failure. Add a second carrier and route by dial status or by splitting campaigns across trunks; test the failover path deliberately rather than discovering it during an outage.

iniDialplan failover pattern
exten => _9NXXNXXXXXX,2,Dial(SIP/provider1/${EXTEN:1},,tTo)
exten => _9NXXNXXXXXX,3,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?4:5)
exten => _9NXXNXXXXXX,4,Dial(SIP/provider2/${EXTEN:1},,tTo)
exten => _9NXXNXXXXXX,5,Hangup
Carrier failover
Primary and backup trunk

Quick Reference

  • Provider details first; one carrier, tested, before adding a second
  • Account entry = peer; dialplan entry = match + call_log + Dial; test failover on purpose

Related tutorials

Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.