A dockerized lab environment that simulates a telco SIP setup using Kamailio 5.6 with MySQL-backed authentication and user location, plus prefix-based dispatcher routing with failover. Intended as a teaching / lab playground, not a production deployment.
- Kamailio 5.6 SIP server (container, host networking). Listens on TCP and
UDP, on
127.0.0.1:5060and<your_public_ip>:5060. - MySQL 8.0.33 (container). Exposes port
3399on the host. Schema name:kamailio_telco_simulator. - Dispatcher routes calls by phone-number prefix to backend SIP servers,
with automatic failover. Group 4 in the example config handles prefix
19002098*and forwards to a LiveKit backend.
simulator-telco/
├── kamailio/
│ ├── kamailio.cfg # Main Kamailio config (custom routing + dispatcher)
│ ├── kamctlrc # kamctl/kamdbctl runtime config
│ ├── dispatcher.list # Dispatcher backend list
│ ├── docker-compose.yaml # Run Kamailio
│ └── docker-compose-create-db.yaml # One-shot: wait for MySQL, create schema, then start Kamailio
└── mysql-setup/
└── docker-compose.yaml # Run MySQL on port 3399
- Docker Engine and Docker Compose v2.
- A Linux host. Both Compose files use
network_mode: host, which is only fully supported on Linux. On Windows or macOS run inside a Linux VM.
- Edit configuration first. The repo ships with placeholders that will not work as-is. See Configuration below.
- Start MySQL:
cd mysql-setup docker compose up -d - Create the Kamailio schema (one-shot — it waits for MySQL, runs
kamdbctl create, then starts Kamailio in foreground):When the schema is created, stop this container withcd ../kamailio docker compose -f docker-compose-create-db.yaml upCtrl+C. - Start Kamailio normally:
docker compose up -d
- Add a SIP user (example):
docker exec -it kamailio kamctl add alice secretpass
You must replace the placeholders below before deploying. The values must stay consistent across the listed files.
| Placeholder | Replace with | Files |
|---|---|---|
your_password |
A real strong DB password | kamailio/kamailio.cfg, kamailio/kamctlrc, kamailio/docker-compose-create-db.yaml, mysql-setup/docker-compose.yaml |
your_public_ip |
The host's public IPv4 | kamailio/kamailio.cfg (in listen= directives and the LiveKit dispatcher target comment) |
Other values you may want to change:
SIP_DOMAINand thealias=directive — currentlysimulator.bytebuffer.co.- Dispatcher backends — edit
kamailio/dispatcher.listand theroute[ROUTING_DISPATCH]block inkamailio/kamailio.cfg. - DB port
3399— change in bothmysql-setup/docker-compose.yamland theDBURL/DBPORTsettings inkamailio.cfgandkamctlrc.
route[ROUTING_DISPATCH]— selects a backend via thedispatchermodule. In the shipped config, requests with a prefix matching19002098*are dispatched to group 4 in round-robin order, witht_on_failure("2")armed for failover.onreply_route[1]— sets flag 15 on incoming1xx/2xxreplies so the failure route knows the backend already responded and failover should be suppressed.failure_route[2]— on a 3xx/4xx/5xx/6xx upstream failure, callsds_next_dst()to try the next backend. When the dispatcher list is exhausted it returns503 Service Unavailableto the caller.
Other custom tweaks vs. the upstream 5.6 default config:
WITH_MYSQL,WITH_AUTH,WITH_USRLOCDBenabled.tmfr_timerlowered from 30 s to 3 s for faster failover.tmlocal_ack_modeset to 1.
- Placeholders
your_passwordandyour_public_ipare not valid values. Replace them before starting the services. dispatcher.listonly ships group 1 (sip:127.0.0.1:5060). Group 4 referenced byroute[ROUTING_DISPATCH]is not populated — add your backend(s) there before dispatcher routing will actually work.- The aggressive 3 s
fr_timeris suited to fast on-LAN backends; raise it if your upstream is slower. mysql-setup/mysql/is the MySQL data volume and is git-ignored. Deleting it wipes all users/registrations.
No license has been declared yet. Add a LICENSE file before any public reuse.