GSMCalls
Asterisk integration

GSM Gateway for Asterisk (PJSIP)

To connect a GSM gateway to Asterisk, define it in pjsip.conf as a trunk — an endpoint, AOR, auth and, if needed, a registration — then route calls to it in the dialplan. GSMCalls exposes your mobile phones as one standard SIP trunk, so Asterisk dials PJSIP/number@gsmcalls like any carrier.

At a glance

Why teams choose GSMCalls as their GSM gateway for Asterisk

  • Plain res_pjsip configuration — no channel drivers to compile
  • Registration or IP identify, your choice
  • alaw, ulaw and g722 codecs
  • UDP, TCP or TLS transport
  • Mobile disconnect causes in GSMCalls CDRs
  • No GSM modules or chan_dongle to maintain

How a GSM gateway fits into Asterisk

Older Asterisk GSM setups used USB modems with chan_dongle or dedicated gateway cards. Those tie radio hardware to the Asterisk server and are hard to monitor remotely. With GSMCalls, mobile phones at your sites handle the radio side, the cloud platform presents them as a SIP trunk, and Asterisk only needs res_pjsip — the SIP stack that ships with every current Asterisk release.

pjsip.conf example for a GSM gateway trunk

Create a trunk in the GSMCalls portal, then replace the placeholders below with the host and credentials it shows. The registration keeps the trunk reachable when Asterisk is behind NAT; if your server has a fixed public IP and you use an IP ACL instead, drop the registration and auth sections and keep identify.

pjsip.conf — GSMCalls trunk (placeholders in capitals)
; /etc/asterisk/pjsip.conf — values in CAPS come from the GSMCalls trunk page
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060

[gsmcalls-reg]
type=registration
transport=transport-udp
outbound_auth=gsmcalls-auth
server_uri=sip:GSMCALLS_SIP_HOST:5060
client_uri=sip:TRUNK_USERNAME@GSMCALLS_SIP_HOST
contact_user=TRUNK_USERNAME
retry_interval=60
expiration=300

[gsmcalls-auth]
type=auth
auth_type=userpass
username=TRUNK_USERNAME
password=TRUNK_PASSWORD

[gsmcalls-aor]
type=aor
contact=sip:GSMCALLS_SIP_HOST:5060
qualify_frequency=30

[gsmcalls]
type=endpoint
transport=transport-udp
context=from-gsmcalls
disallow=all
allow=alaw,ulaw,g722
outbound_auth=gsmcalls-auth
aors=gsmcalls-aor
from_user=TRUNK_USERNAME
direct_media=no

[gsmcalls-identify]
type=identify
endpoint=gsmcalls
match=GSMCALLS_SIP_HOST

Dialplan example

Outbound calls use the endpoint name in the Dial string. Inbound calls arrive in the context set on the endpoint, where you can ring an extension, queue or IVR.

extensions.conf — outbound and inbound
; /etc/asterisk/extensions.conf
[from-internal]
; dial 9 + number to send a call out through the GSMCalls trunk
exten => _9X.,1,NoOp(Outbound via GSMCalls to ${EXTEN:1})
 same => n,Dial(PJSIP/${EXTEN:1}@gsmcalls,60)
 same => n,Hangup()

[from-gsmcalls]
; calls arriving from the mobile lines ring extension 1001
exten => _X.,1,NoOp(Inbound from ${CALLERID(num)} for ${EXTEN})
 same => n,Dial(PJSIP/1001,30)
 same => n,Hangup()

Registration or IP identify?

Asterisk can reach the GSMCalls trunk in two ways. With registration, Asterisk sends a REGISTER with the trunk credentials and keeps it refreshed, so the platform always knows where to deliver inbound calls — the practical choice when Asterisk sits behind NAT or on a dynamic IP. With IP identify, the GSMCalls trunk is locked to your server’s public IP by an ACL and the identify section matches traffic by source address, which avoids credentials on the wire but needs a fixed address.

Either way, keep the endpoint name stable. Dial strings, reports and any AGI or ARI scripts refer to it, and changing it later means touching every context that routes calls out.

Codecs: alaw, ulaw and g722

Match the allow line to the codec order on the GSMCalls trunk. G.711 μ-law (ulaw) is standard in North America and Japan; A-law (alaw) in most other regions — see G.711 A-law vs μ-law. Add G.722 when your endpoints support wideband: Smart Bridge phones stream G.722 to the cloud, so wideband can reach the handset on your desk.

Security and troubleshooting

For signalling encryption use a TLS transport on port 5061 and set media_encryption=sdes on the endpoint for SRTP where the trunk supports it; the reasoning is in SIP security with TLS and SRTP. Useful CLI commands:

  • pjsip show registrations — is the trunk registered?
  • pjsip show endpoint gsmcalls — codecs, AOR contact and qualify status
  • pjsip set logger on — watch the SIP exchange for a failing call
  • One-way audio: set external_media_address and external_signaling_address on the transport when behind NAT
Step by step

Set up your GSM gateway for Asterisk

  1. Step 1: Create the trunk in GSMCalls

    Add a SIP trunk in the portal and copy its host, port, username and password.

  2. Step 2: Edit pjsip.conf

    Add transport, registration, auth, AOR, endpoint and identify sections with your values.

  3. Step 3: Add dialplan

    Route an outbound pattern to PJSIP/number@gsmcalls and handle inbound calls in from-gsmcalls.

  4. Step 4: Reload and test

    Run pjsip reload and dialplan reload, check registrations and place test calls both ways.

Compare

Asterisk codec choices for a GSM gateway trunk

CodecSample rateBitrateUse it when
G.711 A-law (alaw)8 kHz64 kbit/sEurope, Middle East, Africa, most of Asia
G.711 μ-law (ulaw)8 kHz64 kbit/sNorth America and Japan
G.722 (g722)16 kHz64 kbit/sWideband HD voice to capable phones
Pricing

Plans that grow with your gateway estate.

One flat monthly price per plan — not per device.

Professional

Most popular

For operators running several gateways.

$150/ month
  • Up to 20 phones
  • Multiple gateways
  • Multiple locations
  • Advanced CDR
  • Device profiles
  • Prepaid usage management
  • Alerts
  • API (coming soon)
  • Priority support
Start Professional
Prices in USD per month. Taxes, carrier airtime and SIM costs are not included. Features marked Coming Soon are not yet available.Compare all four plans
FAQ

GSM gateway for Asterisk questions

Still unsure? Talk to an engineer — we'll map your site to the right architecture.

Talk to an Engineer

Do I need chan_dongle to use a GSM gateway with Asterisk?

No. GSMCalls is reached over SIP, so standard res_pjsip is enough. No USB modems are attached to the Asterisk server.

Can I use chan_sip instead of PJSIP?

chan_sip was removed in Asterisk 21. Use res_pjsip, which is also what FreePBX uses for new trunks.

How do I enable HD voice?

Add g722 to the endpoint allow line and to the GSMCalls trunk codec order, and use desk phones or softphones that support G.722.

Does this work with FreePBX or other Asterisk-based systems?

Yes. FreePBX builds the same PJSIP objects from its web interface, and other Asterisk-based PBXs accept equivalent trunk settings.

Why does my trunk show Unavailable?

The AOR qualify is not getting OPTIONS replies. Check the host, port, transport and that your firewall allows SIP to and from the GSMCalls host.

GSMCalls is built for lawful, authorised deployments. You remain responsible for local telecommunications regulations and your carriers’ terms — see the acceptable use policy.

Build Your Mobile Gateway Infrastructure

Connect a few phones or manage hundreds of devices across multiple locations from one platform.