IAX2 Trunk between two Trixbox PBX's - not forwardig calls according to dial plan

nbright
Posts: 17
Member Since:
2008-02-07

Greetings,

I've got two Trixbox PBX servers. We'll call them TrixA and TrixB. TrixA has a PRI. TrixA and TrixB are connected via an IAX2 trunk (though I can change it to SIP or any other VoIP type trunk if it helps accomplish my goal).

What I would like to happen is to do the PBX equivalent of "echo 1 > /proc/sys/net/ipv4/ip_forward". Any calls coming in on the PRI matching an inbound route of a specific set of numbers, should then be routed to TrixB. Any calls originating from TrixB need to be routed out the PRI (i.e. on to the PSTN).

I've configured the boxes with the IAX2 trunk and both ends can call extensions on either server perfectly.

At the start of the day today, no calls could be made from the PSTN to TrixB. We worked around that by setting up a ring-group, and telling it to call an extension on TrixB. It's ugly, and I know it's not the right way, but it works.

Now at this point, any calls sourcing from TrixB can reach extensions on TrixA, but they cannot reach the PSTN via the PRI.

It seems like I'm missing something brutally simple here! Shouldn't calls from TrixB simply consult the outbound route table on TrixA?



nbright
Posts: 17
Member Since:
2008-02-07
I'd like to clarify that

I'd like to clarify that extensions on TrixA have full and properly working access to the PSTN via the PRI. I can call in to those extensions, and call out from those extensions. Extensions on TrixA and TrixB have full communication with each other.



SkykingOH
Posts: 8082
Member Since:
2007-12-17
The unfortunate thing is

The unfortunate thing is this is easily accomplished in Asterisk but a huge pain in FreePBX/trixbox. You can't set a trunk as a destination to an inbound route so you have to create a custom extension that will dial the IAX trunk on the other server. You can then either pass the DID along or you can have a custom extension per DID.

--

Scott

aka "Skyking"



nbright
Posts: 17
Member Since:
2008-02-07
Thanks very much for the

Thanks very much for the reply SkykingOH.

I'm curious though, should I be able to use that same method to route calls both inbound from the PSTN to TrixB *and* outbound from TrixB back to the PSTN?

I'm just a hair above a novice at this, and that just doesn't seem like it'll work to me... though I will definitely try it.



SkykingOH
Posts: 8082
Member Since:
2007-12-17
Outbound is the simplest

Outbound is the simplest config, you would simply use the outbound route in trix B to select trix A. The trunk on trix A must be in the from-internal context. It will then follow your outbound routes.

For call fro trx A to trix B the inbound trunk must be in the from-trunk context on trix B in order to use the inbound DID routing. If you set from-internal then you must send extension numbers.

--

Scott

aka "Skyking"



nbright
Posts: 17
Member Since:
2008-02-07
I'm somewhat confused,

I'm somewhat confused, because in TrixB for the outbound route, I can't select an extension; only a trunk. If I set up TrixB to have it's outbound routing sent to the IAX trunk, I can only reach extensions on TrixA. FWIW that box runs Trixbox 2.4.2, which may be slightly out dated.

"For call fro trx A to trix B the inbound trunk must be in the from-trunk context on trix B in order to use the inbound DID routing. If you set from-internal then you must send extension numbers."

On both TrixA and TrixB I have "context=from-trunk" in the "Incoming Settings" box, but I'm not able to do any DID routing. Even with "core set debug 9" I didn't see any mention of the digits in /var/log/asterisk/full

Here's my Trunk settings for TrixA:
------------------------------
[1616]
host=192.168.2.253
username=myusername
secret=superdupersecret
type=peer

[valnet]
secret=superdupersecret
type=user
context=from-trunk
--------------------------------

And Trix B:
--------------------------------
[1616]
host=192.168.2.254
username=myusername
secret=superdupersecret
type=peer

[valnet]
secret=superduersecret
type=user
context=from-trunk
---------------------------------

I wish I knew the asterisk config syntax better, it really seems like this is something I just need to plop into one of the custom dialplan files....



SkykingOH
Posts: 8082
Member Since:
2007-12-17
On trix a the context needs

On trix a the context needs to be from internal.

To route calls to trix B from trix A you need to build a custom extension, in the dial field it will have IAX2/1616/extnum

--

Scott

aka "Skyking"



