---
title: Connect OpenSIPS to TelecomsXchange
url: https://help.telecomsxchange.com/integrations/opensips/
audience: Integrations
summary: 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.
updated: '2026-10-23'
verified_commit: 83b4ebc96d0081a25213776d5a8871bd04941125
---

# Connect OpenSIPS to TelecomsXchange

> 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 OpenSIPS**: drouting gateway, identified by IP
2. **TelecomsXchange** (via `80039#447700900123`): sip01, UDP 5060
3. **Seller's route**: The route you purchased

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](https://help.telecomsxchange.com/integrations/connect-sip-platforms/).

!!! 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](https://help.telecomsxchange.com/buyers/create-your-first-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](https://help.telecomsxchange.com/buyers/find-and-buy-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](https://help.telecomsxchange.com/sellers/add-your-first-route/) with **IP Address:Port** set to OpenSIPS, for example `203.0.113.10:5060`, and the values in [Interconnect Info](https://help.telecomsxchange.com/sellers/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');
```

2. 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")
```

3. 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](https://help.telecomsxchange.com/buyers/routing-groups-and-route-testing/) 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');
```

3. 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

- [OpenSIPS drouting module](https://docs.opensips.org/docs/modules/3.6.x/drouting.html)
- [OpenSIPS dispatcher module](https://docs.opensips.org/docs/modules/3.6.x/dispatcher.html)
- [OpenSIPS uac module](https://docs.opensips.org/docs/modules/3.6.x/uac.html)
- [OpenSIPS uac_auth module](https://docs.opensips.org/docs/modules/3.6.x/uac_auth.html)
- [OpenSIPS permissions module](https://docs.opensips.org/docs/modules/3.6.x/permissions.html)

## Frequently asked questions

**Q: Can OpenSIPS register to TelecomsXchange?**

A: 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().

**Q: Should I use drouting or dispatcher?**

A: 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.

**Q: Which realm goes in the uac_auth credential?**

A: 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.

**Q: Which OpenSIPS version is this for?**

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