How to Connect FreePBX to Yeastar TG Gateway

1. Introduction

The guide provides step-by-step configuration instructions of how to connect TG gateway and FreePBX. The GSM trunk on TG gateway will be extended on FreePBX phone system. With the connection you can achieve:

  1. Make outbound calls from FreePBX via the GSM trunks of TG gateway directly.
  2. Receive calls through GSM trunks of TG gateway at FreePBX.

 

Integration Modes

FreePBX and TG gateway use the Service provider mode to connect with each other.

Firmware version:

In the guide, we tested TG800 and FreePBX.

TG800: 55.18.0.46

FreePBX: 10.13.66

Description:

IP address of FreePBX: 192.168.9.91

IP address of TG800: 192.168.9.95

 

Figure 1 FreePBX and TG800 connect with SPS trunk

 

2. Connect FreePBX to Yeastar TG800

2.1 Create a VoIP Trunk on TG800

Path: Gateway> VoIP Settings> VoIP trunk> Add VoIP Trunk.

Choose “Service Provider” mode, and fill in FreePBX IP address.

Figure 2 Add SIP Trunking in TG800

 

Trunk Type: Service Provider

Type: SIP

Provider Name: FreePBX

Hostname/IP: The IP of the FreePBX, 192.168.9.91

 

After creating SIP Trunking, we can check the status of this trunk, it should be OK(green).

Path: Status> System Status> Trunk Status

Figure 3 Trunks Status on TG800

2.2 Create a VoIP Trunk on FreePBX to TG800

Path: Connectivity> Trunks> Add Trunks> Add SIP (chan_pjsip) Trunk

 

Figure 4 Add VOIP Provider on FreePBX

 

Firgure 5 VoIP trunk on FreePBX

Trunk name: TG800

SIP Server: the IP of the TG800, 192.168.9.95

SIP Server Port: the default port 5060, if you want to change the port, it means the FreePBX provide the port for other devices to register to it

From Domain: the IP of the TG800, 192.168.9.95

Note: it doesn’t matter which type of trunk you need, please feel free to add SIP trunk with other type.

Click “save” and “Apply change”, please check the status of the trunk, it shows “Avail” and “Not in use”

 

Path: Admin> Asterisk CLI> execute command “pjsip show endpoints”

Figure 6 The status of the SIP trunk on FreePBX

2.3 Create an extension in FreePBX

Path: Applications> Extensions> Add Extension> Add New Chan_SIP Extension

 

 Figure 7 the SIP extension on FreePBX

Display Name: The name of the extension. For example: Sharon

Secret: the password of the extension. For example: Pincode300

 

Click “save” and “Apply change”, please check the status of the extension and it will shows OK.

Path: Admin> Asterisk CLI> execute command “sip show peers”

Figure 8 Extension status on FreePBX

 

3. Mobile to IP

In this section, we will configure incoming call to FreePBX.

Figure 9 mobile to IP

 

Step1. Configure “Mobile to IP” Route Settings in TG800.

Path: Gateway> Route Settings > Mobile to IP

 

Figure 10 Create Mobile to IP Route

Simple Mode: No

Route Name: You can name the route whatever you want, to_FreePBX

Call Source: Mobile—GSM1. You can select any GSM line or mobile group. Here we select GSM1 as an example.

Call Destination: SPS-FreePBX. All the calls from GSM1 will be sent to FreePBX via this trunk.

Hotline: 999, you can enter the number as 999 in this field, which is same to DID number on FreePBX

 

Step 2. Configure inbound route on FreePBX.

Path: Connectivity> Inbound Routes> Add Inbound Route

 

Figure 11 Create inbound route on FreePBX

Description: From_TG800

DID Number: 999

Set Destination: Extensions-300 Sharon

 

Step 3. Test a call.

now we can test incoming calls for FreePBX. If you dial the GSM1 number on TG800, the call will be routed to the extension 300 in FreePBX.

 

4. IP to Mobile

In this section, we will configure outbound call for FreePBX extensions.

Figure 12 IP to mobile

Step1. Configure Outbound route on FreePBX.

Path: Connectivity> Outbound routes> Add Outbound Route

Figure 13 Create Outbound Route on FreePBX

Route Name: to_TG800

Prefix: 9

Match pattern: x.

Trunk Sequence for Matched Routes: TG800

 

Step2. Create IP to Mobile on TG800

Path: Gateway->Route Settings->IP to Mobile -> Add IP to Mobile Route

 

Figure 14 Create IP to Mobile Route

Simple Mode: Yes

Route Name: From_FreePBX

Call Source: SPS—FreePBX

Call Destination: Mobile—GSM1

 

Step3. Test a call

After settings, all the calls from FreePBX will be routed to GSM1. We can use extension on FreePBX to make test calls. For example, call 913850614596. Here 9 is the prefix in the outbound route of FreePBX.

 

Have more questions? Submit a request

6 Comments

  • 0
    Avatar

    This is good tutorial as long as the TG and the IPPBX are on the same lan.

    Could you please assist in a config where the IPPBX is on public IP and the TG is on a network behind a nat ?

    This is my case, unfortunately the TG is showing trunk ok whereas the freepbx is showing unavailable

     

    I am obliged to do so as the Openvpn is not working for me. I have a Mikrotik openvpn .

  • 0
    Avatar

    Hi Toufic, thanks for bringing it up. If the freePBX is on public IP and TG is behind a nat, we usually do the settings as below,

    1. Configure "Gateway> VoIP Settings> VoIP trunk> Add VoIP Trunk" on TG with the public IP of freePBX. 

    2. Do port forwarding for your TG gateway, for example, port forward UDP 5060 and 10000-12000 to 192.168.9.95. 

    3. Fill the public IP of TG gateway on SIP trunk page of freePBX.

    For the openVPN the configuration, it is almost the same with the tutorial.

    Please feel free to submit a ticket on our support system https://support.yeastar.com/ if you have further issues. Our aggents will be glad to help you. 

  • 0
    Avatar

    Hi,

    Thank you for the reply. In fact my gateway is in an environment where I have no access to port forwarding and the IP address is either private or dynamic.

    That environment has no restriction for vpn or sip nor even iax.

    As for the Openvpn, could you please share a configuration with Mikrotil routerboard ? That would be the solution but unfortunately I am failing to establish a link.

    Thank you and looking forward to your reply.

     

  • 0
    Avatar

    Hi Toufic, your technical skill is very impressive. I am glad to help but we don`t have the configuration with Mikrotik routerboard, sorry for it. I suggest you to have contact Mikrotik as we consider it as a network issue. I think they may offer you more useful information of the settings on vpn. Thanks. 

  • 0
    Avatar

    Once again your interaction is appreciated.

    The setting on mikrotik has no issue, it is on the Yeastar that I am not able to adapt it.

    If I request support from Mikrotik they will not be able to reply as their provided instructions work for Windows and linux devices.

    https://wiki.mikrotik.com/wiki/OpenVPN

    Probably from your experience with yealink you could figure out a vpn.conf settings.

    Important to note that Openvpn on Mikrotik requires username and password that i could not find in yealink.

    what I did is added a file called auth.cnf with username on first line and password on the second followed by a new line

     

  • 0
    Avatar

    Hi Toufic, I notice that you have already submited the ticket on our support system, our technical support is working hard to reply you asap. Please feel free to share the information with him. Thanks. 

Please sign in to leave a comment.