返回列表 發帖

Failover trunk

本帖最後由 ckleea 於 2011-2-13 22:24 編輯

What is your favourite dialplan for a failover trunk setup so that if trunk 1 fails, dial via trunk 2?

Gladful if you can share

The question I post is that I have some problems with HKBN 2b. Dial out encountered problem. I have to fail over to PSTN. But my PSTN trunk is connected via SPA3000.

Now my solution as follow:
Use a macro
  1. [macro-superdial]
  2. ; add some abilities to Dial(Technology/resource[&Technology2/resource2...][|timeout][|options][|URL]):
  3. ;       ${ARG1} - Technology/resource[&Technology2/resource2...] (like SIP/2201)
  4. ;       ${ARG2} - timeout in seconds
  5. ;       ${ARG3} - Dial command options
  6. ;       ${ARG4} - URL (see Dial command for info)
  7. ;       ${ARG5} - Group name (used if you want to limit the number of calls in any way)
  8. ;       ${ARG6} - Max. group number (maximum number of concurrent calls you want to allow for that group)
  9. ;       ${ARG7} - Caller ID name (typically for outgoing calls only)
  10. ;       ${ARG8} - Caller ID number (typically for outgoing calls only)
  11. ;       ${ARG9} - CDR account name (over-rides account group setting in sip.conf or iax.conf)
  12. ;       ${ARG10} - voicemail to send to if noanswer (typically for incoming calls only)
  13. ; Usage instructions:
  14. ;       for an outgoing call, in extensions.conf you just list multiple lines like:
  15. ;               exten => s,1,Macro(superdial,IAX2/voipjet/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,voipjet)
  16. ;               exten => s,2,Macro(superdial,IAX2/alpeh-com/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,aleph)
  17. ;       and it will take the first one that is available
  18. ;
  19. ;       it also works for incoming like so ..
  20. ;               exten => s,1,Wait(2)
  21. ;               exten => s,2,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
  22. ;               exten => s,3,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
  23. ;               exten => s,4,Voicemail(b${GENERALVM})
  24. ;       and then goes to unavailable voicemail if one times out .. otherwise (eg if busy) it tries the next extension
  25. ;       if all are busy or unavailable .. it gets to the last priority which is the busy voicemail
  26. ;
  27. exten => s,1,Set(GROUP()=${ARG5})
  28. exten => s,2,Set(GROUPCOUNT=${GROUP_COUNT(${ARG5})})
  29. exten => s,3,GotoIf($[${GROUPCOUNT} > ${ARG6}]?104)
  30. exten => s,4,GotoIf($["${ARG7}" = ""]?macro-superdial,s,6)
  31. exten => s,5,Set(CALLERID(name)=${ARG7})        ; skip this if ARG7 is empty
  32. exten => s,6,GotoIf($["${ARG8}" = ""]?macro-superdial,s,8)
  33. exten => s,7,Set(CALLERID(number)=${ARG8})              ; skip this if ARG8 is empty
  34. exten => s,8,GotoIf($["${ARG9}" = ""]?macro-superdial,s,10)
  35. exten => s,9,SetAccount(${ARG9})        ; skip this if ARG9 is empty
  36. exten => s,10,Dial(${ARG1},${ARG2},${ARG3},${ARG4})
  37. exten => s,11,Goto(s-${DIALSTATUS},1)
  38. exten => s,104,Goto(s-CHANUNAVAIL,1)
  39. exten => s-BUSY,1,Noop
  40. exten => s-NOANSWER,1,GotoIf($["${ARG10}" = ""]?macro-superdial,s-NOANSWER,3)
  41. exten => s-NOANSWER,2,Voicemail(${ARG10})
  42. exten => s-NOANSWER,3,Noop
  43. exten => _s-.,1,Noop
複製代碼

TOP

My dialplan now is as follow:
If hkbn2b fails, it will use http digest to connect SPA3000 to dial out PSTN
Only problem is different callerid.

;dial-out via HKBN 2b
[CallingRule_2b-out_nocid]
;exten => _9.,1,Dial(SIP/133${EXTEN:1}@hkbn2b)
;exten => _9.,n,Hangup()

