SIP Gateway for Asterisk: Integration Guide

The clean way to connect Asterisk to SIM or trunk voice is a SIP gateway: Asterisk registers a trunk to the gateway, and the gateway carries the calls to the mobile or fixed network, which keeps Asterisk's dial plan as the only place call logic lives.

The alternative of attaching GSM modules directly through chan_dongle works for small experiments, but a dedicated SIP gateway scales, survives reboots, and keeps the media path stable.

This guide covers the integration model, the configuration steps, dial plan basics, and the troubleshooting path for the Asterisk-to-gateway pairing.

The Integration Model

The model has three parts: Asterisk is the call brain with the dial plan, the gateway is the trunk provider with SIMs or lines, and the two talk over SIP. Asterisk sees the gateway as a trunk, and the gateway sees Asterisk as the phone system.

The advantage over chan_dongle is separation: the gateway manages SIM registration, signal, and failover on its own, while Asterisk manages routing and features. A reboot of Asterisk does not reset the SIMs, and a SIM failure is visible on the gateway's dashboard instead of inside a kernel module.

The media path also stays cleaner: the gateway handles the codec conversion to the mobile network, so Asterisk negotiates one consistent codec with the gateway instead of adapting to every carrier's preferences.

The model also simplifies maintenance: Asterisk upgrades do not touch the gateway, and gateway firmware updates do not require a dial plan change, so each side can be updated on its own schedule. That independence is the quiet benefit of the separation, and it compounds over years of operation.

The Configuration Steps

Step 1 configures the gateway first: set the network, insert the SIMs or connect the trunks, confirm registration, and create the SIP user or trunk that Asterisk will register against. The gateway must be stable before Asterisk is pointed at it.

Step 2 creates the trunk in Asterisk: define the SIP peer with the gateway's IP, the credentials from the gateway's SIP user, and the codec list, then reload the configuration and confirm the trunk registers.

See also  How can an8-port SMS gateway integrate with local databases for automated alerts?

Step 3 verifies from the Asterisk console: the command sip show registry confirms the registration, and sip show peers confirms the gateway is reachable. Both checks are fast and are the first evidence the integration works.

Step 4 tests with a call: place an outbound call through the trunk from a test extension and receive an inbound call, checking audio in both directions. The test call is the proof that registration, routing, and media all work together.

Keep the SIP credentials unique to the pairing: create a dedicated SIP user on the gateway for Asterisk rather than reusing admin credentials, because a compromised trunk credential is a real cost and a separate user limits the blast radius. The extra minute at setup is worth it.

Document the versions: the Asterisk version, the gateway firmware, and the configuration files, because a pairing that works on one version can break on the next. The version record turns an upgrade failure from a mystery into a known compatibility question.

The gateway's own test tools are part of the setup: most gateways can place a test call or show SIM status without Asterisk involved. Use them to prove the trunk side first, because a call that fails at the gateway will also fail through Asterisk, and isolating the layer saves the debugging.

Dial Plan Basics

The dial plan routes external calls to the gateway trunk: an outbound context sends matching destinations to the gateway, and an inbound context receives calls from it and delivers them to extensions or queues.

A minimal outbound rule is a pattern match on the destination prefix with an action that sends the call to the gateway trunk. The rule should also handle what happens when the trunk is unavailable, such as playing a message or routing to a fallback.

Inbound calls arrive on the gateway trunk and should be matched by the caller's number or simply delivered to the main extension; the dial plan can add time-of-day routing, queues, or announcements once the basic flow works.

Element Purpose Example
Outbound context Route external calls to trunk Match 9.XXXXXXXXXX
Inbound context Receive calls from trunk Ring extension 100
Fallback logic Handle trunk failure Play message or hunt
See also  SIM Bank for SMS Gateway: High-Capacity, Authorized Enterprise Messaging Infrastructure

The table shows the three dial plan pieces every integration needs; the exact syntax follows your Asterisk version, and the pattern is the same across them.

The dial plan should also set the caller ID and the allowed destinations: which numbers Asterisk may send through the trunk, and what the gateway presents to the carrier. Both settings are compliance and billing controls, and both are easier to enforce in the dial plan than after the fact.

Start with a restrictive dial plan and open it as testing proves each route: local, then mobile, then international, with the call records checked at each step. A restrictive start prevents surprise bills, and the step-by-step opening keeps the records clean.

Testing the dial plan is a checklist of its own: an allowed number connects, a disallowed number is blocked, a busy trunk returns the fallback behavior, and an inbound call reaches the right extension. Each test is a line in the setup record, and together they define what the system is allowed to do.

Troubleshooting the Integration

Start with the registration: sip show registry should show the gateway as registered, and if it does not, check the network path, the credentials, and the gateway's SIP settings in that order.

Registration is fine but calls fail: check the dial plan route and the trunk selection, then confirm the codec list matches between Asterisk and the gateway. A codec mismatch produces failed calls or poor audio while registration looks healthy.

Audio problems point to the media path: one-way audio is usually a NAT or firewall issue, and poor audio is usually a codec or signal issue on the gateway's SIM side. The two symptoms lead to different fixes, which is why the diagnosis matters more than the symptom list.

The Asterisk log is the first diagnostic: the console shows registration attempts, call setup, and hangup causes, and the cause code at call failure names the layer. Read the log before touching configuration, because the log is the system telling you what happened.

After-hours changes make the pairing fragile: a firewall rule added by the network team, a firmware update on either side, or a new codec preference can break a working integration silently. Re-run the test call after any network or firmware change, and keep the baseline results to compare against.

See also  SIP Trunk Gateway: Scalable Voice Communication for Modern Enterprises (June 2026)

Telarvo Expert Views

The Asterisk integrations that fail are almost always pairing problems: a codec list that does not match, a firewall that blocks the media path, or a gateway configured after Asterisk instead of before. Configure the gateway to a known-good state first, then point Asterisk at it, and the pairing becomes routine.

— Voice Solutions Engineer, Telarvo Store

Validation note: Asterisk syntax and gateway menus vary by version and model; use the documentation for your versions.

Conclusion

The Asterisk and gateway pairing is a clean separation of roles: Asterisk owns the dial plan, the gateway owns the trunks, and the SIP registration plus a tested media path is the whole integration.

Key Takeaways for B2B Buyers

Configure and verify the gateway first, register the trunk in Asterisk, confirm registration and peers from the console, test outbound and inbound audio, and keep the codec list consistent on both sides.

Questions to Ask Before Committing

Ask which Asterisk versions the gateway is tested with, what SIP user options the gateway exposes, which codecs are supported, and how the supplier documents the integration.

Ask Telarvo Store which VoIP gateway is verified with Asterisk before you build the integration.

FAQs

Do I need chan_dongle with a gateway?
No; the gateway replaces direct module attachment with a SIP trunk, which is more stable and scalable for production.

Why is my trunk not registering?
Check the network path, the SIP credentials, and the gateway's registration settings in that order.

Which codec should I set?
Use a codec both sides support, commonly G.711 with a fallback; confirm the gateway's codec list and test the audio.

Can the gateway handle failover for Asterisk?
The gateway manages its own SIM and trunk failover; Asterisk can add routing fallback in the dial plan.

Can I use multiple gateways with one Asterisk server?
Yes; each gateway registers as its own trunk, and the dial plan can route by destination, cost, or priority across them.

What if the gateway reboots?
Asterisk re-registers automatically when the gateway returns, and queued calls fail with a busy signal; the recovery is automatic in most setups.

Sources

Your Guide to VOIP, SMS Gateways, and Telecom Trends - Telarvo Store Blog