# FreePBX Configuration - sipgate SIP Trunking

The following guide describes the configuration of a sipgate SIP Trunk on a fresh install of FreePBX. Estimated setup time required: under 20 minutes (excluding download and installation of FreePBX). FreePBX version used in this guide: FreePBX 13; Linux 6.6; Asterisk 13. FreePBX Documentation,

#### Installation & Configuration Guides

* FreePBX download page: <https://www.freepbx.org/downloads/>
* FreePBX Wiki: <https://wiki.freepbx.org/>

You'll need your sipgate SIP Trunk's **SIP-ID** and **SIP Password**. To find these:

* Login to your sipgate account: [https://login.sipgate.com](https://login.sipgate.com/)
* Under the **Trunks** menu in the Navigation bar click on the Trunk you wish to configure
* Scroll down to the **SIP Credentials** section at the bottom of the main page.

Open your computer's browser and enter FreePBX's IP address into your browser's address bar.\
Click on **FreePBX Administration**:

![](https://1449431311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FftdJXe39x3wvuZjiDFLY%2Fuploads%2Fgit-blob-8adb49901657f9b02078758456ffec7ee7f49994%2FFPBX_Console.png?alt=media)

**Remember:**

Submit your changes regularly. Double check your changes before applying them.

#### Add a SIP Trunk

Open **Connectivity** ➔ **Trunks**

![](https://1449431311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FftdJXe39x3wvuZjiDFLY%2Fuploads%2Fgit-blob-5cc677299ac314d0c6557d29dd4cda340919743e%2FAdd_Trunk.png?alt=media)

Click **Add Trunk** ➔ **Add SIP (chan\_sip) TRUNK**

![](https://1449431311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FftdJXe39x3wvuZjiDFLY%2Fuploads%2Fgit-blob-faf34a30d86b1e15d464b6de6542ad0d4a69f9b3%2FAdd_Trunk_2.png?alt=media)

**Add Trunk** ➔ **General**

![](https://1449431311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FftdJXe39x3wvuZjiDFLY%2Fuploads%2Fgit-blob-de3c54e37e671958ca2d81499c2c2259b5adc7a7%2FAdd_Trunk_1.png?alt=media)

**Add Trunk ➔** **sip Settings**

![](https://1449431311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FftdJXe39x3wvuZjiDFLY%2Fuploads%2Fgit-blob-1db819b619be5c734fcc6739e0a64388202cc34d%2FAdd_Trunk_3_Peer_Details.png?alt=media)

**Peer Details**

{% code title="Peer Details" %}

```ini
fromuser=SIPID
username=SIPID
secret=SIP_Password
host=sipconnect.sipgate.co.uk
fromdomain=sipconnect.sipgate.co.uk
port=5060
type=peer
context=from-trunk
insecure=port,invite
canreinvite=no
registertimeout=600
dtmfmode=rfc2833
disallow=all
allow=alaw&ulaw&G729&GSM&G726
```

{% endcode %}

**If your PBX is behind a NAT Firewall add the following to your Peer Details**

{% code title="NAT Firewall Settings" %}

```ini
qualify=yes
keepalive=30
nat=yes
```

{% endcode %}

**Edit Trunk ➔ SIP Settings ➔ Incoming:**

![](https://1449431311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FftdJXe39x3wvuZjiDFLY%2Fuploads%2Fgit-blob-c1010cf578bd65c74dc5e43a2ece037d8effcc53%2FAdd_Trunk_4_Register.png?alt=media)

Your SIP Trunk must be registered online to receive incoming calls.

If you only wish to place outbound calls with your sipgate trunk this step can be skipped.

In the **Incoming** menu, delete any settings already showing/entered and add your **Register String** in the format: **SIP-ID:<SIP_Password@sipconnect.sipgate.co.uk>/SIP-ID**

Click **Submit** followed by **Apply Config** to register your trunk online with sipgate.

After your trunk has registered online successfully, the status in your sipgate account will update to online.

Click Submit followed by Apply Config to register your trunk online with sipgate.

Your Trunk's registration status can also be checked in the FreePBX GUI under:\
**Reports** ➔ **Asterisk Info** ➔ **Registries**

#### Add Outbound Route

**Connectivity ➔ Outbound Routes ➔ Route Settings**

![](https://1449431311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FftdJXe39x3wvuZjiDFLY%2Fuploads%2Fgit-blob-3d41c1887a232d9b525bac929f4e0e44322381f7%2FAdd_Outbound_Route_1.png?alt=media)

**Outbound Routes ➔ Dial Patterns:**

Simplest Dial Pattern - using **X.** will send all dialled digits to sipgate:

![](https://1449431311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FftdJXe39x3wvuZjiDFLY%2Fuploads%2Fgit-blob-5dd7344034367e86d6b7695bbacca60e8ef3f007%2FAdd_Outbound_Route_2.png?alt=media)

If you also add a Dial Pattern in your Trunk settings, the Outbound Route's Dial Pattern will be applied to the dialled number first followed by the Trunk's Dialling Pattern.

#### Set your Outgoing Caller ID

**Note:** It is only possible to set an outgoing Caller ID from a/the number(s) you have on your sipgate trunking account. It is not possible for you to set "any number" as an outbound caller ID with sipgate trunking.

More than one phone number can be used with a single SIP Trunk.

The phone numbers the Trunk will receive incoming calls with can be chosen in your sipgate account Settings

* Under the **Trunking** tab click on the trunk.
* On the right hand side of the trunk's settings click **Assign Phone Number** to add a single number.
* Choose **+Phone Number Block** to add a block of three or ten numbers.

To set the Outgoing caller ID in FreePBX

* Open **Admin** ➔ **Config Edit**
* Click on the **extensions\_Custom.conf** file and add the following text:

{% code title="extensions\_Custom.conf" %}

```ini
[macro-dialout-trunk-predial-hook]
exten => s,1,SipAddHeader(P-Preferred-Identity:<sip:${CALLERID(number)}@sipconnect.sipgate.co.uk>)
exten => s,n,MacroExit()
```

{% endcode %}

\* The number you wish to show on outgoing calls can be selected in FreePBXs settings in the the Trunk Settings ('General' --> 'Outbound Caller ID'), the Outbound Route's settings ('Route Settings' -> 'Route CID') or in the Extension settings ('Outbound CID'). \* The number to be displayed as your outgoing caller ID must be sent to sipgate in the in the E.164 format (i.e. international format without the leading zeros or plus (+) sign) as a new header P-Preferred-Identity: 4420300000000)

#### Asterisk SIP Settings

![](https://1449431311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FftdJXe39x3wvuZjiDFLY%2Fuploads%2Fgit-blob-d1d6e3ce65157c7625879fcdef0acaf2f0dbe0bf%2FSettings-Asterisk_SIP_Settings.png?alt=media)

**Asterisk SIP Settings ➔ General SIP Settings**

* Allow Anonymous Inbound SIP Calls: Yes/No
* STUN Server
* RTP Port Ranges
* Codec Selection

**Asterisk SIP Settings ➔ Chan SIP Settings**

* Registration Timer/Expiry Settings
* Bind Port: Standard Value = 5160
* Bind Address: Standard value is 0.0.0.0.0 (Asterisk will listen on all addresses)