exten => _9.,1,Macro(superdial,SIP/133${EXTEN:2}@hkbn2b)
exten => _9.,2,Macro(superdial,SIP/pstn-spa3k-d1/${EXTEN:1})

TOP

本帖最後由 ckleea 於 2011-2-13 21:54 編輯

I also modify the following macro by adding these 2 lines in red to accommodate error in HKbn2b connection
  1. [macro-trunkdial-failover-0.3]
  2. exten = s,1,GotoIf($[${LEN(${FMCIDNUM})} > 6]?1-fmsetcid,1)
  3. exten = s,n,GotoIf($[${LEN(${GLOBAL_OUTBOUNDCIDNAME})} > 1]?1-setgbobname,1)
  4. exten = s,n,Set(CALLERID(num)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 2]?${CID_${CALLERID(num)}}:)})
  5. exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${ARG5})} > 2]?${ARG5}:)})
  6. exten = s,n,GotoIf($[${LEN(${CALLERID(num)})} > 6]?1-dial,1)
  7. exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${CID_${ARG3}})} > 6]?${CID_${ARG3}}:${GLOBAL_OUTBOUNDCID})})
  8. exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${ARG5})} > 2]?${ARG5}:)})
  9. exten = s,n,Goto(1-dial,1)
  10. exten = 1-setgbobname,1,Set(CALLERID(name)=${GLOBAL_OUTBOUNDCIDNAME})
  11. exten = 1-setgbobname,n,Goto(s,3)
  12. exten = 1-fmsetcid,1,Set(CALLERID(num)=${FMCIDNUM})
  13. exten = 1-fmsetcid,n,Set(CALLERID(name)=${FMCIDNAME})
  14. exten = 1-fmsetcid,n,Goto(s,4)
  15. exten = 1-dial,1,Dial(${ARG1})
  16. exten = 1-dial,n,Gotoif(${LEN(${ARG2})} > 0 ?1-${DIALSTATUS},1:1-out,1)
  17. exten = 1-CHANUNAVAIL,1,Dial(${ARG2})
  18. exten = 1-CHANUNAVAIL,n,Hangup()
  19. exten = 1-CONGESTION,1,Dial(${ARG2})
  20. exten = 1-CONGESTION,n,Hangup()
  21. [color=Red]exten = 1-NOANSWER,1,Dial(${ARG2})
  22. exten = 1-NOANSWER,n,Hangup()[/color]
  23. exten = 1-out,1,Hangup()
複製代碼

TOP

example of speed dial as follow

exten=330,1,Macro(trunkdial-failover-0.3,SIP/2xxxxxxx@hkbn2b,SIP/2xxxxxxx@pstn-spa3k-d1,hkbn2b,pstn-spa3k-d1)

TOP

回復 4# bubblestar


    Yours is line hunting. Mine is failover (analog, voip, other, in any combination)

TOP

If you have more voip/analog lines, you can


exten => _9.,1,Macro(superdial,SIP/133${EXTEN:2}@hkbn2b)
exten => _9.,1,Macro(superdial,DAHDI/g0/${EXTEN:1})
exten => _9.,2,Macro(superdial,SIP/pstn-spa3k-d1/${EXTEN:1})

TOP

Learn from problem. Need to set up IP01 dial plan for my brother. Since yesterday, my 2b fails intermittently. So I have to work out a back up solution. Here is my work. Glad you like it.

TOP

I am still not sure whether to get a tdm410p or your sangoma USB-FXO. So I use this. In the future, I can mix more like using the spare spa3000 or my spa400 sip trunk.

This failover macro will work great in a mixed environment.

For a FXO card, if the card fails or DAHDI has problem, it can't work. But for me, I use different technologies.

TOP

Please also refer to this link to learn more

http://www.voip-info.org/wiki/view/Asterisk+variable+DIALSTATUS

TOP

This is our spirit to keep trying and learning from problems.
老土D,就是香港精神

哈哈!

TOP

The next trial will be to get support from other users in HK. so that we can have failover from PCCW, HGC, NWT, HKBN, etc

TOP

This is our VOIP world!!

TOP

Not only the cheapest but reliable.

TOP

回復 20# 角色


    I am just at the beginning. Still many not sure and not understand. However, with mutual co-operation, we can do more in a reliable and economic way.

TOP

返回列表