Help Center
All integration guides

Connect OpenSIPS to TelecomsXchange

Guide 5 of 284-minute readUpdated 23 October 2026

In short: Add sip01.telecomsxchange.com:5060 as a drouting gateway whose pri_prefix is the route's tech prefix, normalise the number to E.164 and call do_routing(). Authorise OpenSIPS'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 check_source_address() for 174.136.44.213.

OpenSIPS to a purchased route
  1. Your OpenSIPSdrouting gateway, 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

OpenSIPS often fronts a voice network as an SBC or least-cost router. 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_registrant for it. OpenSIPS is recognised by its source IP or by digest authentication on the INVITE.

Before you start#

  • A SIP account with OpenSIPS's public IP, for example 203.0.113.10, or a VoIP login and password from Edit Account → Add SIP Digest Auth.
  • One or more purchased routes and their tech prefixes from My Interconnections, for example 80039#.
  • OpenSIPS 3.x with a database (db_mysql or db_postgres) and the tm, drouting, uac, uac_auth and permissions modules.
  • To sell: a route with IP Address:Port set to OpenSIPS, for example 203.0.113.10:5060, and the values in Interconnect Info.

How do I send calls to TelecomsXchange?#

  1. Add one gateway per purchased route. They share the address and differ in pri_prefix, the tech prefix that drouting puts in front of the number:
SQL
-- type 1 is a label of your choice for TCXC gateways
INSERT INTO dr_gateways (gwid, type, address, strip, pri_prefix, description)
VALUES ('tcxc_80039', 1, 'sip01.telecomsxchange.com:5060', 0, '80039#', 'TCXC route 80039');

-- send UK numbers (44...) in routing group 1 to that gateway
INSERT INTO dr_rules (groupid, prefix, timerec, priority, gwlist, description)
VALUES ('1', '44', '', 0, 'tcxc_80039', 'UK via TCXC');
  1. Load the modules in opensips.cfg:
Text
loadmodule "drouting.so"
loadmodule "uac_auth.so"
loadmodule "uac.so"
loadmodule "permissions.so"

modparam("drouting", "db_url", "mysql://opensips:PASSWORD@localhost/opensips")
modparam("drouting", "use_domain", 0)
modparam("permissions", "db_url", "mysql://opensips:PASSWORD@localhost/opensips")
# digest variant: the account's VoIP login, the realm TCXC challenges with (its platform IP), the VoIP password
modparam("uac_auth", "credential", "VOIP_LOGIN:174.136.44.213:VOIP_PASSWORD")
  1. Normalise the number, route, and handle the challenge:
Text
route[to_tcxc] {
    # strip + or 00 so the rules see plain E.164
    if ($rU =~ "^\+") {
        $rU = $(rU{s.substr,1,0});
    } else if ($rU =~ "^00") {
        $rU = $(rU{s.substr,2,0});
    }
    # do_routing() picks the gateway and prepends its pri_prefix: 80039#447700900123
    if (!do_routing(1)) {
        send_reply(404, "No TCXC route");
        exit;
    }
    t_on_failure("tcxc_auth");
    t_relay();
    exit;
}

failure_route[tcxc_auth] {
    if (t_was_cancelled()) exit;
    if (t_check_status("401|407")) {
        if (uac_auth()) {      # adds Authorization / Proxy-Authorization
            t_relay();
        }
        exit;
    }
}

Call route(to_tcxc) from your main route for INVITEs your customers send to international numbers, after authenticating those customers. Reload rules with opensips-cli -x mi dr_reload.

With IP authentication only, TelecomsXchange doesn't challenge and uac_auth() is never called; leave the credential line out.

Using dispatcher instead. For a single route, put sip:sip01.telecomsxchange.com:5060 in a dispatcher set, set $rU = "80039#" + $rU; after normalising, then ds_select_dst(1, 4) and relay with the same failure route.

Tip

