Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note

To accomplish above tasks please sdlgkndasglndsglnsdglnsdglkndsglknsdglk

Code Block
[root@pbxroot@xxx ~]# vim /etc/asterisk/trunk-failover.conf

...

Code Block
[trunk-failover]
exten => _X.,1,Verbose(Failover group)
  same => n,Set(PREV_CHAN=${canale})

  same => n(__trunk_ffefd2c02f46993e),Verbose(Trying to dial using trunk "MessagenetTrunk 89010" __trunk_ffefd2c02f46993e)
  same => n,Set(NETWORKSTATUS=${SIPPEER(__trunk_ffefd2c02f46993e,status)})
  same => n,Gotoif($["${NETWORKSTATUS}"="UNREACHABLE"]?__trunk_616683993964bc16:)
  same => n,Set(SHARED(Sip_Trunk,${PREV_CHAN})=__trunk_ffefd2c02f46993e)
  same => n,Dial(SIP/__trunk_ffefd2c02f46993e/${EXTEN})
  same => n,Hangup()

  same => n(__trunk_616683993964bc16),Verbose(Trying to dial using trunk "MessagenetTrunk 89111" __trunk_616683993964bc16)
  same => n,Set(NETWORKSTATUS=${SIPPEER(__trunk_616683993964bc16,status)})
  same => n,Gotoif($["${NETWORKSTATUS}"="UNREACHABLE"]?__trunk_d346973491bc1df3:)
  same => n,Set(SHARED(Sip_Trunk,${PREV_CHAN})=__trunk_616683993964bc16)
  same => n,Dial(SIP/__trunk_616683993964bc16/${EXTEN})
  same => n,Hangup()

  same => n(__trunk_d346973491bc1df3),Verbose(Trying to dial using trunk "MessagenetTrunk 89212" __trunk_d346973491bc1df3)
  same => n,Set(NETWORKSTATUS=${SIPPEER(__trunk_d346973491bc1df3,status)})
  same => n,Gotoif($["${NETWORKSTATUS}"="UNREACHABLE"]?__trunk_6fd24f043acea450:)
  same => n,Set(SHARED(Sip_Trunk,${PREV_CHAN})=__trunk_d346973491bc1df3)
  same => n,Dial(SIP/__trunk_d346973491bc1df3/${EXTEN})
  same => n,Hangup()

  same => n(__trunk_6fd24f043acea450),Verbose(Trying to dial using trunk "MessagenetTrunk 89313" __trunk_6fd24f043acea450)
  same => n,Set(NETWORKSTATUS=${SIPPEER(__trunk_6fd24f043acea450,status)})
  same => n,Gotoif($["${NETWORKSTATUS}"="UNREACHABLE"]?__trunk_27f415d6fb6346c0:)
  same => n,Set(SHARED(Sip_Trunk,${PREV_CHAN})=__trunk_6fd24f043acea450)
  same => n,Dial(SIP/__trunk_6fd24f043acea450/${EXTEN})
  same => n,Hangup()

  same => n(__trunk_27f415d6fb6346c0last),Verbose(Trying to dial using trunk "zerozero39" __trunk_27f415d6fb6346c0)
  same => n,Set(NETWORKSTATUS=${SIPPEER(__trunk_27f415d6fb6346c0,status)})
  same => n,Gotoif($["${NETWORKSTATUS}"="UNREACHABLE"]?last:No trunk reachable)
  same => n,Set(SHARED(Sip_Trunk,${PREV_CHAN})=FAILOVER__trunk_27f415d6fb6346c0FAILED)
  same => n,Dial(SIP/__trunk_27f415d6fb6346c0/${EXTEN})
  same => n,Hangup()

  same => n(last),Verbose(No trunk reachable)
  same => n,Set(SHARED(Sip_Trunk,${PREV_CHAN})=FAILOVER_FAILED)
  same => n,Hangup()Hangup()

Once you're done just save the file. When you're back in console, as root you can reload dialplan by issuing the following command:

Code Block
[root@xxx ~]# rasterisk -x "dialplan reload"
Setting max files open to 65536
Privilege escalation protection disabled!
See https://wiki.asterisk.org/wiki/x/1gKfAQ for more details.
Dialplan reloaded.
[root@xxx ~]#

Now your Trunk failover configuration is completed. Any time one Trunk of yours resulted Unreachable,

Brand
brandserver
 would try to use the next one configured. If all your trunks failed, then the call would be rejected (as you can expect, by the way). 

Info

It's possible to choose the exact priority by correctly naming your Trunks. Order followed is alphabetical.

4.4.2 "Re-route temporary unavailable users" option

...