IAX trunk not following outbound routes

Hi,

We have two SIPs set up with various outbound routes (one trunk for landline calls, one trunk for mobiles, etc).

If the internet connection on sip1 fails it passes the calls through an IAX trunk to sip2 (on the LAN), which is set up with identical outbound routes.

However, calls coming into sip2 down the IAX don’t follow the outbound routes. I have found that the file extensions_custom.conf (set up by a previous tech) has the following section:

[from-trunk-other]
exten => _X.,1(begin),Noop(trying a selection of trunks via the other connection)
exten => _X.,n,Dial(SIP/${EXTEN}@NGC,Tt)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = “BUSY”]?busy)
exten => _X.,n,Dial(SIP/${EXTEN}@AQL3,Tt)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = “BUSY”]?busy)
exten => _X.,n,Dial(SIP/${EXTEN}@AQL4,Tt)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = “BUSY”]?busy)
exten => _X.,n,Dial(SIP/${EXTEN}@AQL7,Tt)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = “BUSY”]?busy)
exten => _X.,n(begin),Noop(Infoserve playing unknown caller)
exten => _X.,n,Playback(cannot-complete-as-dialed)
exten => _X.,n,Playback(check-number-dial-again)
exten => _X.,n,Wait(1)
exten => _X.,n,Hangup

exten => _X.,n(busy),1,Busy
exten => _X.,n,Hangup()

The Asterisk log shows lines like the following, suggesting it’s the above directing these calls:

– Executing [0133238xxxx@from-trunk-other:1] NoOp(“IAX2/xxxxxxxx-user-4161”, “trying a selection of trunks via the other connection”) in new stack
– Executing [0133238xxxx@from-trunk-other:2] Dial(“IAX2/xxxxxxxx-user-4161”, “SIP/0133238xxxx@NGC,Tt”) in new stack

Calls that originate from clients registered to sip2 and going out through the correct routes show up as “from-internal”

I have tried hashing out the above section, but was then unable to make outbound calls from sip1 over the IAX.

What changes could you recommend so that “from-trunk-other” follows the same outbound routes as “from-internal”?

Thanks,
Gavin