# TG VoIP 4G Gateway Integration Guide

A TG-series VoIP 4G gateway holds one or more carrier SIM (Subscriber Identity Module) cards and presents each mobile channel to your Cloud Voice hosted PBX as a standard SIP trunk. That lets the phone system place and receive calls over the cellular network, handy for reaching mobile numbers at on-net rates, keeping a fallback path when your SIP carrier is unavailable, or handling calls per carrier. This guide walks through a complete example that connects a TG400 gateway to Cloud Voice and puts its 4G trunks to work.

:::note[Key terms]
- **PBX** (Private Branch Exchange): the phone system that manages your extensions and decides how calls are routed.
- **VoIP** (Voice over Internet Protocol): carrying phone calls as data over an IP network instead of a traditional phone line.
- **SIP** (Session Initiation Protocol): the signaling protocol that sets up and tears down VoIP calls.
- **Trunk**: a connection that carries calls between your PBX and an outside network. Here each SIM card becomes one 4G trunk.
- **4G**: fourth-generation cellular mobile data, the network the gateway's SIM cards connect through.
:::

## How the integration works

The gateway registers to Cloud Voice, and each SIM card it carries becomes a 4G trunk on the PBX. Once a trunk is up, it behaves like any other trunk: outbound routes decide which calls leave over it, and inbound routes decide where its incoming calls land. The gateway simply converts between the mobile network and SIP in both directions.

![Cloud Voice, network diagram of a TG400 4G gateway bridging two carrier SIM cards to the hosted PBX over SIP](/images/pbx/tg-gateway-p-series-cloud.png)

:::danger[Emergency calling over 4G trunks]
Calls placed over a 4G trunk leave through the SIM card's mobile carrier, not your normal SIP carrier, so they do not carry your site's registered E911 (Enhanced 911) location. Do not rely on a 4G trunk as the path for emergency (911) calls. Keep a separate, tested emergency route, and confirm 911 still connects after any routing change.
:::

## Reference environment

Every procedure in this guide refers back to the setup below. Your firmware versions and addresses will differ, but the workflow is the same, substitute your own values wherever they appear.

| Equipment | Firmware version | IP address / domain |
| --- | --- | --- |
| Cloud Voice | 84.10.0.30 | pbx.example.com |
| TG400 4G Gateway | 91.3.0.21 | 192.168.6.200 |

:::note
The gateway sits on the local network with a private IP address (`192.168.6.200` in this example), while Cloud Voice is reached at its domain. The gateway must be able to reach the PBX over the network for its trunks to register and stay up.
:::

The TG400 in this example has two SIM cards installed, one from each of two carriers. The mobile-number prefix of each carrier matters later, because it drives the outbound and inbound routing decisions.

| SIM card | Carrier | Mobile prefix |
| --- | --- | --- |
| SIM card 1 | Carrier A | 92 |
| SIM card 2 | Carrier B | 10 |

:::tip
Note down which SIM sits in which slot and its carrier prefix before you start. The prefixes (`92` and `10` here) are what later routes match on to send same-carrier calls out the matching trunk, and to steer inbound calls to the right destination. Get them straight now and the routing steps go smoothly.
:::

:::caution
The prefixes above are specific to this example's carriers. Use the real prefixes for the SIM cards you install. A mismatched prefix sends calls out the wrong trunk (losing the on-net rate) or delivers inbound calls to the wrong place.
:::

## In this guide

Work through the topics in order. The first brings the gateway and the PBX together; the remaining two use the SIM prefixes above to route calls in each direction.

1. [Connect Cloud Voice and the TG400 Gateway](/pbx/integrations/cloud-voice-tg/connect-cloud-voice-ippbx-and-cloud-voice-tg400-gateway/), register the gateway with the PBX and bring up its 4G trunks.
2. [Make outbound calls through a designated 4G trunk](/pbx/integrations/cloud-voice-tg/make-outbound-alls-through-a-designated-4g-trunk/), send calls out over the trunk that matches the dialed number's carrier so same-network calls stay cheap.
3. [Route calls from different carriers to different destinations](/pbx/integrations/cloud-voice-tg/route-calls-from-different-carriers-to-different-destinations/), deliver incoming calls to different places depending on which carrier's 4G trunk they arrive on.
