---
title: Connect Asterisk to TelecomsXchange
url: https://help.telecomsxchange.com/integrations/asterisk/
audience: Integrations
summary: Create a PJSIP endpoint, aor and identify for sip01.telecomsxchange.com on
  UDP 5060 with no registration, matching 174.136.44.213 for inbound. Authorise your
  public IP on the TelecomsXchange account or add an outbound_auth with the VoIP login,
  and dial PJSIP/TECH_PREFIX + E.164 number.
updated: '2026-10-23'
verified_commit: 83b4ebc96d0081a25213776d5a8871bd04941125
---

# Connect Asterisk to TelecomsXchange

> Create a PJSIP endpoint, aor and identify for sip01.telecomsxchange.com on UDP 5060 with no registration, matching 174.136.44.213 for inbound. Authorise your public IP on the TelecomsXchange account or add an outbound_auth with the VoIP login, and dial PJSIP/TECH_PREFIX + E.164 number.

## Asterisk to a purchased route

1. **Your Asterisk**: PJSIP endpoint, identified by IP
2. **TelecomsXchange** (via `80039#447700900123`): sip01, UDP 5060
3. **Seller's route**: The route you purchased

This guide connects Asterisk's PJSIP channel driver to TelecomsXchange: outbound calls to a purchased route, and inbound calls on routes you sell or numbers you bought. For the full list of TelecomsXchange values, see [Connect a SIP platform](https://help.telecomsxchange.com/integrations/connect-sip-platforms/).

