I HAVE A DREAM CLI Scripts for Incredible PBX 13 and Asterisk 13

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,201
Reaction score
5,221
Some of you may recall that we started down this road with FreePBX 2.11 and Asterisk 11. The objective was to build the CLI components that would be needed to create an open source Drag-and-Drop UI for Asterisk using the GPL components of FreePBX for the code generation component. There were a few "other issues" along the way, but we're back at it again now.

We'll be retesting the original scripts with Asterisk 13 just to be sure everything still works. And we'll be adding some new ones shortly. All of this will be built on the Incredible PBX 13 ISO platform if you want to join the party.

The first new scripts we'll be tackling are Interconnecting Asterisk servers with SIP trunks. The idea here is to plug in the IP addresses of two of your servers and then to interconnect them. With one click on each server, the trunks and outbound routes get generated by the scripts. Once both sides are in place, you can start making free calls between all of the extensions on both servers.

Obviously, you don't need a drag-and-drop UI in order to take advantage of these CLI tools. And these interconnection scripts should be especially handy for those of you that set up remote servers from a central location. No web access is required to the remote site, just SSH into the site, upload the scripts, and go.

We'll post something in a few days to let anyone with a couple sandboxes or VMs play around. Working fine in our lab. :chef:
 
Last edited:

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,201
Reaction score
5,221
interconnect-servers

ast2_0405.png

Photo credit: Asterisk: The Future of Telephony


This script generates code to create trunks and outbound routes to interconnect Asterisk 13 servers running Incredible GUI or FreePBX GUI (untested). It assumes that BOTH servers are running Asterisk 13 . Otherwise, you will need to edit the SIP port numbers in the script before beginning. Right now, the script only supports interconnecting 2 servers. That will be expanded in subsequent releases. The design supports up to 10 interconnected servers. As configured, the generated code allows calls to 3-digit extensions on the other server. You obviously can change that in the script or in the outbound routes that are generated.

WARNING: You must have fixed IP addresses or locked dynamic IP addresses or VPN addresses for ALL servers in order to interconnect Asterisk servers!

To get started:

Code:
cd /root
wget http://incrediblepbx.com/interconnect-servers.tar.gz
tar zxvf interconnect-servers.tar.gz
rm -f interconnect-servers.tar.gz
./interconnect-servers  mainserver-IPaddress remoteserver-IPaddress

Run interconnect-servers with the two IP addresses of your Main server and Remote server which are designated as server70 and server71, respectively. The number is actually the dial prefix to reach extensions on the other server. So, for example from the Main server, you'd dial 71701 to reach extension 701 on the Remote server, server71. Syntax: ./interconnect-servers 192.168.0.1 192.168.0.2

The interconnect-servers script generates the code to build the trunks and outbound routes for BOTH servers. Do NOT run interconnect-servers on both servers and expect things to work because the random trunk passwords won't match.

After you have run the script (ONCE only), there will be 2 new subdirectories, server70 and server71. In those subdirectories, you will find the scripts to be run on the two servers. There's also a tar.gz file for ease of transfer if you want to use it. Copy the code from server70 to your Main server. Copy the code from server71 to your Remote server.

The following install sequence is important, or the trunks won't register!

First, on the Main server, run the server70-to-server71 script.

Second, on the Remote server, run the server71-to-server70 script.

Third, on the Main server, resync to the Remote server by running apply-config script.

On both servers, test that the trunks have registered to each other: asterisk -rx "sip show registry"

If both trunks show "registered" then you're good to go and can start making calls between the servers.

If not, rerun apply-config script on both servers.

To remove the interconnecting trunks, delete the interconnected trunk AND outbound route on BOTH servers using your favorite GUI. Trunks are named server70, server71, etc. Outbound routes are named ToServer70, ToServer71, etc.

Comments/suggestions always welcomed! It's GPL open source code with NoGotchas or annual "maintenance" contracts. :chef:
 
Last edited:

Dan Lawrence

Member
Joined
Jan 4, 2008
Messages
47
Reaction score
9
What kind of link does this create between the servers? Is the voice path encrypted?
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,201
Reaction score
5,221
It's a SIP connection. If you want encryption, use a VPN such as the free NeoRouter app that's included with Incredible PBX.
 
