# Trunks Trunks let you connect your FlyNumber phone system to external VoIP providers for both incoming and outgoing calls. This gives you control over call routing, which providers handle your calls, and how caller information is displayed. :::important[Enabled on request] The **Trunks** menu isn't shown on a new phone system. [Contact FlyNumber support](https://www.flynumber.com/contact) and we'll have it switched on for your account — activation happens on our side, so allow a little time. Once it's live, **Trunks** appears in the main menu with the three tabs described below. ::: ## Quick Start {#quick-start} Most users need trunks for one of these scenarios. Jump to the one that fits your needs: ### I want to route all outbound calls through my own VoIP provider **Steps:** 1. Go to **Trunks > Termination Gateways** and click **+** 2. Enter your provider's details (host, username, password, port) 3. Save the gateway 4. Go to **Trunks > Termination Routes** and click **+** 5. Create a route with: - **Name**: "All Outbound" - **SRC Prefix**: Leave empty - **DST Prefix**: Leave empty - **Gateway**: Select your new gateway 6. Save and test with a call This catch-all route sends all outbound calls through your provider. ### I want to route calls to specific countries through a different provider **Steps:** 1. Create your termination gateway (if not already done) 2. Go to **Trunks > Termination Routes** and click **+** 3. Create a route with: - **Name**: "UK Calls" (or relevant country) - **SRC Prefix**: Leave empty - **DST Prefix**: "+44" (UK country code, adjust as needed) - **Gateway**: Select your gateway 4. Save and test with a call to that country Calls to numbers starting with +44 will use your gateway; others use the default. ### I want to receive calls from another VoIP provider on my FlyNumber system **Steps:** 1. Go to **Trunks > Inbound Trunks**. A trunk named **Default** already exists; open it with **Actions → Edit**, or click **+** to create another 2. Copy the auto-generated **Domain** shown at the top of the General section (use the copy icon) 3. Add the external provider's number under **Numbers > Phone Numbers** so the phone system recognises calls to it 4. Configure your external provider to send calls to `@` 5. If your provider requires registration, enable it and enter credentials 6. Test by calling the number Your FlyNumber system will receive calls sent to the trunk's domain. --- ## Overview {#overview} ![Trunks interface showing inbound trunk configuration options](/docs/phone-system-guide/main-menu/img/trunks-inbound.png) The Trunks interface has three sections: | Section | Purpose | |---------|---------| | **Inbound Trunks** | Receive calls from external VoIP providers | | **Termination Gateways** | Define connections to outbound VoIP providers | | **Termination Routes** | Control which gateway handles which outbound calls | ### Why Use Custom Trunks? - **Cost Control**: Route calls through cheaper providers for specific destinations - **Provider Flexibility**: Use multiple VoIP providers at once - **Number Portability**: Keep numbers with other providers while using FlyNumber features - **Redundancy**: Set up backup call paths - **Custom Routing**: Route based on caller ID, destination, or both --- ## Inbound Trunks {#inbound-trunks} Inbound trunks let you receive calls from external VoIP providers. Useful when you have phone numbers with other providers that you want to route through your FlyNumber system. ![Inbound trunk configuration options](/docs/phone-system-guide/main-menu/img/trunks-inbound-details.png) ### Creating an Inbound Trunk {#creating-inbound-trunk} 1. Navigate to **Trunks > Inbound Trunks** 2. Click the **+** button 3. Configure settings: | Setting | Description | |---------|-------------| | Domain | Auto-generated — copy it with the icon next to the field and give it to your provider. New trunks include the region you pick (see POP) in the domain | | Friendly Name | Name shown in the list (e.g., "External Provider Trunk") | | Transport Protocol | UDP, TCP or TLS | | POP | Which of the two points of presence handles the trunk's calls: **FRA** (Frankfurt, default) or **NYC** (New York). Changing it changes the domain, so update your provider afterwards | | Lookup destination by | How the called number is read from the incoming call: **R-URI username part** (typical) or **To header username part** | | Allowed Codecs | OPUS, G722, PCMU, PCMA, G729, GSM, telephone-event — drag to set priority (left-most first). Keep **telephone-event** so key presses reach voice menus and feature codes | Numbers that reach you through an inbound trunk must also be added under [Numbers > Phone Numbers](./numbers) — otherwise the phone system can't match the incoming call to a Phone Number module. ### Registration (If Required) {#inbound-registration} Some providers require your trunk to register with them (registration is off by default): 1. Toggle **Registration** to ON 2. Enter: - **Domain**: Your provider's SIP registrar - **Port**: Usually 5060 — leave empty to use the provider's SRV or A record - **Username** and **Password**: From your provider - **Contact User**: Optional value for the Contact header ### CLI Rules {#inbound-cli-rules} ![CLI rules for inbound trunks](/docs/phone-system-guide/main-menu/img/trunks-inbound-details-2.png) Modify caller information as calls arrive: - **SRC number rule**: a ready-made choice to **Remove +** or **Add +** on the caller's number - **SRC Name Rewrite Rule / Result**: change caller names (e.g., add an "External: " prefix) - **DST Rewrite Rule / Result**: reformat the called number (e.g., strip country codes) The rewrite rules use POSIX Regular Expressions. See [Understanding Regular Expressions](#regex) below. --- ## Termination Gateways {#termination-gateways} Termination gateways connect your system to external providers for **outbound** calls. A FlyNumber-managed gateway is already there and carries your outbound calls by default; it shows a padlock and can't be edited or deleted. Add a gateway only when you want a third-party provider or custom routing. ![Termination Gateways interface](/docs/phone-system-guide/main-menu/img/trunks-termination.png) ### Creating a Termination Gateway {#creating-termination-gateway} 1. Navigate to **Trunks > Termination Gateways** 2. Click the **+** button 3. Configure settings: ![Creating a termination gateway](/docs/phone-system-guide/main-menu/img/trunks-termination-create.png) | Setting | Description | Example | |---------|-------------|---------| | Name | Friendly name | "Main Provider" | | Network Protocol | IPv4 Only (usual), IPv6 Only, Dualstack, IPv4 Preferred or IPv6 Preferred | IPv4 Only | | Transport Protocol | UDP, TCP or TLS | UDP | | Username | Auth username from provider | your_username | | Password | Auth password from provider | ••••••• | | Host | Provider's SIP server | sip.provider.com | | Port | Connection port (5060 if left empty) | 5060 (UDP/TCP) or 5061 (TLS) | | Allowed Codecs | OPUS, G722, PCMU, PCMA, G729, GSM, telephone-event — drag to set priority | OPUS, G722, PCMU | :::tip[Codec Selection] - **OPUS**: Highest quality, more bandwidth - **G722**: HD voice quality - **PCMU/PCMA**: Standard quality, widely supported - **G729**: Lower bandwidth, slightly lower quality - Always include **telephone-event** for DTMF tones ::: ### CLI Rules for Gateways {#termination-gateway-cli-rules} | Rule | Purpose | |------|---------| | SRC Rewrite | Modify outbound caller ID | | DST Rewrite | Reformat destination number | Useful for adding/removing country codes or presenting specific caller IDs. --- ## Termination Routes {#termination-routes} Routes determine **which gateway** handles each outbound call based on number patterns. :::warning[Key Point] Creating a gateway isn't enough—you must also create routes that tell the system when to use it. Without routes, calls use the default gateway. ::: ### Creating a Termination Route {#creating-termination-route} 1. Navigate to **Trunks > Termination Routes** 2. Click the **+** button 3. Configure settings: ![Creating a termination route](/docs/phone-system-guide/main-menu/img/trunks-termination-route-create.png) | Setting | Description | |---------|-------------| | Name | Friendly name (e.g., "International Calls") | | SRC Prefix | Match calls FROM numbers starting with this (optional) | | DST Prefix | Match calls TO numbers starting with this (optional) | | Gateway | Which gateway to use | ### Route Priority {#route-priority} When several routes could match a call, the one whose prefixes match most closely wins — a longer prefix beats a shorter one (+44207 beats +44, which beats an empty prefix). An empty SRC or DST prefix means "any". If no custom route matches, the call uses the FlyNumber-managed default gateway. ### Common Route Configurations {#common-routes} **Route all calls through custom gateway:** - SRC Prefix: (empty) - DST Prefix: (empty) - Gateway: Your custom gateway **Route UK calls through custom gateway:** - SRC Prefix: (empty) - DST Prefix: +44 - Gateway: Your UK provider **Route calls from specific DID:** - SRC Prefix: +15551234567 - DST Prefix: (empty) - Gateway: Your custom gateway --- ## Troubleshooting {#troubleshooting} | Problem | Likely Cause | Solution | |---------|--------------|----------| | Inbound calls never arrive | Number not added under Numbers > Phone Numbers, or provider sending to an old domain after a POP change | Add the number; re-copy the trunk domain and update the provider | | Calls don't connect | Wrong gateway credentials | Verify username/password with provider | | Registration fails | Network/firewall issue | Check connectivity to provider's server | | One-way audio | Codec mismatch or firewall | Try different codecs; open RTP ports | | Wrong caller ID | CLI rules needed | Add SRC Rewrite rule | | Number format rejected | Provider expects different format | Add DST Rewrite to format numbers | --- ## Reference {#reference} ### Understanding Regular Expressions {#regex} CLI rules use POSIX Regular Expressions: | Pattern | Meaning | |---------|---------| | `^` | Start of string | | `$` | End of string | | `.` | Any character | | `\d` | Any digit | | `*` | Zero or more of previous | | `+` | One or more of previous | | `()` | Capture group | | `\1` | First captured group (in replacement) | **Example**: Add "+1" to 10-digit US numbers: - Pattern: `^(\d{10})$` - Replacement: `+1\1` ### Inbound Trunk Use Cases {#inbound-uses} | Use Case | Description | |----------|-------------| | Multi-Provider Integration | Route numbers from various providers to one system | | Legacy Migration | Gradually move from old phone systems | | Geographic Presence | Maintain local numbers from different regions | | Redundancy | Backup call paths for reliability | ### Outbound Route Use Cases {#outbound-uses} | Use Case | How to Configure | |----------|------------------| | Cost Savings | Route by destination country to cheapest providers | | Quality Control | Premium gateway for important calls | | Local Presence | Present local caller IDs per region | | Failover | Multiple routes to different gateways | --- ## Getting Help {#getting-help} If you need assistance: 1. [Open a support ticket](https://www.flynumber.com/contact) with FlyNumber 2. Have your provider's documentation ready 3. Include (non-sensitive) details about your setup :::tip Some VoIP providers have specific FlyNumber integration guides—ask your provider if one is available. :::