
A Bit About FreePBX And Asterisk
For the uninitiated, FreePBX is an open source user interface for the Asterisk platform. Asterisk itself is a free and open source framework for building communications applications and is sponsored by Sangoma. Sangoma offers additional functionality as paid modules. However, all the core functionality, that is needed to stand up a PBX, is included in the free version. This post covers how to set up packet captures in FreePBX (Asterisk).
FreePBX is very popular in the home lab community as well as in the business world. It can be hosted locally or on a server in a datacenter anywhere in the world. Many cloud offerings are built on these platforms. Some offerings are just re-branded versions of these with modifications for specific industries or special purposes.
When working with a PBX like FreePBX you will almost certainly run into issues with communication with internal and external devices. This could be that you’re having an issue negotiating a codec for a call, or maybe the SIP registration for a trunk or a station isn’t working properly.
Often times, this will require packet captures of the traffic from the FreePBX server to diagnose the issue. This isn’t always possible through the user interface. While there may be some third part modules out there that provide this functionality, you will find the steps to do this manually through the command line of the FreePBX server.
Turning On The Logging And Packet Captures
The first thing your will need to do is to SSH into your server. If you have direct access to the console either through a hypervisor or a keyboard and monitor you can use that too.
Once you are logged in to the server you will want to do the following.
Open the Asterisk CLI interface:
sudo asterisk -r
You are now at the Asterisk CLI (hostname*CLI>)
Type the following commands in order:
pjsip set logger on
pjsip set logger verbose on
pjsip set logger pcap /tmp/myCaptureFile.pcap
The above will turn on the logging for pjsip (SIP), set the logging to verbose, and start the packet capture. You can change the location and the name of the capture file to whatever you want.
Once you issue the first command above you may start seeing some messaging scrolling up on the screen. This is normal.
Now that the logging is active let it run and try and reproduce your issue if possible. If your issue is not something you can manually re-produce you can let the packet capture for a while until you feel like it’s long enough to have gathered some relevant data.
Turning Off The Logging And Packet Captures
The logging and capture settings are not persistent so if the system is rebooted it will need to be turned back on. If your system is busy, you will want to turn this off as soon as your done since it can possibly take up a lot of disk space.
To turn off the logs and capture just issue the first command above with off instead of on like so:
pjsip set logger off
Now you’ll want to grab the file from your server and copy it some where to a PC with Wireshark so you can review the packet capture and hopefully figure out what is causing your issue.
If you are new to packet captures you can take a look at some examples provided on the Wireshark WIKI page.
Hopefully this article helps you solve your issue. Here at Southwest Tech Solutions we work with FreePBX and many other VoIP and telephony platforms. If you would like to know how VoIP, SIP, or a Cloud PBX could help your business please reach out to us.
No responses yet