Patton SIP Gateway at remote site using 3CX SBC

This guide will demonstrate the use of a Patton SIP Gateway to Analog FXO/FXS connected to 3CX via the SBC gateway.

The use cases for this are where the 3CX instance is hosted, but it needs access to FXO or FXS connections at the client office. It can also be used in scenarios where the client has branch offices with FXO or FXS connection requirements within the 3CX system at head office.

Follow the setup guide for the Patton gateways located below:
FXO: https://www.3cx.com/voip-gateways/patton-smartnode-sn4112/
(for this guide, I used the FXO version)
FXS: https://www.3cx.com/voip-gateways/patton-smartnode-sn4112-fxs/
But don’t follow the whole guide as we need to make alterations to the config file prior to uploading it to the Patton appliance.

Basically, we need to create the SIP Gateway entity in 3CX, export the config, modify it, and upload into the gateway – do the following:

3CX Management > SIP Trunks > Add Gateway
Select Brand: Patton
Select appropriate model or type
Enter the number of ports the device has (not the number you intend to use – must be total)
Enter the main trunk number

Next, enter the local IP address of the device (must be static or DHCP reservation)
Subnet mask: applicable to the gateway’s local network
Tone Selection region: Australia
Number or SIM calls: this is where you specify the number of lines you will be using
Number of physical PSTN ports: should be pre-populated from earlier.

Under options, Dial Delay: Wait for Dial Tone
Hit OK, then go back into the SIP Gateway in 3cx, next to the blue OK button is Generate device config
This will open a new tab or window into the Patton’s import screen and download the config file to your local computer
Open the config in Notepad++ or similar
Locate the 3CX’s local IP address – using find & replace to replace them all with the SBC’s local IP address
Save and import this config into the Patton gateway, reload, wait, and it should be visible to 3CX once loaded & connected behind the SBC.

3CX Monitoring in PRTG

This script is designed for Debian Linux based 3CX deployments that need to be monitored in PRTG.

Create the scripts in

/var/prtg/scripts

Call the script: 3cxstatuscheck.pl

Make it executable:

chmod +x 3cxstatuscheck.pl

Edit using nano:

