Help Center
All integration guides

Connect Kamailio to TelecomsXchange

Guide 4 of 284-minute readUpdated 23 October 2026

In short: Put sip:sip01.telecomsxchange.com:5060 in a dispatcher set, rewrite the Request-URI user to TECH_PREFIX plus the E.164 number, and relay. Authorise Kamailio's public IP on the account, or answer 401/407 in a failure route with uac_auth() and the VoIP login. Accept inbound calls with allow_source_address() for 174.136.44.213.

Kamailio to a purchased route
  1. Your Kamailiodispatcher set, identified by IP
  2. then, 80039#447700900123, TelecomsXchangesip01, UDP 5060
  3. Seller's routeThe route you purchased
On this page
  1. Before you start
  2. How do I send calls to TelecomsXchange?
  3. How do I receive calls from TelecomsXchange?
  4. How do I receive calls on numbers I bought?
  5. How do I test it?
  6. What if something goes wrong?
  7. References
  8. Common questions

Kamailio usually sits in front of your media servers as an SBC or routing proxy. This guide sends calls from it to TelecomsXchange and accepts TelecomsXchange's calls for routes you sell or numbers you bought. For every TelecomsXchange value in one place, see Connect a SIP platform.

Warning

TelecomsXchange does not accept SIP REGISTER. Don't use uac_reg for it. Kamailio is recognised by its source IP or by digest authentication on the INVITE.

Before you start#

  • A SIP account with Kamailio's public IP, for example 203.0.113.10, or a VoIP login and password from Edit Account → Add SIP Digest Auth.
  • A purchased route and its tech prefix from My Interconnections, for example 80039#.
  • Kamailio with the tm, dispatcher, permissions and uac modules available.
  • To sell: a route with IP Address:Port set to Kamailio, for example 203.0.113.10:5060, and the values in Interconnect Info.

How do I send calls to TelecomsXchange?#

  1. Add TelecomsXchange as dispatcher set 1, and your own media servers as set 2 for inbound calls:
Text
# /etc/kamailio/dispatcher.list
# setid  destination
1 sip:sip01.telecomsxchange.com:5060
2 sip:10.0.0.21:5060
  1. Load the modules and set their parameters in kamailio.cfg:
Text
loadmodule "dispatcher.so"
loadmodule "permissions.so"
loadmodule "uac.so"

modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list")
modparam("permissions", "address_file", "address.list")   # next to kamailio.cfg
# digest credentials are read from these AVPs in the failure route
modparam("uac", "auth_username_avp", "$avp(auser)")
modparam("uac", "auth_password_avp", "$avp(apass)")
modparam("uac", "auth_realm_avp", "$avp(arealm)")
  1. Rewrite the number and relay. 80039# is the TECH_PREFIX from My Interconnections:
Text
route[TO_TCXC] {
    # strip + or 00 so the number is plain E.164
    if ($(rU{s.substr,0,1}) == "+") {
        $rU = $(rU{s.substr,1,0});
    } else if ($(rU{s.substr,0,2}) == "00") {
        $rU = $(rU{s.substr,2,0});
    }
    $rU = "80039#" + $rU;              # TECH_PREFIX + E.164
    if (!ds_select_dst("1", "4")) {
        send_reply("503", "TelecomsXchange unavailable");
        exit;
    }
    t_on_failure("TCXC_AUTH");
    route(RELAY);
    exit;
}

failure_route[TCXC_AUTH] {
    if (t_is_canceled()) exit;
    # digest variant: answer TCXC's challenge with the account's VoIP login
    if (t_check_status("401|407")) {
        $avp(auser) = "VOIP_LOGIN";
        $avp(apass) = "VOIP_PASSWORD";
        $avp(arealm) = $null;          # empty: use the realm from the challenge
        if (uac_auth()) {
            t_relay();
        }
        exit;
    }
}

Call route(TO_TCXC) from request_route for the INVITEs your customers send to international numbers, after your own authentication of those customers.

With IP authentication only, TelecomsXchange doesn't challenge and the failure route is never used for auth; keep it anyway, so adding a VoIP login later needs no script change.

Tip

sip01 is a single host, so set 1 has one destination. To fail over between purchased routes, dial a routing group prefix such as 444101# and let TelecomsXchange pick the route.

How do I receive calls from TelecomsXchange?#

