We are running Trixbox 2.8.0.1 with a Yeastar TDM1600 card with 6 FXO ports. I would like a way where outbound calls are rotated among the FXO trunks. For example, first outbound call would use trunk 1. Next would use Trunk 2 (regardless if trunk 1 is free or not). Next Trunk 3, etc. Of course, if the trunk is busy, it would roll over to the next available trunk.
I also don't want to set up different outgoing routes for each trunk.
Thanks in advance!
rotate outgoing calls through FXO trunks
I believe that you specify the trunk group as r0 instead of g0, that should cause the trunks to be used in a round-robin fashion.
-Chris
I was not aware of the trunk rotation r0 option and will certainly try it later in the day when the server is lightly loaded.
I have achieved trunk rotation quite simply by placing the following code in extensions_custom.conf:
[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(Start Trunk Rotation - Using trunk: ${OUT_${DIAL_TRUNK}} Caller: ${REALCALLERIDNUM})
exten => s,n,Set(TRUNK_GROUP=${OUT_${DIAL_TRUNK}:0:4})
exten => s,n,Gotoif($["${TRUNK_GROUP}" = "ZAP/"]?rotaryhunting)
exten => s,n,MacroExit()
exten => s,n(rotaryhunting),NoOp(Start Alternating Hunt - Using group: ${TRUNK_GROUP} Caller: ${REALCALLERIDNUM})
exten => s,n,Set(NUMBER_TRUNKS=3)
exten => s,n(loop),SetGlobalVar(NEXTLINE=$[${NEXTLINE} + 1])
exten => s,n,Gotoif($[${NEXTLINE}
exten => s,n,SetGlobalVar(NEXTLINE=1)
exten => s,n(noreset),Dial(${TRUNK_GROUP}${NEXTLINE}/${OUTNUM},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,NoOp(Trunk busy retrying)
exten => s,n,Set(NUMBER_TRUNKS=$[${NUMBER_TRUNKS} - 1])
exten => s,n,NoOp(Tries left: ${NUMBER_TRUNKS})
exten => s,n,GotoIf($[${NUMBER_TRUNKS} > 0]?loop)
exten => s,n,NoOp(Run out of trunks)
exten => s,n,Playback(all-circuits-busy-now,noanswer)
exten => s,n,NoOp(Exiting Trunk Rotation)
exten => s,n,Macro(hangupcall,)
exten => h,1,Macro(hangupcall,)
You also need to place NEXTLINE=1 in globals_custom.conf to define a global variable NEXTLINE
Line 2 defines which trunks are to be rotated, here it assumes that it is a number of Zap trunks with name starting with ZAP/, if not you need to adjust
Line 1 TRUNK_GROUP variable to read the required number of characters and Line 2 to the name of the actual trunks you are using. You also need to adjust Line 5 NUMBER_TRUNKS variable to equal the actual number of trunks to be rotated.
This should achieve what you need, it is working consistently for me. Thanks go to gbrook who sowed the seeds of the idea in a post on this forum. Hope it helps.
thanks for sharing the information.
trying to follow your instruction to rotate server sip trunks but failed. things i have done:
place NEXTLINE=1 in globals_custom.conf to define a global variable NEXTLINE;
placing your code in extensions_custom.conf, and replace ZAP with SIP and updated total number of trunks which i have 8;
After updating, i am no longer making any calls.
Hope you can shed some light on the issue for us.
Many thanks,
Bob
Member Since:
2010-07-12