Kamailio vs Asterisk: When to Use Each
Introduction¶
Both are open-source SIP platforms, but they solve different problems. Choosing wrong means either fighting Asterisk to scale, or trying to make Kamailio play audio prompts.
What each is¶
Asterisk — B2BUA and media server¶
- A Back-to-Back User Agent: it terminates the incoming call leg and originates a new outgoing leg. It's in every call.
- Handles media: plays prompts, records, does IVR, conferencing, voicemail, DTMF detection, transcoding, music on hold.
- A full PBX: dialplan, queues, features (transfer, park, pickup).
- Stateful and resource-heavy per call — RTP, codecs, channels. One box handles hundreds to low thousands of concurrent calls.
Kamailio — SIP proxy/router/registrar¶
- A SIP proxy: it forwards SIP messages, it is not a call party. It stays in the signalling path (Record-Route) but never touches RTP.
- Registrar / location service, load balancer, SBC-like functions (NAT traversal help, topology hiding, rate limiting, auth).
- Programmable routing in its own config language (
kamailio.cfg) or via KEMI (Lua/Python/JS). - Extremely scalable — tens of thousands of registrations, thousands of calls per second, because it only shuffles small text messages.
The canonical architecture¶
internet
|
[ Kamailio ] <- SIP edge: registration, auth, NAT handling, load balancing,
| rate limiting, dispatcher to the media tier
+--> [ Asterisk #1 ] <- media: IVR, queues, voicemail, conferencing
+--> [ Asterisk #2 ]
+--> [ Asterisk #N ]
|
[ RTPengine ] <- media relay for NAT / recording (driven by Kamailio)
Kamailio is the front door: it authenticates users, keeps the registration
table, protects against floods, and dispatches calls across a pool of
Asterisk boxes (dispatcher module + health checks). Asterisk does the
call-processing work. RTPengine (Kamailio-controlled) relays media when NAT
requires it.
This gives you Kamailio's scale and resilience at the edge with Asterisk's features behind it — and you can add Asterisk capacity horizontally.
Choosing for a project¶
| You're building | Use |
|---|---|
| An office PBX, < ~500 concurrent calls, lots of features | Asterisk alone |
| A hosted PBX / class-4 softswitch / SIP trunking platform at scale | Kamailio edge + Asterisk (or FreeSWITCH) media |
| A registrar / SIP load balancer / SBC | Kamailio (or OpenSIPS) |
| IVR, call recording, conferencing, complex media | Asterisk or FreeSWITCH |
| Carrier-grade routing, LCR, high CPS, no media | Kamailio / OpenSIPS |
FreeSWITCH is the other media server — more built for scale and concurrency than Asterisk, steeper learning curve; often paired with Kamailio the same way.
Verification and troubleshooting¶
# Kamailio
kamctl ul show # registered contacts
kamcmd dispatcher.list # media-tier targets + health
kamcmd core.shmmem # shared memory (tune -m / -M)
sngrep # ladder diagrams across both
# Asterisk
asterisk -rx "pjsip show endpoints"
asterisk -rx "core show channels"
- Calls register on Kamailio but fail to connect — the
dispatcherhas no healthy Asterisk targets, or the Record-Route/loose-routing isn't set so in-dialog requests bypass Kamailio and hit NAT. - One-way / no audio — RTPengine not engaged (
rtpengine_manage()not called in the right routes), or Asterisk'sexternal_media_addresswrong. Media is the usual culprit, not signalling. - Kamailio out of memory under load — shared memory (
-m) or package memory (-M) too small; transactions/dialogs accumulating (TM/dialog timers). - Asterisk box maxed at a few hundred calls — that's expected; add boxes and let Kamailio's dispatcher spread the load. If one call = 100% of a core, it's transcoding — align codecs end to end.
- Trying to do an IVR in Kamailio — wrong tool. Route the call to Asterisk
(or an
rtpengine+ media server) for anything that plays or records audio. - Registration storms after a restart — Kamailio
pike/htablerate limiting, and randomised re-REGISTER timers on the clients.
Related tools and reading¶
- On-site: Port Checker (5060), Ping test.
- Related posts: RTPengine for NAT and transcoding, Your first Asterisk dialplan.
Stuck on something this site can't fix?Reach out to Prabath directly on LinkedIn.More in Telecom Systems
SMSC Basics for Sysadmins
The SMSC is the store-and-forward hub for text messages. Here's the message paths (MO, MT, AO, AT), how retries work, and a Kannel config to get started.
October 24, 2026eSIM and Remote SIM Provisioning
An eSIM is a reprogrammable chip (eUICC) that holds downloadable operator profiles. Here's the GSMA RSP architecture — SM-DP+, SM-DS, LPA — and the profile lifecycle.
October 24, 2026SIP Trunk Basics for Sysadmins
A sysadmin's view of SIP trunking — signalling vs media, the ports involved, and why one-way audio is almost always NAT.
October 24, 2026