Back to Blog
KamailioSBCSecurityTLS/SRTPSTIR/SHAKENDDoS ProtectionTopology Hiding

Configuring Kamailio as anEnterprise Session Border Controller

Full Kamailio SBC setup: topology hiding, codec negotiation via rtpengine, TLS/SRTP enforcement, rate limiting, IP allowlisting, and STIR/SHAKEN attestation for production enterprise deployments.

Topology

Hide internal IPs

TLS+SRTP

Full encryption

30 req/2s

Pike rate limit

STIR

Call attestation

By Kaushik Parmar · Founder & VoIP Architect, CelloIP Technologies · January 8, 2026 · 17 min read

What does a Kamailio SBC do and how do you configure it?

A Kamailio SBC performs topology hiding (masking internal IPs), enforces TLS/SRTP security, rate-limits SIP traffic to prevent DDoS, normalises SDP, and handles STIR/SHAKEN call attestation at the network boundary.

What Is a Session Border Controller?

An SBC sits at the network boundary between your trusted VoIP infrastructure and the public internet or SIP carrier. Kamailio + rtpengine is the most widely deployed open-source SBC stack in carrier and enterprise environments.

Topology Hiding

Masks internal IP addresses from external parties

TLS + SRTP

Enforces encrypted signalling and media at the border

Rate Limiting

Protects against SIP flooding and dictionary attacks

SDP Normalisation

Translates between incompatible endpoints (NAT, codecs)

STIR/SHAKEN

Regulatory call authentication to combat robocall spoofing

Topology Routing

Route calls to correct internal servers based on policy

Topology Hiding

What Gets Hidden

Via headers (internal SIP hops)
Record-Route headers (internal proxies)
Contact URI (internal Asterisk IP)
SDP connection lines (internal RTP IP)
Call-ID obfuscation (optional)

What External Parties See

Only Kamailio's public IP address
SBC-generated Via and Route headers
SBC's IP in SDP connection lines
Opaque Call-ID (masked original)
Zero internal infrastructure information
ckamailio.cfg — topology hiding module setup
# Load modules
loadmodule "topoh.so"

# Topology hiding parameters
modparam("topoh", "mask_key", "a_very_secret_key_32chars_long!!")
modparam("topoh", "mask_ip", "203.0.113.10")  # Your SBC public IP
modparam("topoh", "mask_callid", 1)           # Also obfuscate Call-IDs

# In request_route — apply for INVITE and all non-ACK requests:
route[TOPOLOGY_HIDE] {
    if (!topology_hiding()) {
        xlog("L_WARN", "Topology hiding failed for $ci\n");
    }
}

Rate Limiting & DDoS Protection

SIP flooding is the most common attack against public-facing SIP infrastructure. Without rate limiting, a basic UDP flood can exhaust your server in seconds.

ckamailio.cfg — pike-based rate limiting + iptables blocking
loadmodule "pike.so"
modparam("pike", "sampling_time_unit", 2)
modparam("pike", "reqs_density_per_unit", 30)  # 30 req/2sec max per IP
modparam("pike", "remove_latency", 120)         # unblock after 120s

route[DOS_PROTECT] {
    if (!pike_check_req()) {
        xlog("L_ALERT","DoS from $si — blocking\n");
        # Kernel-level block — stops flood before reaching Kamailio
        exec_cmd("iptables -A INPUT -s $si -j DROP &");
        sl_send_reply(503, "Flood Detected");
        exit;
    }
}

# IP allowlist — skip rate limiting for trusted carrier IPs
route[ALLOWLIST_CHECK] {
    if (src_ip == "1.2.3.4" || src_ip == "5.6.7.8") {
        return; # trusted carrier, skip DOS_PROTECT
    }
    route(DOS_PROTECT);
}

TLS Signalling + SRTP via rtpengine

External Leg (Public Internet)

TLS 1.3 SIP signalling (:5061)
DTLS-SRTP media (WebRTC clients)
SRTP AES-128/256 (SIP clients)
Certificate from Let's Encrypt
ICE for WebRTC NAT traversal

Internal Leg (Trusted Network)

Plain SIP UDP/TCP (:5060)
Plain RTP media
No encryption overhead
Direct Asterisk/FreeSWITCH access
Firewall restricts to internal VLAN
ckamailio.cfg — rtpengine with external SRTP enforcement
modparam("rtpengine", "rtpengine_sock", "udp:127.0.0.1:22222")

route[RTPENGINE] {
    if (is_method("INVITE") || is_method("ACK")) {
        # External (SRTP) → Internal (RTP) bridge
        rtpengine_manage(
          "replace-origin replace-session-connection SRTP",  # external leg
          "replace-origin replace-session-connection RTP"   # internal leg
        );
    }
}

STIR/SHAKEN: Call Authentication

What STIR/SHAKEN Does

Signs outbound INVITEs with JWT in Identity header
Verifies inbound calls against public cert repository
A-attestation: carrier fully verified the caller
B-attestation: carrier knows subscriber, not call origin
C-attestation: carrier cannot verify (foreign call)
Unsigned calls labelled 'Spam?' by downstream carriers

Compliance Timeline

2021: US FCC mandate for carriers 100+ employees
2023: Extended to all US voice service providers
2025–2026: European SHAKEN rollout in progress
2026: UK Ofcom framework expected

Kamailio vs Commercial SBC Solutions

FeatureKamailioOracle ACMERibbon
Topology hiding✅ Full (topoh module)✅ Full✅ Full
SRTP/TLS enforcement✅ rtpengine + TLS✅ Full✅ Full
STIR/SHAKEN✅ stirshaken module✅ Full✅ Full
Hardware appliance❌ Software only✅ Physical/virtual✅ Physical/virtual
GUI admin⚠️ Kamctl CLI only✅ Full GUI✅ Full GUI
Vendor SLA support⚠️ Community + CelloIP✅ Enterprise SLA✅ Enterprise SLA
Cost (1,000 sessions)✅ ~$0 licence❌ $50k+/yr❌ $30k+/yr
Customisability✅ Full source access❌ Black box❌ Black box

Frequently Asked Questions

QDo I need an SBC if I use a cloud SIP provider?

Not always for small deployments. But for enterprise environments with 50+ extensions, an SBC provides critical security, topology hiding, and policy enforcement that cloud SIP providers cannot offer on their shared infrastructure.

QCan Kamailio replace a commercial SBC?

For most enterprise use cases, yes. Commercial SBCs offer hardware appliances and vendor SLAs. Kamailio with professional configuration matches their functionality at a fraction of the cost — often saving $30k–$100k in annual licensing.

QWhat is the difference between Kamailio and OpenSIPS for SBC?

Both serve as SBC. Kamailio has broader module coverage for security and carrier features. OpenSIPS has a more approachable scripting language. CelloIP uses both depending on existing infrastructure and team familiarity.

QIs STIR/SHAKEN mandatory?

In the US, FCC mandated STIR/SHAKEN for carriers with 100+ employees since 2021. European equivalents are being rolled out in 2025–2026. Compliance avoids call labelling as 'potential spam' by carriers.

Enterprise SBC Deployment

CelloIP Technologies designs and deploys Kamailio SBC solutions for enterprise and carrier environments — replacing $50k+/year commercial SBCs with fully customised, open-source alternatives.