Regional SIP gateway between ElevenLabs and customer SBCs — static IP, in-country presence, media anchoring.
graph LR
LK[ElevenLabs SIP] -.->|"❌ Dynamic IPs<br/>❌ Outside country<br/>❌ No FQDN support"| SBC[Customer SBC]
style LK fill:#fee,stroke:#c33
style SBC fill:#fee,stroke:#c33
| Issue | Impact |
|---|---|
| SIP server IPs are dynamic | Legacy SBCs (Five9, etc.) can't whitelist |
| SIP INVITE originates outside country | Blocked by local telecom regulators (e.g., Turkey) |
| SBC requires IP, not FQDN | Direct connection impossible |
graph LR
LK[ElevenLabs SIP] -->|TCP 5060| GW["<b>SIP Gateway</b><br/>Static IP • In-Region"]
GW -->|SIP + RTP| SBC[Customer SBC / Twilio]
style GW fill:#dfd,stroke:#0a0,stroke-width:2px
Deploy a lightweight SIP gateway in any region. It provides a fixed IP, in-country presence, and media anchoring — all RTP audio flows through it.
|
Stateful SIP proxy with dedicated media relay.
|
Full Back-to-Back User Agent (PBX engine).
|
| Kamailio + RTPEngine | Asterisk B2BUA | |
|---|---|---|
| Latency | ~2ms | ~10-20ms |
| Max concurrent calls | 1000+ | 50-100 |
| Header passthrough | Automatic | Explicit mapping |
| Codec transcoding | ✗ | ✓ |
| IVR / call logic | ✗ | ✓ |
| SIP dialog | Preserved (proxy) | Re-originated (B2BUA) |
| Config complexity | ~150 lines | ~200 lines |
flowchart TD
A{"Need transcoding, IVR,<br/>or recording at gateway?"} -->|Yes| B["<b>Asterisk B2BUA</b>"]
A -->|No| C{"Need >100<br/>concurrent calls?"}
C -->|Yes| D["<b>Kamailio + RTPEngine</b>"]
C -->|No| E["Either works — Kamailio<br/>is lighter for pure relay"]
style B fill:#ddf,stroke:#33a
style D fill:#dfd,stroke:#0a0
sequenceDiagram
participant EL as ElevenLabs SIP
participant GW as SIP Gateway
participant SBC as Customer SBC
EL->>GW: INVITE sip:+1234@gateway:5060
Note over GW: Rewrite R-URI → customer SBC<br/>Anchor media (RTPEngine/Asterisk)
GW->>SBC: INVITE sip:+1234@sbc.customer.com
SBC-->>GW: 100 Trying
GW-->>EL: 100 Trying
SBC-->>GW: 180 Ringing
GW-->>EL: 180 Ringing
SBC-->>GW: 200 OK (SDP: SBC media IP)
Note over GW: Rewrite SDP → gateway IP
GW-->>EL: 200 OK (SDP: gateway IP)
EL->>GW: ACK
rect rgb(240, 255, 240)
Note over EL,SBC: 🔊 RTP audio flows through gateway
EL->>GW: RTP (UDP)
GW->>SBC: RTP (UDP)
SBC->>GW: RTP
GW->>EL: RTP
end
SBC->>GW: BYE
GW->>EL: BYE
Kamailio + RTPEngine
cd kamailio-proxy/terraform
cp terraform.tfvars.example terraform.tfvars
# Edit region, zone, project
terraform init && terraform apply
cd ../scripts
./deploy.sh --customer-sbc your-trunk.pstn.twilio.comAsterisk B2BUA
cd asterisk-b2bua
PROJECT_ID=your-project \
TWILIO_TERMINATION_HOST="your-trunk.pstn.twilio.com" \
bash deploy-gcp-middleware.shKamailio + RTPEngine
sudo bash kamailio-proxy/scripts/install-onprem.sh \
--external-ip <PUBLIC_IP> \
--internal-ip <PRIVATE_IP> \
--customer-sbc your-trunk.pstn.twilio.comAsterisk B2BUA
sudo bash asterisk-b2bua/install-onprem.sh \
--twilio-termination-host your-trunk.pstn.twilio.com \
--external-ip <PUBLIC_IP>Both scripts install Docker, write all configs, open firewall ports, and start the stack.
After deploying, configure the outbound trunk:
| Field | Value |
|---|---|
| Address | <gateway-ip> |
| Transport | TCP |
| Auth | Username/password (if enabled) |
| Direction | Configuration |
|---|---|
| Termination (outbound) | Add <gateway-ip>/32 to IP Access Control List |
| Origination (inbound) | Add URI sip:<gateway-ip>:5060;transport=tcp |
| Resource | Minimum |
|---|---|
| OS | Ubuntu 22.04+, Debian 12+, CentOS 8+ |
| CPU | 2 cores |
| RAM | 2 GB |
| Ports | TCP 5060, UDP 5060, UDP 10000-20000 |
| IP | Static public IP (or NAT with port forwarding) |
sip-gateway/
├── kamailio-proxy/ # Kamailio + RTPEngine
│ ├── docker/ # Docker Compose stack
│ ├── terraform/ # GCP infrastructure
│ ├── scripts/ # Deploy + on-prem installer
│ └── README.md
├── asterisk-b2bua/ # Asterisk B2BUA
│ ├── deploy-gcp-middleware.sh # GCP provisioning
│ ├── install-onprem.sh # On-prem installer
│ ├── startup-script.sh # VM bootstrap
│ └── README.md
└── README.md # This file
MIT
Built for ElevenLabs Conversational AI telephony