#!/usr/bin/perl
#
#
#Script which checks several things on a linux box and then reports back to PRTG
#
$message = "3CX DNS resolve services and logfile OK ";
$status = "0";
@services = ("3CXAudioProvider01","3CXCfgServ01","3CXEventNotificationManager","3CXIVR01","3CXMediaServer","3CXPhoneSystem01","3CXPhoneSystemMC01","3CXQueueManager01","3CXSystemService01","3CXTunnel01");
# Get information from PING about DNS lookupability
open(DNS, "nslookup www.cisco.com|");
@dnsout = <DNS>;
close(DNS);
if ($dnsout[3] =~ m/can't find/)
{
$message = "Unable to resolve DNS";
$status = "1";
}
#check all of the services
foreach $service (@services)
{
open(SERVICECHK, "systemctl status $service|");
@servicestatus = <SERVICECHK>;
close(SERVICECHK);
# print "\n $servicestatus[2] \n";
if ($servicestatus[2] =~ m/running/)
{
#this service is active
}
else
{
#something is wrong with this service
$status = "1";
$message = "One or more 3CX services currently not running";
}
}
#check the end of the log file
open(LOGCHK, "tail -n 500 /var/lib/3cxpbx/Data/Logs/3CXMediaServer* |grep Error|");
@logstatus = <LOGCHK>;
close(LOGCHK);
if ($logstatus[3] =~ m/Error/)
{
#something is wrong with this service
$status = "1";
$message = "3CX Logfile contains many recent errors";
}
if ($status eq '0')
{
print "0:0:3CX OK: $message";
}
else
{
print "2:2:3CX DEGRADED: $message";
}

Add to PRTG as an SSH script sensor.

Install 3CX SBC on Raspberry Pi

This guide is broken into two sections. The first section covers the installation & configuration of the Raspberry Pi’s OS,
and the second section covers the installation & configuration of the 3CX-SBC program that will be running on the Pi.

Section 1: Installation & Configuration of Raspbian Linux on the Raspberry Pi:

Download latest Raspbian Linux Lite from raspberrypi.org – https://www.raspberrypi.org/downloads/
Use Etcher to write the downloaded Linux image to the SD card – https://www.balena.io/etcher/
Remove and re-insert the SD card
Use notepad or similar to create a blank text file on the root of the SD card called ssh and remove the extension from the filename
Unmount the SD card and insert into the Raspberry Pi
Connect to network & power
Locate the let it boot, locate it in DHCP (should appear as ‘raspberrypi’)
SSH to the Raspberry Pi using the IP address in DHCP with username: pi, and password: raspberry
Enter in sudo raspi-config
Using the Raspberry Pi configuration utility, make the following adjustments:
Under the localisation menu, set up appropriate settings for the region in all four sub menus:

  • Change Locale to en_AU.UTF-8
  • Change Timezone to Australia, Melbourne
  • Change Keyboard Layout to EN_AU
  • Change Wi-Fi Country to Australia
  • Back out to the main menu, and enter the Network Options

Change hostname to something meaningful like 3CXSBC01
Change the user password for the account ‘pi’ to something else
Identify the MAC address either in DHCP or using the ‘ifcommand’ & looking at the ether line under eth0
Log into the client’s DHCP server and create a DHCP reservation for the MAC address on their network (assuming the VLAN for VoIP has already been setup) – a static IP address can also be used instead of a reservation.
Update the client docuemntation with the hostname, IP address, username & password
Reboot the Pi after exiting the configuration program
SSH back into the pi
Enter the command: sudo apt-get update to install any updates to the OS

Section 2: Installation & Configuration of 3CX-SBC onto the Raspberry Pi:

Now it’s time to download and install the 3CX-SBC program onto the Pi…
Enter the command:

wget https://downloads-global.3cx.com/downloads/sbc/3cxsbc.zip -O- | sudo bash

You will be presented with the 3CX SBC installer program which will outline the 3CX system requirements for the version of SBC you are installing on the Pi.
Press OK, accept the license agreement (no one is going to read this anyway)
From here, you will need to enter in the URL from the 3CX web interface for the SBC Trunk
Next enter in the Authentication key
Press OK to proceed and it will finalise configuration
Confirm in the 3CX Web console that the SBC trunk has come online

Congratulations! You have successfully completed the instalation of 3CX-SBC on a Raspberry Pi

3CX v16 Not Updating

This document applies to 3CX v16 instances hosted in AWS or running on Debian 9 (Stretch) that are stuck on older versions of 3CX v16 and seemingly just will not update.

SSH or web-console into the Debian instance

Edit the file /etc/apt/sources.list.d/saltstack.list

sudo nano /etc/apt/sources.list.d/saltstack.list

If the one line in this file reads: deb http://repo.saltstack.com/apt/debian/9/amd64/archive/2019.2.0/ stretch main
Then add # in front of it and add an extra line below that reads: deb http://repo.saltstack.com/apt/debian/9/amd64/latest stretch main

Your file should now read:

#deb http://repo.saltstack.com/apt/debian/9/amd64/archive/2019.2.0/ stretch main
deb http://repo.saltstack.com/apt/debian/9/amd64/latest stretch main


Save and close the file
CTRL+O
CTRL+X

Now manually update and upgrade the packages:

sudo apt-get update
sudo apt-get upgrade

Answer Y when prompted to proceed
If prompted about updating the configuration of the Minion package, say Y and press enter

Once the upgrades are completed, you can now go through the 3CX web console and start installing all the pending updates – note, there will be quite a few.

Note: Changes as of December 2021:

I had to update a 3CX instance tonight that refused to update using the 3CX console or the above.

In the end, I had to edit the file:

/etc/apt/sources.list.d/saltstack.list

and enter in the line:

deb https://repo.saltproject.io/py3/debian/9/amd64/latest/ stretch main

Next, you’ll need to install APT’s secure transport module using:

sudo apt-get install apt-transport-https

Now do the update:

sudo apt-get update
sudo apt-get upgrade

Now head back the 3CX Admin Console and continue upgrades from there…