GSM Hosting All articles
SMS Infrastructure

Skip the API Middleman: Building a DIY SMS Gateway with $30 of Hardware and Open Source Software

GSM Hosting
Skip the API Middleman: Building a DIY SMS Gateway with $30 of Hardware and Open Source Software

Every developer has had that moment: you check the Twilio bill and realize you're paying a premium per SMS for what is, at its core, a radio transmitting 160 bytes of data. If your volume is meaningful — 2FA codes, alerting, internal notifications — the math starts looking ugly. The good news is that a self-hosted SMS gateway is genuinely buildable for the cost of a nice dinner, and the open-source tooling has been battle-tested for two decades.

The Hardware: What Actually Works

The heart of any DIY gateway is a GSM modem. In practice, you have three tiers:

One critical US-specific note: verify the modem supports the LTE bands your carrier uses. A cheap SIM800 is 2G only, and with AT&T and Verizon having fully shut down their 2G/3G networks, that $15 dongle becomes a paperweight. T-Mobile's legacy networks are gone too. For anything in the US today, you want LTE-capable hardware like the SIM7600 or a Quectel EC25.

The Software Stack

You've got options, and they're not all equal:

gammu / gammu-smsd: The simplest path. A daemon that watches the modem and moves messages in and out of a database. If you just need inbound SMS to SQL and outbound SMS from a script, this is done in an hour.

Kannel: The old-school gateway. It speaks SMPP, so you can bolt it onto existing telecom infrastructure. Configuration files are cryptic, but it's rock solid once running.

Asterisk + chan_dongle: If you're already running Asterisk for voice, the chan_dongle channel driver turns USB dongles into trunk-like resources. You can route SMS through your dialplan, bridge SMS-to-SIP, and manage everything from one box. Fair warning: chan_dongle is community-maintained and quirky with certain modem firmwares.

PlaySMS or Jasmin on top of any of the above gives you a web UI, user accounts, and API endpoints for your apps to hit.

SIM Cards and the Carrier Problem

Here's where the US market gets tricky, and where most guides go quiet. Prepaid SIMs technically work, but the major carriers' terms of service generally prohibit using consumer plans for automated or machine-originated messaging. T-Mobile in particular has been aggressive about throttling or suspending lines that send high SMS volumes from prepaid SIMs.

Your realistic options:

  1. Keep volume low and human-like — fine for alerting and internal tools, risky for anything resembling bulk.
  2. IoT/M2M plans (Hologram, Soracom, KORE Wireless) — designed for machine connectivity, more tolerant of automation, though SMS support varies.
  3. Wholesale SMPP providers — not self-hosted per se, but you host the gateway logic while riding their carrier relationships.

Also understand A2P 10DLC: US long-code SMS for application-to-person traffic is now a registered, fee-per-message regime. Carriers filter unregistered traffic aggressively, and a raw SIM in a modem sends exactly that kind of traffic. Self-hosting works best for person-to-person-style flows, internal alerting, and inbound-heavy use cases — not for blasting marketing texts.

Throughput: Manage Your Expectations

A single modem handles roughly 6–10 SMS per minute sustained without tripping carrier filters. Send faster and you'll see latency creep up, messages queue, and eventually the carrier notices. Two modems don't perfectly double that — RF interference and SIM registration issues compound — but a four-modem setup with staggered sending can realistically push 30–40 messages per minute.

For comparison, a Twilio long code tops out around 1 message per second anyway. The throughput ceiling is the network, not your hardware.

When Self-Hosting Beats the API

Run the numbers honestly. At Twilio's roughly $0.0079 per SMS, you break even against a $30 modem plus a $10/month line somewhere around 5,000 messages per month. Below that, the API is cheaper when you factor in your time. Above it, and especially in the tens of thousands, self-hosting wins decisively.

But cost isn't the whole story. Self-hosting gives you:

And when you shouldn't bother: anything customer-facing at scale, anything needing delivery receipts you can trust, and anything where a blocked SIM would be a business-ending event. Twilio's carrier relationships and compliance plumbing are worth paying for in those cases.

Start Small, Then Scale

Grab a SIM7600, a T-Mobile or MVNO SIM, and a Raspberry Pi or any old Linux box. Get gammu-smsd moving messages into Postgres first. Once that's boring, layer on Kannel or Jasmin for API access. Only then start thinking about multi-modem racks and SMPP peering.

The beauty of the GSM approach is that it's real telecom infrastructure on your own terms — no rate limits, no usage dashboards, just a radio on your desk doing what phones do. For the right workload, nothing else comes close.

All Articles

Related Articles

Voice Traffic Hates Virtualization: When Bare Metal Earns Its Keep (and When It's Overkill)

Voice Traffic Hates Virtualization: When Bare Metal Earns Its Keep (and When It's Overkill)