[Asterisk-Users] Failover Registration

Daniel Wright dw at wonderwave.net
Mon Dec 5 01:31:08 MST 2005


Try something like this.

Note: I did not write these scripts. I would give credit to who did, but 
unfortunately I do not remember where I got it.

Dan


[globals]
TRUNK1 => IAX2/user:password at provider1.com
TRUNK2 => IAX2/user:password at provider2.com

; Sets up the outgoing gateway according to availability
[macro-swap-priority]
exten => s,1,NoOp(Swapping trunk priority)
exten => s,n,SetGlobalVar(TRUNKBUF=${TRUNK1})
exten => s,n,SetGlobalVar(TRUNK1=${TRUNK2})
exten => s,n,SetGlobalVar(TRUNK2=${TRUNKBUF})
exten => s,n,NoOp(Swapped)
exten => s,n,NoOp(Priority 1 ${TRUNK1})
exten => s,n,NoOP(Priority 2 ${TRUNK2})

; calls the swap-priority macro to find out which gateway is set to the 
default and dials the number.
[macro-outbound-dial]
exten => s,1,Wait(3)
exten => s,n,Set(TIMEOUT(response)=60)
exten => s,n,Dial(${TRUNK1}/${ARG1})
exten => s,n,NoOp(TRUNK1 failed)
exten => s,n,SetVar(A=2)
exten => s,n,NoOp(rolling over to TRUNK2)
exten => s,n,Playback(hang-on-a-second)
exten => s,n,Macro(swap-priority)
exten => s,n,Wait(2)
exten => s,n,Dial(${TRUNK1}/${ARG1})
exten => s,n,Playback(all-outgoing-lines-unavailable)
exten => s,n,Playback(please-try-again-later)
exten => s,n,Hangup()

;Call outbound-dial macro
[from-inside]
exten => _1XXXXXXXXXX,1,Macro(outbound-dial,${EXTEN})




More information about the asterisk-users mailing list