To let TelecomsXchange choose between your routes, make one gateway with pri_prefix set to a routing group prefix such as 444101#.

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 address table as group 10, then run opensips-cli -x mi address_reload:
SQL
INSERT INTO address (grp, ip, mask, port, proto, context_info)
VALUES (10, '174.136.44.213', 32, 0, 'any', 'tcxc');
  1. Near the top of your main route, before customer authentication:
Text
if (is_method("INVITE") && check_source_address(10)) {
    # from TelecomsXchange: E.164 number in $rU, e.g. 14165551234
    # send it to your media servers, here drouting group 2
    if (!do_routing(2)) {
        send_reply(404, "Not here");
        exit;
    }
    t_relay();
    exit;
}

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 OpenSIPS, for example sip:14165551234@203.0.113.10:5060. The INVITE comes from 174.136.44.213, matches check_source_address(10), and is routed by the number in $rU.

How do I test it?#

  1. Check the gateways and addresses are loaded: opensips-cli -x mi dr_gw_status and opensips-cli -x mi address_dump.
  2. Start a capture: sngrep port 5060.
  3. Place a call and check the INVITE to sip01 carries 80039#447700900123 (or 80039%23447700900123) and the reply code. If you see a 401 or 407, note its realm for the credential line.
  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 uac_auth() found no matching credential. Check the credential realm matches the challenge, and the VoIP login and password on Edit Account.
403 Forbidden OpenSIPS's public IP isn't authorised and no valid credentials were sent. Check the source IP against IP Address and Additional Allowed IPs; check the account isn't blocked or out of balance.
404 Not Found from TelecomsXchange Missing or wrong tech prefix, or +/00 left in the number. Check pri_prefix and strip on the gateway.
404 No TCXC route from OpenSIPS No dr_rules prefix matched the number. Add a rule or reload with dr_reload.
408 Request Timeout No reply from sip01. Check outbound UDP 5060 and DNS on the server.
503 Service Unavailable The route is blocked or failed on the seller's side. Check My Interconnections; try another route or a routing group.
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 the address table, or the route or number points at the wrong host or port.

References#

Common questions

Can OpenSIPS register to TelecomsXchange?

No. TelecomsXchange is peering only and does not accept REGISTER, so don't use uac_registrant for it. OpenSIPS is recognised by its source IP, or by answering the digest challenge with uac_auth().

Should I use drouting or dispatcher?

drouting, if you buy several TelecomsXchange routes: each route becomes a gateway with its own pri_prefix, and rules pick it by destination prefix. dispatcher works for a single route, with the tech prefix added in the script.

Which realm goes in the uac_auth credential?

TelecomsXchange challenges with its platform IP as the realm: 174.136.44.213, the address sip01.telecomsxchange.com resolves to. If you send through another TelecomsXchange address, copy the realm from one captured challenge.

Which OpenSIPS version is this for?

OpenSIPS 3.x. The examples follow the 3.6 module documentation; drouting, uac, uac_auth and permissions work the same way in 3.4.

Can OpenSIPS register to TelecomsXchange?
No. TelecomsXchange is peering only and does not accept REGISTER, so don't use uac_registrant for it. OpenSIPS is recognised by its source IP, or by answering the digest challenge with uac_auth().
Should I use drouting or dispatcher?
drouting, if you buy several TelecomsXchange routes: each route becomes a gateway with its own pri_prefix, and rules pick it by destination prefix. dispatcher works for a single route, with the tech prefix added in the script.
Which realm goes in the uac_auth credential?
TelecomsXchange challenges with its platform IP as the realm: 174.136.44.213, the address sip01.telecomsxchange.com resolves to. If you send through another TelecomsXchange address, copy the realm from one captured challenge.
Which OpenSIPS version is this for?
OpenSIPS 3.x. The examples follow the 3.6 module documentation; drouting, uac, uac_auth and permissions work the same way in 3.4.