Calls on routes you sell, and on numbers you bought, come from 174.136.44.213 over UDP, from source ports 5060 to 5072, with the number in E.164 format such as 14165551234.

  1. Allow 174.136.44.213 on your firewall for UDP 5060.
  2. Add it to the permissions address file as group 10:
Text
# /etc/kamailio/address.list
# group  address         mask  port  tag
10 174.136.44.213 32 0 tcxc
  1. Near the top of request_route, before your customer authentication, send TelecomsXchange's INVITEs to your media servers:
Text
if (is_method("INVITE") && allow_source_address("10")) {
    # route sold: E.164 number in $rU, e.g. 14165551234
    if (!ds_select_dst("2", "4")) {
        send_reply("503", "No media server");
        exit;
    }
    route(RELAY);
    exit;
}
  1. Reload with kamcmd permissions.addressReload and kamcmd dispatcher.reload.

If your route has an Outgoing Prefix or strips digits (Edit Route → Outgoing Number Translation Parameters), expect the number in that format.

How do I receive calls on numbers I bought?#

Set the number's SIP Endpoint (Primary) in DID Settings to Kamailio, for example sip:14165551234@203.0.113.10:5060. The INVITE comes from 174.136.44.213, matches allow_source_address("10"), and goes to your media servers with the number in $rU.

How do I test it?#

  1. Check the configuration: kamailio -c -f /etc/kamailio/kamailio.cfg, then kamcmd dispatcher.list and kamcmd permissions.addressDump.
  2. Start a capture: sngrep port 5060.
  3. Place a call from one of your customers and check the INVITE to sip01 carries 80039#447700900123 (or 80039%23447700900123) and the reply code.
  4. In the portal, watch the call in Live Calls and find its SIP code in Logs → CDR (Voice).

What if something goes wrong?#

You see What to do
401 or 407 passed back to your customer The failure route isn't armed or uac_auth() failed. Check t_on_failure("TCXC_AUTH") runs before the relay, and the VoIP login and password.
403 Forbidden Kamailio's public IP isn't authorised and no valid credentials were sent. Check the source IP in sngrep against IP Address and Additional Allowed IPs; check the account isn't blocked or out of balance.
404 Not Found Missing or wrong tech prefix, or +/00 left in the number. Log $rU before ds_select_dst().
408 Request Timeout No reply from sip01. Check outbound UDP 5060, and that Kamailio resolved the hostname (kamcmd dispatcher.list).
503 Service Unavailable From TelecomsXchange: the route is blocked or failed; check My Interconnections. From Kamailio: the dispatcher set has no active destination.
One-way or no audio Your media servers advertise private IPs. Add rtpengine or set their external address, and open the RTP range.
No inbound calls 174.136.44.213 isn't allowed on the firewall or not in address.list, or the route or number points at the wrong host or port.

References#

Common questions

Can Kamailio register to TelecomsXchange?

No. TelecomsXchange is peering only and does not accept REGISTER, so don't use the uac module's remote registration. Kamailio is recognised by its source IP, or by answering the digest challenge with uac_auth().

Does Kamailio need to handle media?

Kamailio only relays signalling. Media flows between the endpoints in the SDP, so if your media servers are behind NAT, add rtpengine or set their public IP. TelecomsXchange doesn't transcode.

How do I use several purchased routes?

Choose the tech prefix per destination in the script, for example from an htable or a database lookup, or dial a routing group prefix starting with 444 and let TelecomsXchange choose.

Which Kamailio version is this for?

The modules and functions used, dispatcher, permissions and uac, are the same in Kamailio 5.8 and 6.0.

Can Kamailio register to TelecomsXchange?
No. TelecomsXchange is peering only and does not accept REGISTER, so don't use the uac module's remote registration. Kamailio is recognised by its source IP, or by answering the digest challenge with uac_auth().
Does Kamailio need to handle media?
Kamailio only relays signalling. Media flows between the endpoints in the SDP, so if your media servers are behind NAT, add rtpengine or set their public IP. TelecomsXchange doesn't transcode.
How do I use several purchased routes?
Choose the tech prefix per destination in the script, for example from an htable or a database lookup, or dial a routing group prefix starting with 444 and let TelecomsXchange choose.
Which Kamailio version is this for?
The modules and functions used, dispatcher, permissions and uac, are the same in Kamailio 5.8 and 6.0.