nbright
Posts: 17
Member Since:
2008-02-07
Setting from-internal on the

Setting from-internal on the IAX trunk on TrixA made a huge difference! When I changed my outbound route to use the IAX trunk, I was able to dial out from TrixB - which was one of my big problems. I will try the custom extension suggestion next and report back in about an hour.

Thank you very much Scott!



nbright
Posts: 17
Member Since:
2008-02-07
I created an Custom

I created an Custom Extension with a Direct DID, which then dials IAX2/1616 (my trunk name). This does pass the call to my trunk, but it isn't passing DID, so I can't perform any further call routing on TrixB. Imperfect, but it will work. I would *like* to be able to do call routing, but it's not a deal breaker.

Is there a way to make it pass DID?



nbright
Posts: 17
Member Since:
2008-02-07
Well, I spoke a little

Well, I spoke a little prematurely. When I changed the outbound route earlier to my IAX trunk, it looped back to TrixB. I assumed it was probably related to my ring-group configuration or something like that, but now that I've removed said configuration; when I dial out from TrixB it sends the call to TrixA which then sends the call back to TrixB! I can see it doing this in the asterisk console on box TrixA.

I've tried a number of different dial-plan and digit combinations, but everything just loops my call back :( Here's an example of the console on TrixA when I place a call that should be routed out to the PSTN from TrixB:

