GSM gateways put SIM cards behind a SIP interface, letting a dialer place calls over mobile networks rather than a wholesale SIP trunk. In markets where mobile-to-mobile rates beat VoIP termination, or where local caller ID matters more than cost, they earn their place.
The configuration is straightforward. The operational side is where people struggle.
How the Gateway Presents Itself
Whatever the vendor — Dinstar, Yeastar, OpenVox, GoIP, Synway — a GSM gateway does the same thing: it accepts SIP on its LAN side and bridges to GSM on its radio side. To Asterisk it looks like any other SIP device.
There are two ways to connect it:
Use IP mode unless you have a reason not to.
Asterisk Side: IP Trunk
In your VICIdial carrier’s Account Entry:
[gsmgw]
type=friend
host=192.168.1.200
port=5060
context=trunkinbound
insecure=port,invite
disallow=all
allow=ulaw
allow=alaw
dtmfmode=rfc2833
qualify=yes
canreinvite=no
nat=no
Notes specific to GSM gateways:
canreinvite=no— keep media on the server. Gateways handle re-invites inconsistently and you will get one-way audio.nat=nowhen the gateway is on your LAN. Settingforce_rportagainst a local device causes more problems than it solves.- Codec. Most gateways transcode GSM to ulaw or alaw internally. Offer only what the gateway lists as supported — negotiating a codec it does not have produces call setup failures that look like network faults.
Leave Registration String empty for IP mode.
Dialplan Entry
exten => _9X.,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _9X.,n,Dial(SIP/gsmgw/${EXTEN:1},60,tTo)
exten => _9X.,n,Hangup()
GSM call setup is slower than SIP — the network has to locate the handset. A 60-second timeout is reasonable; 30 will cut off calls that would have connected.
Gateway Side
In the gateway’s web interface, configure a SIP endpoint pointing back at Asterisk:
- Server address: your VICIdial server IP
- Port: 5060
- Registration: disabled, for IP mode
- Codec: match what you allowed in Asterisk
Then set the routing rules. Most gateways use a table mapping inbound SIP calls to outbound GSM channels. A basic rule sends everything from your Asterisk IP to any available channel:
IP->Tel: source=192.168.1.50 -> channel group: all
Tel->IP: any channel -> 192.168.1.50:5060
The Tel->IP rule handles inbound calls to the SIM numbers. Without it, calls to your SIMs ring nowhere.
Per-Channel Routing
Where GSM gets interesting is selecting a specific SIM. You might want each campaign on its own number, or to present a caller ID matching the region being dialled.
Most gateways expose channels via a prefix. Check your vendor’s syntax — a common pattern is to prefix the dialled number with the channel or group identifier. If channel 3 is addressed as a prefix, the dialplan becomes:
exten => _93X.,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _93X.,n,Dial(SIP/gsmgw/3${EXTEN:2},60,tTo)
exten => _93X.,n,Hangup()
Then set the campaign’s dial prefix to 93 to route it out channel 3 specifically.
For round-robin across a group, most gateways handle selection internally when you dial the group rather than a channel. That is preferable — let the gateway do channel selection, since it knows which SIMs are registered and which are in a call.
Verifying
asterisk -rx "sip show peer gsmgw"
Status OK with a latency figure means the qualify ping is answered.
Place a test call and watch:
asterisk -rvvvvv
sip set debug peer gsmgw
Read the SIP response codes:
| Code | Usual cause on GSM |
|---|---|
| 404 | Routing rule on the gateway does not match, or number format wrong |
| 480 | SIM not registered to the mobile network |
| 486 | Called party busy, or all channels in use |
| 503 | Gateway out of available channels |
| 603 | Network rejected the call — often SIM blocked or out of credit |
Check SIM registration on the gateway’s status page before assuming Asterisk is at fault. A SIM that has lost network registration will fail every call while the gateway itself looks perfectly healthy.
Audio Problems Specific to GSM
Operational Realities
Three things that are not configuration but will determine whether this works:
Summary
Connect over IP rather than registration, keep media on the server with canreinvite=no, allow a 60-second dial timeout for GSM setup, and let the gateway pick channels within a group. Then spend your time on SIM rotation and pacing, because that is what actually determines whether a GSM setup survives past the first month.