Configuring inbound & outbound GSM (chan_dongle) connections in FreePBX

Configuring inbound & outbound GSM (chan_dongle) connections in FreePBX

If you followed our previous tutorial, you already know how to install FreePBX on a Raspberry Pi on a RasPBX system. But what next? In this article, you will learn how to add the possibility to make incoming and outgoing calls using a GSM modem. We will use the chan_dongle.conf module for this. 

Table of Contents

1) Adding custom (dongle) trunk

If you used the tutorial mentioned earlier, your modem should be visible in the operating system. After logging into the system, you should see devices named ttyUSB0, ttyUSB1, etc … To see the list of these devices, do:

					ls -l /dev/ttyUSB*

Also from the Asterisk console we will see the available modems and their status. To do this, from the console level (asterisk -r command) you can execute:

					dongle show devices

If the devices are not visible, maybe the device is not compatible or does not work in the mode supported by usb_modeswitch (article in preparation).

Then log in to FreePBX via your web browser. It should be a link resembling (replace the IP address with the address of your PBX).

Select “Trunks” from the top “Connectivity” menu. Here we will add our support for chan_dongle. On the “Trunks” page, add a new trunk and select “Add Custom Trunk“.

In the first tab “General“, at least in the minimum necessary configuration, we are interested in three fields. Below are some sample values with descriptions:

  • Trunk Name: gsm_dongle0 (unique name of the connection, which will later appear e.g. in the list of outgoing routes)
  • Outbound CallerIDempty (presentation for the route; it is not necessary because it will be set upfront by the SIM card operator)
  • Maximum Channels: 1 (maximum number of simultaneous channels for this connection; logic dictates that 1 SIM = 1 channel)

In the third “Custom Settings” tab, define the text string that will be responsible for making the connections. This variable consists of three parts: channel typedongle device name, and $OUTNUM$. Most often it will look like this:

  • Custom Dial String: dongle/dongle0/$OUTNUM$

For devices using usb-modeswitch and chan_dongle.conf, it will usually be something like dongle0. The device name can be found in /etc/asterisk/dongle.conf.

After entering this data, save the configuration using the “Submit” button, which is usually located in the lower right corner of the screen.

Missing “Outboud CallerID” entry will throw an error, but for GSM modems we don’t have to worry about it. However, if you do not want this error to occur, enter the telephone number in the field provided, preferably in the format 123456789 <123456789>.

2) Inbound route

The configuration of incoming routes is carried out in the tab “Connectivity“> “Inbound Routes“. Depending on your configuration, there may already be one or more routes there. If you already have a route that has the value “ANY” as “DID Number” then you probably don’t need to add another one. If you do not have any route, we can add you the following (minimum) information:

  • Descriptiongsm_in (unique qoute name)
  • DID NumberANY oraz ‘exten’ value from dongle.conf (if you leave the field blank, it will be ANY and all incoming connections will fall into the same place; you can also enter the value of the variable ‘exten’, if you have defined it in the dongle.conf file)
  • Set Destination: destination for the route

At this point, you don’t need to configure anything else. When finished, hit “Submit”.

3) Outbound route

The configuration of outgoing routes is carried out in the tab “Connectivity“> “Outbound Routes“. To add an outbound route, click “Add route“. In the new route, we need to add settings in two tabs.

In the “Route Settings” tab, we need at least two pieces of information:

  • Route Namegsm_out (unique route name)
  • Trunk Sequence for Matched Routesgsm_dongle0 (expandable list of trunks)

If you want to have one shared outbound route for GSM, you can add several items here, e.g. gsm_dongle0 and then gsm_dongle1. Then the route will try to establish a connection through the first available device.

You can also add a separate route for each device, they call it e.g. gsm_out_dongle0gsm_out_dongle1, etc … and add only individual devices in the Trunk Sequence.

Then, in the “Dial Patterns” tab, you need to define for which number pattern, we should make connections via this route.

Usually this setting will be sufficient:

  • Match PatternZX.

With this setting, the route will be used for all calls that are at least 3 digits long and start with a digit other than 0. However, you may want to specify it a bit more, eg ZXXXXXXXX will only make connections to 9-digit numbers and 48ZX. only for numbers to Poland.

Of course, there can be many more such patterns for each individual route. However, it is worth considering whether the cost of mobile connections for a given route will not be too high.

After all of that, we press “Submit” and then, in the upper right corner, we “Apply” our entire configuration. From now on, you can make incoming and outgoing calls using GSM modems.

Do you really know what is happening on your PBX? Let’s try our own VOIPERO software.


The system arleady has created and now is completely FREE. Setup takes a few minutes.


Get to know what VOIPERO system is able to do in terms of reporting and live monitoring of VoIP systems created on Asterisk.

Share this post

Do you have questions or you need an offer?

Contact us!

Most popular

Related Posts

We Have Launched

Monitoring & Reporting of Your VoIP Server