-- Accepting AUTHENTICATED call from 192.168.2.253:
> requested format = ulaw,
> requested prefs = (ulaw|alaw|gsm),
> actual format = ulaw,
> host prefs = (ulaw|alaw|gsm),
> priority = mine
-- Executing [6203301405@from-internal:1] Macro("IAX2/valnet-3462", "user-callerid|SKIPTTL|") in new stack
-- Executing [s@macro-user-callerid:1] NoOp("IAX2/valnet-3462", "user-callerid: Valnet 8883321616") in new stack
-- Executing [s@macro-user-callerid:2] Set("IAX2/valnet-3462", "AMPUSER=8883321616") in new stack
-- Executing [s@macro-user-callerid:3] GotoIf("IAX2/valnet-3462", "0?report") in new stack
-- Executing [s@macro-user-callerid:4] ExecIf("IAX2/valnet-3462", "1|Set|REALCALLERIDNUM=8883321616") in new stack
-- Executing [s@macro-user-callerid:5] NoOp("IAX2/valnet-3462", "REALCALLERIDNUM is 8883321616") in new stack
-- Executing [s@macro-user-callerid:6] Set("IAX2/valnet-3462", "AMPUSER=") in new stack
-- Executing [s@macro-user-callerid:7] Set("IAX2/valnet-3462", "AMPUSERCIDNAME=") in new stack
-- Executing [s@macro-user-callerid:8] GotoIf("IAX2/valnet-3462", "1?report") in new stack
-- Goto (macro-user-callerid,s,13)
-- Executing [s@macro-user-callerid:13] NoOp("IAX2/valnet-3462", "TTL: ARG1: SKIPTTL") in new stack
-- Executing [s@macro-user-callerid:14] GotoIf("IAX2/valnet-3462", "1?continue") in new stack
-- Goto (macro-user-callerid,s,23)
-- Executing [s@macro-user-callerid:23] NoOp("IAX2/valnet-3462", "Using CallerID "Valnet" <8883321616>") in new stack
-- Executing [6203301405@from-internal:2] Set("IAX2/valnet-3462", "_NODEST=") in new stack
-- Executing [6203301405@from-internal:3] Macro("IAX2/valnet-3462", "record-enable||OUT|") in new stack
-- Executing [s@macro-record-enable:1] GotoIf("IAX2/valnet-3462", "0?2:4") in new stack
-- Goto (macro-record-enable,s,4)
-- Executing [s@macro-record-enable:4] AGI("IAX2/valnet-3462", "recordingcheck|20081231-144308|1230756188.295") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/recordingcheck
recordingcheck|20081231-144308|1230756188.295: No AMPUSER db entry for . Not recording
-- AGI Script recordingcheck completed, returning 0
-- Executing [s@macro-record-enable:5] NoOp("IAX2/valnet-3462", "No recording needed") in new stack
-- Executing [6203301405@from-internal:4] Macro("IAX2/valnet-3462", "dialout-trunk|2|620330XXXX||") in new stack
-- Executing [s@macro-dialout-trunk:1] Set("IAX2/valnet-3462", "DIAL_TRUNK=2") in new stack
-- Executing [s@macro-dialout-trunk:2] ExecIf("IAX2/valnet-3462", "0|Authenticate|") in new stack
-- Executing [s@macro-dialout-trunk:3] GotoIf("IAX2/valnet-3462", "0?disabletrunk|1") in new stack
-- Executing [s@macro-dialout-trunk:4] Set("IAX2/valnet-3462", "DIAL_NUMBER=620330XXXX") in new stack
-- Executing [s@macro-dialout-trunk:5] Set("IAX2/valnet-3462", "DIAL_TRUNK_OPTIONS=tr") in new stack
-- Executing [s@macro-dialout-trunk:6] Set("IAX2/valnet-3462", "GROUP()=OUT_2") in new stack
-- Executing [s@macro-dialout-trunk:7] GotoIf("IAX2/valnet-3462", "1?nomax") in new stack
-- Goto (macro-dialout-trunk,s,9)
-- Executing [s@macro-dialout-trunk:9] GotoIf("IAX2/valnet-3462", "0?skipoutcid") in new stack
-- Executing [s@macro-dialout-trunk:10] Set("IAX2/valnet-3462", "DIAL_TRUNK_OPTIONS=") in new stack
-- Executing [s@macro-dialout-trunk:11] Macro("IAX2/valnet-3462", "outbound-callerid|2") in new stack
-- Executing [s@macro-outbound-callerid:1] ExecIf("IAX2/valnet-3462", "0|SetCallerPres|") in new stack
-- Executing [s@macro-outbound-callerid:2] GotoIf("IAX2/valnet-3462", "1?start") in new stack
-- Goto (macro-outbound-callerid,s,4)
-- Executing [s@macro-outbound-callerid:4] NoOp("IAX2/valnet-3462", "REALCALLERIDNUM is 8883321616") in new stack
-- Executing [s@macro-outbound-callerid:5] GotoIf("IAX2/valnet-3462", "1?normcid") in new stack
-- Goto (macro-outbound-callerid,s,10)
-- Executing [s@macro-outbound-callerid:10] Set("IAX2/valnet-3462", "USEROUTCID=") in new stack
-- Executing [s@macro-outbound-callerid:11] Set("IAX2/valnet-3462", "EMERGENCYCID=") in new stack
-- Executing [s@macro-outbound-callerid:12] Set("IAX2/valnet-3462", "TRUNKOUTCID=") in new stack
-- Executing [s@macro-outbound-callerid:13] GotoIf("IAX2/valnet-3462", "1?trunkcid") in new stack
-- Goto (macro-outbound-callerid,s,17)
-- Executing [s@macro-outbound-callerid:17] GotoIf("IAX2/valnet-3462", "1?usercid") in new stack
-- Goto (macro-outbound-callerid,s,19)
-- Executing [s@macro-outbound-callerid:19] GotoIf("IAX2/valnet-3462", "1?report") in new stack
-- Goto (macro-outbound-callerid,s,23)
-- Executing [s@macro-outbound-callerid:23] NoOp("IAX2/valnet-3462", "CallerID set to "Valnet" <8883321616>") in new stack
-- Executing [s@macro-dialout-trunk:12] AGI("IAX2/valnet-3462", "fixlocalprefix") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/fixlocalprefix
-- AGI Script fixlocalprefix completed, returning 0
-- Executing [s@macro-dialout-trunk:13] Set("IAX2/valnet-3462", "OUTNUM=620330XXXX") in new stack
-- Executing [s@macro-dialout-trunk:14] Set("IAX2/valnet-3462", "custom=IAX2/1616") in new stack
-- Executing [s@macro-dialout-trunk:15] GotoIf("IAX2/valnet-3462", "1?gocall") in new stack
-- Goto (macro-dialout-trunk,s,17)
-- Executing [s@macro-dialout-trunk:17] Macro("IAX2/valnet-3462", "dialout-trunk-predial-hook|") in new stack
-- Executing [s@macro-dialout-trunk:18] GotoIf("IAX2/valnet-3462", "0?bypass|1") in new stack
-- Executing [s@macro-dialout-trunk:19] GotoIf("IAX2/valnet-3462", "0?customtrunk") in new stack
-- Executing [s@macro-dialout-trunk:20] Dial("IAX2/valnet-3462", "IAX2/1616/620330XXXX|300|") in new stack
-- Called 1616/620330XXXX
-- Call accepted by 192.168.2.253 (format ulaw)
-- Format for call is ulaw
-- IAX2/1616-7997 answered IAX2/valnet-3462
-- Channel 'IAX2/valnet-3462' ready to transfer
-- Channel 'IAX2/1616-7997' ready to transfer
-- Releasing IAX2/1616-7997 and IAX2/valnet-3462
-- Hungup 'IAX2/1616-7997'
== Spawn extension (macro-dialout-trunk, s, 20) exited non-zero on 'IAX2/valnet-3462' in macro 'dialout-trunk'
== Spawn extension (macro-dialout-trunk, s, 20) exited non-zero on 'IAX2/valnet-3462'
-- Executing [h@macro-dialout-trunk:1] Macro("IAX2/valnet-3462", "hangupcall|") in new stack
-- Executing [s@macro-hangupcall:1] ResetCDR("IAX2/valnet-3462", "w") in new stack
-- Executing [s@macro-hangupcall:2] NoCDR("IAX2/valnet-3462", "") in new stack
-- Executing [s@macro-hangupcall:3] GotoIf("IAX2/valnet-3462", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,6)
-- Executing [s@macro-hangupcall:6] GotoIf("IAX2/valnet-3462", "1?skipblkvm") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s@macro-hangupcall:9] GotoIf("IAX2/valnet-3462", "1?theend") in new stack
-- Goto (macro-hangupcall,s,11)
-- Executing [s@macro-hangupcall:11] Hangup("IAX2/valnet-3462", "") in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'IAX2/valnet-3462' in macro 'hangupcall'
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'IAX2/valnet-3462'
-- Hungup 'IAX2/valnet-3462'