!!! warning
    TelecomsXchange does not accept SIP REGISTER. Don't create a `type=registration` section for it. Asterisk 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 Asterisk'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](https://help.telecomsxchange.com/buyers/find-and-buy-routes/) and its tech prefix from **My Interconnections**, for example `80039#`.
- Asterisk 20 or 22 with `res_pjsip` loaded, and a public IP (or a known NAT address).
- To sell: a [route](https://help.telecomsxchange.com/sellers/add-your-first-route/) with **IP Address:Port** set to your Asterisk, 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 a UDP transport, if you don't already have one. Behind NAT, set the external addresses so the SDP carries your public IP:

```ini
; /etc/asterisk/pjsip.conf
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060
; only behind NAT: your public IP and your private network
external_media_address=203.0.113.10
external_signaling_address=203.0.113.10
local_net=10.0.0.0/8
```

2. Add the TelecomsXchange trunk. There is no registration section:

```ini
; /etc/asterisk/pjsip.conf
[tcxc]
type=aor
contact=sip:sip01.telecomsxchange.com:5060

[tcxc]
type=endpoint
transport=transport-udp
aors=tcxc
context=from-tcxc            ; inbound calls from TelecomsXchange land here
disallow=all
allow=g729,ulaw,alaw         ; TCXC passes codecs through: offer what the route supports
direct_media=no
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
;outbound_auth=tcxc-auth     ; uncomment for digest authentication (below)

[tcxc]
type=identify
endpoint=tcxc
match=174.136.44.213         ; TelecomsXchange platform IP (sip01 resolves to it)
```

3. Add the dial plan. `TECH_PREFIX` is the route's prefix from **My Interconnections**; Asterisk dials it in front of the E.164 number:

```ini
; /etc/asterisk/extensions.conf
[globals]
TECH_PREFIX=80039#

[to-tcxc]
; 00 + international number
exten => _00X.,1,Dial(PJSIP/${TECH_PREFIX}${EXTEN:2}@tcxc,60)
 same => n,Hangup()
; international number without 00, e.g. 447700900123
exten => _[1-9]X.,1,Dial(PJSIP/${TECH_PREFIX}${EXTEN}@tcxc,60)
 same => n,Hangup()
```

Include `to-tcxc` in the context your phones or customers dial from, then run `core reload` (or `module reload res_pjsip.so` and `dialplan reload`).

**Digest variant.** If you send from an IP that isn't on the account, use the account's VoIP login and password. Asterisk answers TelecomsXchange's 401 or 407 challenge with them:

```ini
; /etc/asterisk/pjsip.conf
[tcxc-auth]
type=auth
auth_type=userpass
username=VOIP_LOGIN          ; Edit Account → VoIP Login
password=VOIP_PASSWORD       ; Edit Account → VoIP Password
```

Then uncomment `outbound_auth=tcxc-auth` on the `tcxc` endpoint.

!!! tip
    To pick routes per destination, use one `TECH_PREFIX` variable per route, or dial a [routing group](https://help.telecomsxchange.com/buyers/routing-groups-and-route-testing/) prefix such as `444101#` and let TelecomsXchange choose.

## 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, and open your RTP range (`rtp.conf`, by default 10000 to 20000).
2. The `identify` section above maps that IP to the `tcxc` endpoint, so calls enter the `from-tcxc` context. Route them there:

```ini
; /etc/asterisk/extensions.conf
[from-tcxc]
; number you bought, delivered to sip:14165551234@203.0.113.10:5060
exten => 14165551234,1,Dial(PJSIP/reception,30)
 same => n,Hangup()
; seller route: send everything on to your own carrier or gateway
exten => _X.,1,Dial(PJSIP/${EXTEN}@my-upstream,60)
 same => n,Hangup()
```

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

!!! warning
    Keep `from-tcxc` separate from the context your phones use. Only calls matched by `identify` should reach it; unmatched INVITEs are challenged or rejected, unless you have defined an `anonymous` endpoint.

## How do I receive calls on numbers I bought?

Set the number's **SIP Endpoint (Primary)** in **DID Settings** to your Asterisk, for example `sip:14165551234@203.0.113.10:5060`. TelecomsXchange sends the INVITE from `174.136.44.213`, which the `identify` section matches, so the call arrives in `from-tcxc` with `${EXTEN}` set to the user part.

## How do I test it?

1. In the Asterisk CLI, turn on SIP logging: `pjsip set logger on`. Check the trunk with `pjsip show endpoint tcxc`.
2. Place a test call, for example `channel originate Local/447700900123@to-tcxc application Playback demo-congrats`.
3. In the log, look for the INVITE to `80039#447700900123` (or `80039%23447700900123`) and the reply. On the shell, `sngrep port 5060` shows the same flow as a ladder.
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 repeated, then the call fails | Asterisk isn't answering the challenge. Add the `tcxc-auth` section, set `outbound_auth=tcxc-auth`, and check the VoIP login and password on **Edit Account**. |
| 403 Forbidden | Asterisk's public IP isn't authorised and no credentials were sent. Compare the IP in `pjsip set logger` with the account's **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. Check `TECH_PREFIX` and the Request-URI in the log. |
| 408 Request Timeout | No reply from sip01. Check outbound UDP 5060 on your firewall and that `sip01.telecomsxchange.com` resolves 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 | Set `external_media_address` and `local_net` on the transport, keep `rtp_symmetric=yes`, and open the RTP range on your firewall. |
| Inbound calls rejected with 401 or 403 | The `identify` doesn't match: check `match=174.136.44.213` with `pjsip show identifies`, and the firewall. |
| Inbound call arrives but goes nowhere | No extension in `from-tcxc` matches the E.164 number; check the number format and any Outgoing Prefix on your route. |

## References

- [Asterisk PJSIP configuration sections and relationships](https://docs.asterisk.org/Configuration/Channel-Drivers/SIP/Configuring-res_pjsip/PJSIP-Configuration-Sections-and-Relationships/)
- [Asterisk res_pjsip configuration reference](https://docs.asterisk.org/Latest_API/API_Documentation/Module_Configuration/res_pjsip/)
- [Configuring res_pjsip to work through NAT](https://docs.asterisk.org/Configuration/Channel-Drivers/SIP/Configuring-res_pjsip/Configuring-res_pjsip-to-work-through-NAT/)
- [Asterisk versions and support lifecycle](https://docs.asterisk.org/About-the-Project/Asterisk-Versions/)

## Frequently asked questions

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

A: No. TelecomsXchange is peering only and does not accept REGISTER, so don't add a registration section. Asterisk is recognised by its source IP, or by answering the digest challenge with outbound_auth.

**Q: Which Asterisk versions does this cover?**

A: The PJSIP configuration shown works on the current long-term-support releases, Asterisk 20 and 22. The legacy chan_sip driver has been removed from Asterisk.

**Q: Do I need a separate endpoint for inbound calls?**

A: No. One endpoint named tcxc can carry both directions: the identify section matches 174.136.44.213 and puts inbound calls in the endpoint's context.

**Q: Where does the tech prefix go?**

A: In the Dial() string, before the number: Dial(PJSIP/80039#447700900123@tcxc). Each purchased route has its own prefix in My Interconnections.