Last edited:

kenn10

Well-Known Member
Joined
Dec 16, 2007
Messages
3,779
Reaction score
2,192
Ward, the script does not seem to work between an Ubuntu Incredible 12-13 install and a PIAF 3.0.6.5 Centos install.
The primary Centos server keeps throwing up Host does not implement 'register' when trying to register to the remote Ubuntu machine.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,201
Reaction score
5,221
@kenn10 I assume you meant Incredible PBX 13-12?? Is the PIAF3 server also running FreePBX 12? Have you tried resaving the trunk on both machines?
 

kenn10

Well-Known Member
Joined
Dec 16, 2007
Messages
3,779
Reaction score
2,192
@wardmundy OK I solved it. I had to add a "fromhost" statement on the trunk on the Ubuntu end. I read a post from another user on a different forum that said they needed to do it. I added it, saved and the Centos end finally registered to the Ubuntu end.

I've been fighting with this for two days but it seems resolved now.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,201
Reaction score
5,221
@wardmundy OK I solved it. I had to add a "fromhost" statement on the trunk on the Ubuntu end. I read a post from another user on a different forum that said they needed to do it. I added it, saved and the Centos end finally registered to the Ubuntu end.

I've been fighting with this for two days but it seems resolved now.

So... it should be "fromhost=ipaddress" at each end??
 

kenn10

Well-Known Member
Joined
Dec 16, 2007
Messages
3,779
Reaction score
2,192
@wardmundy I only had to do it on the Ubuntu end. The Centos end worked OK without it and the Ubuntu end registered. But the Centos end kept saying the "register" is not implemented on host xxx.xxx.xxx.xxx" which was the Ubuntu end. This was prior to adding the "fromhost=ipaddress" to the Ubuntu end. Very odd.

Just in the way of background, I wanted to upgrade my Foxconn box from PIAF 2. I tried to do a fresh load of Centos 6.5 (in 32 and 64-bit varieties) and every time I did the yum -y upgrade, it hosed the boot sequence and the box would not come up. I finally went with the Ubuntu Incredible PBX install and it worked flawlessly. I cannot get gmail or Comcast to work with sendmail on this box either. After reading about all the problems with sendmail on Ubuntu 14.04, I'm walking away from that for the time being.

It was vital that my two homes link up via a SIP trunk and it was making me crazy. Even your script would not work. I had the same settings prior to trying your script and nothing worked. Finally, I was Googling and saw another instance of someone having problems with Ubuntu 14.04 LTS and SIP trunking between Asterisk servers. The had figured out that adding "fromhost=" did the trick and it worked for me.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,201
Reaction score
5,221
@kenn10 I guess the question is whether inserting this extra line on every platform all the time would break anything. Thanks for the heads up. I'll test it out when I have a few hours to burn. :smartass:

Then on to wrestle with SendMail on Ubuntu... again. :coolgleamA:
 

howie954

Member
Joined
Oct 16, 2015
Messages
68
Reaction score
6
This sounds very exciting. I was watching one of your videos on YouTube displaying this concept if I am not mistaken. Ironically, I was reading this article on the wiki.freepbx site last night:

http://wiki.freepbx.org/pages/viewpage.action?pageId=4161588

It seems that your script would be much more efficient. The problem is, I only have one Raspberry Pi to test with. I guess I need to get a couple more so I can jump on this band wagon and begin testing as well.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,201
Reaction score
5,221
It seems that your script would be much more efficient. The problem is, I only have one Raspberry Pi to test with. I guess I need to get a couple more so I can jump on this band wagon and begin testing as well.

Or just add VirtualBox to a desktop PC and set up some servers there. :santa:
 

howie954

Member
Joined
Oct 16, 2015
Messages
68
Reaction score
6
You know, your right. I was very exhausted last night while reading and didn't think about it. I so caught up with the RPI that I wasn't even thinking about a Virtual Machine. Thanks for the idea.
 

Members online

Forum statistics

Threads
25,812
Messages
167,761
Members
19,240
Latest member
nikko
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top