SkykingOH
Posts: 8082
Member Since:
2007-12-17
Ok, maybe I wasn't clear,

Ok, maybe I wasn't clear, let's say the DID is 3235551212, you would put IAX2/1616/3235551212 in the Dial field. Then you can route on 3235551212 at Site A.

--

Scott

aka "Skyking"



nbright
Posts: 17
Member Since:
2008-02-07
I resolved the call loopback

I resolved the call loopback problem, it was caused by an outbound route in TrixA that should not have been there.



nbright
Posts: 17
Member Since:
2008-02-07
To follow up, for those who

To follow up, for those who might find this thread on a search.

The desired operation: Connect two Trixbox PBXes with an IAX2 trunk, where one PBX has a PRI circuit that will be used to provide PSTN service to both PBXes.

PSTN <- PRI -> TrixboxA <- IAX Trunk -> TrixboxB

On Trixbox A, in USER Details, the context needs to be "from-internal" (the default is from-trunk).
On Trixbox A, create a Custom extension with the desired DID. Under "Device Options" in the "dial" box, type in the name of the IAX trunk, for example: IAX2/mytrunk

This will configure TrixboxA to connect all calls to your desired DID to your IAX2 trunk. IT WILL NOT PASS DID. You will NOT be able to do DID routing on TrixboxB!

On Trixbox B, configure the IAX2 trunk with the default settings for PEER and USER (with the correct IP, Username, and Secret of course). Set your "Outbound Routes" to use the IAX trunk as you would any other PSTN facing trunk.

Note: Leave the "Dial Rules" blank for the trunk on both sides, unless you know that you need to put something else in it. I found that if I put in "Local 7" or any other set of dial rules, it could cause problems.



SkykingOH
Posts: 8082
Member Since:
2007-12-17
Thanks for the write up.

Thanks for the write up. You can indeed route DID's from Box A to Box B as follows:

On Box A

  1. Create a Custom Extension for Each DID
  2. In the dial string of the extension your created use the Dial Option IAX2/MyTrunkName/MyDID
  3. Program an inbound route for the DID selecting the extension created in step 1 as the destination

On Box B you can now use the inbound route to route the DID # from step to any valid destination on the system.

--

Scott

aka "Skyking"



gooster1
Posts: 8
Member Since:
2006-11-26
This thread completely

This thread completely matched my needs. I now have my two trixboxes doing the same. PRI on my main TB feeding others downstream..

Using the custom extension method, is there a way to route a range of DIDs to the further downstream trixbox?



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.