Replacing one dialed number with another number

Here is the problem, with my VoIP provider 311 does not work as expected, well does not work at all really. But there is a work around, I can dial the 877 direct number instead. Now the problem, everyone knows to dial 311, but no one knows the 10 digit number that they can use instead. So what I was hoping is that I can get FreePBX to take capture 311 and replace it with 8773114974. Is this possible?

Set up an Outbound Route with:
prefix: 311
prepend: 8773114974 (or 18773114974, whatever your provider requires)
match pattern: (leave blank)
trunk sequence: (same as what your normal route to toll-free numbers uses)

Make sure that this route is above any others that would match 311.
Also, be sure that you don’t have an extension 311 or a feature code 311.

1 Like

Tried that, just gave me the usual “All circuits are busy now”

Tue, Nov 6 2018 12:59 PM 1541530756.74 “Greg” <202> <2049754919> Playback 311 ANSWERED 00:03
Tue, Nov 6 2018 12:59 PM 1541530756.74 “Greg” <202> <2049754919> Dial 311 FAILED 00:00
Tue, Nov 6 2018 12:50 PM 1541530254.72 “Greg” <202> <2049754919> Congestion 311 ANSWERED 00:04
Tue, Nov 6 2018 12:50 PM 1541530254.72 “Greg” <202> <2049754919> Dial 311 FAILED 00:00

The CDR log
The dial pattern is: Prepend: 8773114974 Preface: 311 Match: Blank / single period

Post the Asterisk log for a failed attempt.

Here is the log
[2018-11-06 13:08:31] VERBOSE[2573][C-00000013] netsock2.c: Using SIP RTP TOS bits 184
[2018-11-06 13:08:31] VERBOSE[2573][C-00000013] netsock2.c: Using SIP RTP CoS mark 5
[2018-11-06 13:08:31] VERBOSE[2434] chan_sip.c: Extension Changed 202[ext-local] new state InUse for Notify User 202
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@from-internal:1] Macro(“SIP/202-00000041”, “user-callerid,LIMIT”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:1] Set(“SIP/202-00000041”, “TOUCH_MONITOR=1541531311.76”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:2] Set(“SIP/202-00000041”, “AMPUSER=202”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:3] GotoIf(“SIP/202-00000041”, “0?report”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:4] ExecIf(“SIP/202-00000041”, “1?Set(REALCALLERIDNUM=202)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:5] Set(“SIP/202-00000041”, “AMPUSER=202”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:6] GotoIf(“SIP/202-00000041”, “0?limit”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:7] Set(“SIP/202-00000041”, “AMPUSERCIDNAME=Greg”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:8] ExecIf(“SIP/202-00000041”, “0?Set(__CIDMASQUERADING=TRUE)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:9] GotoIf(“SIP/202-00000041”, “0?report”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:10] Set(“SIP/202-00000041”, “AMPUSERCID=202”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:11] Set(“SIP/202-00000041”, “__DIAL_OPTIONS=HhTtr”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:12] Set(“SIP/202-00000041”, “CALLERID(all)=“Greg” <202>”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:13] GotoIf(“SIP/202-00000041”, “0?limit”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:14] ExecIf(“SIP/202-00000041”, “1?Set(GROUP(concurrency_limit)=202)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:15] GosubIf(“SIP/202-00000041”, “0?sub-ccss,s,1(from-internal,311)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:16] ExecIf(“SIP/202-00000041”, “0?Set(CHANNEL(language)=)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:17] NoOp(“SIP/202-00000041”, “Macro Depth is 1”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:18] GotoIf(“SIP/202-00000041”, “1?report2:macroerror”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (macro-user-callerid,s,19)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:19] GotoIf(“SIP/202-00000041”, “1?continue”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (macro-user-callerid,s,38)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:38] Set(“SIP/202-00000041”, “CALLERID(number)=202”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:39] Set(“SIP/202-00000041”, “CALLERID(name)=Greg”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:40] GotoIf(“SIP/202-00000041”, “0?cnum”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:41] Set(“SIP/202-00000041”, “CDR(cnam)=Greg”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:42] Set(“SIP/202-00000041”, “CDR(cnum)=202”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-user-callerid:43] Set(“SIP/202-00000041”, “CHANNEL(language)=en_GB”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@from-internal:2] Set(“SIP/202-00000041”, “ROUTEUSER=202”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@from-internal:3] Set(“SIP/202-00000041”, “ROUTEUSER=202”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@from-internal:4] GotoIf(“SIP/202-00000041”, “1?notblind”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (from-internal,311,7)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@from-internal:7] GotoIf(“SIP/202-00000041”, “1?restrictedroute-13cee27a2bd93915479f049378cffdd3,311,2:outbound-allroutes,311,2”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (restrictedroute-13cee27a2bd93915479f049378cffdd3,311,2)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@restrictedroute-13cee27a2bd93915479f049378cffdd3:2] Gosub(“SIP/202-00000041”, “sub-record-check,s,1(out,311,dontcare)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:1] GotoIf(“SIP/202-00000041”, “0?initialized”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:2] Set(“SIP/202-00000041”, “__REC_STATUS=INITIALIZED”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:3] Set(“SIP/202-00000041”, “NOW=1541531311”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:4] Set(“SIP/202-00000041”, “__DAY=06”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:5] Set(“SIP/202-00000041”, “__MONTH=11”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:6] Set(“SIP/202-00000041”, “__YEAR=2018”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:7] Set(“SIP/202-00000041”, “__TIMESTR=20181106-130831”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:8] Set(“SIP/202-00000041”, “__FROMEXTEN=202”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:9] Set(“SIP/202-00000041”, “__MON_FMT=wav”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:10] NoOp(“SIP/202-00000041”, “Recordings initialized”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:11] ExecIf(“SIP/202-00000041”, “0?Set(ARG3=dontcare)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:12] Set(“SIP/202-00000041”, “REC_POLICY_MODE_SAVE=”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:13] ExecIf(“SIP/202-00000041”, “0?Set(REC_STATUS=NO)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:14] GotoIf(“SIP/202-00000041”, “3?checkaction”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (sub-record-check,s,17)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-record-check:17] GotoIf(“SIP/202-00000041”, “1?sub-record-check,out,1”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (sub-record-check,out,1)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [out@sub-record-check:1] NoOp(“SIP/202-00000041”, “Outbound Recording Check from 202 to 311”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [out@sub-record-check:2] Set(“SIP/202-00000041”, “RECMODE=dontcare”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [out@sub-record-check:3] ExecIf(“SIP/202-00000041”, “1?Goto(routewins)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (sub-record-check,out,7)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [out@sub-record-check:7] Gosub(“SIP/202-00000041”, “recordcheck,1(dontcare,out,311)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [recordcheck@sub-record-check:1] NoOp(“SIP/202-00000041”, “Starting recording check against dontcare”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [recordcheck@sub-record-check:2] Goto(“SIP/202-00000041”, “dontcare”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (sub-record-check,recordcheck,3)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [recordcheck@sub-record-check:3] Return(“SIP/202-00000041”, “”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [out@sub-record-check:8] Return(“SIP/202-00000041”, “”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@restrictedroute-13cee27a2bd93915479f049378cffdd3:3] ExecIf(“SIP/202-00000041”, “0 ?Set(CDR(accountcode)=)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@restrictedroute-13cee27a2bd93915479f049378cffdd3:4] Set(“SIP/202-00000041”, “EMERGENCYROUTE=YES”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@restrictedroute-13cee27a2bd93915479f049378cffdd3:5] Set(“SIP/202-00000041”, “MOHCLASS=default”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@restrictedroute-13cee27a2bd93915479f049378cffdd3:6] ExecIf(“SIP/202-00000041”, “1?Set(TRUNKCIDOVERRIDE=2049754919)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@restrictedroute-13cee27a2bd93915479f049378cffdd3:7] Set(“SIP/202-00000041”, “_NODEST=”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@restrictedroute-13cee27a2bd93915479f049378cffdd3:8] Macro(“SIP/202-00000041”, “dialout-trunk,2,311,on”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:1] Set(“SIP/202-00000041”, “DIAL_TRUNK=2”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:2] ExecIf(“SIP/202-00000041”, “0?Set(DIAL_OPTIONS=Hhtr)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:3] GosubIf(“SIP/202-00000041”, “0?sub-pincheck,s,1()”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:4] ExecIf(“SIP/202-00000041”, “0?Set(CALLERID(num)=202)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:5] GotoIf(“SIP/202-00000041”, “0?disabletrunk,1”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:6] Set(“SIP/202-00000041”, “DIAL_NUMBER=311”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:7] Set(“SIP/202-00000041”, “DIAL_TRUNK_OPTIONS=HhTtr”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:8] Set(“SIP/202-00000041”, “OUTBOUND_GROUP=OUT_2”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:9] Set(“SIP/202-00000041”, “DIAL_TRUNK_OPTIONS=T”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:10] GotoIf(“SIP/202-00000041”, “1?nomax”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (macro-dialout-trunk,s,12)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:12] GotoIf(“SIP/202-00000041”, “0?skipoutcid”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:13] Macro(“SIP/202-00000041”, “outbound-callerid,2”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:1] NoOp(“SIP/202-00000041”, “202”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:2] NoOp(“SIP/202-00000041”, “”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:3] NoOp(“SIP/202-00000041”, “off”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:4] ExecIf(“SIP/202-00000041”, “0?Set(CALLERPRES(name-pres)=)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:5] ExecIf(“SIP/202-00000041”, “0?Set(CALLERPRES(num-pres)=)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:6] ExecIf(“SIP/202-00000041”, “0?Set(REALCALLERIDNUM=202)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:7] ExecIf(“SIP/202-00000041”, “0?Set(AMPUSER=202)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:8] GotoIf(“SIP/202-00000041”, “1?normcid”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (macro-outbound-callerid,s,12)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:12] Set(“SIP/202-00000041”, “USEROUTCID=2042728654”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:13] Set(“SIP/202-00000041”, “EMERGENCYCID=”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:14] Set(“SIP/202-00000041”, “TRUNKOUTCID=2042728654”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:15] GotoIf(“SIP/202-00000041”, “1?trunkcid”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (macro-outbound-callerid,s,20)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:20] ExecIf(“SIP/202-00000041”, “1?Set(CALLERID(all)=2042728654)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:21] ExecIf(“SIP/202-00000041”, “1?Set(CALLERID(all)=2042728654)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:22] ExecIf(“SIP/202-00000041”, “1?Set(CALLERID(all)=2049754919)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:23] ExecIf(“SIP/202-00000041”, “0?Set(CALLERPRES(name-pres)=prohib_passed_screen)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:24] ExecIf(“SIP/202-00000041”, “0?Set(CALLERPRES(num-pres)=prohib_passed_screen)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:25] Set(“SIP/202-00000041”, “CDR(outbound_cnum)=2049754919”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outbound-callerid:26] Set(“SIP/202-00000041”, “CDR(outbound_cnam)=”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:14] GosubIf(“SIP/202-00000041”, “1?sub-flp-2,s,1()”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-flp-2:1] ExecIf(“SIP/202-00000041”, “0?Return()”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@sub-flp-2:2] ExecIf(“SIP/202-00000041”, “1?Return()”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:15] Set(“SIP/202-00000041”, “OUTNUM=311”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:16] Set(“SIP/202-00000041”, “custom=SIP/P2569465875”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:17] ExecIf(“SIP/202-00000041”, “0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^default)T)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:18] ExecIf(“SIP/202-00000041”, “0?Set(DIAL_TRUNK_OPTIONS=TM(confirm))”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:19] Macro(“SIP/202-00000041”, “dialout-trunk-predial-hook,”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit(“SIP/202-00000041”, “”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:20] GotoIf(“SIP/202-00000041”, “0?bypass,1”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:21] ExecIf(“SIP/202-00000041”, “1?Set(CONNECTEDLINE(num,i)=311)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:22] ExecIf(“SIP/202-00000041”, “1?Set(CONNECTEDLINE(name,i)=CID:2049754919)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:23] ExecIf(“SIP/202-00000041”, “0?Set(CONNECTEDLINE(name,i)=CID:(Hidden)2049754919)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:24] GotoIf(“SIP/202-00000041”, “0?customtrunk”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:25] Dial(“SIP/202-00000041”, “SIP/P2569465875/311,300,Tb(func-apply-sipheaders^s^1)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] netsock2.c: Using SIP RTP TOS bits 184
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] netsock2.c: Using SIP RTP CoS mark 5
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] app_stack.c: SIP/P2569465875-00000042 Internal Gosub(func-apply-sipheaders,s,1) start
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@func-apply-sipheaders:1] NoOp(“SIP/P2569465875-00000042”, “Applying SIP Headers to channel”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@func-apply-sipheaders:2] Set(“SIP/P2569465875-00000042”, “SIPHEADERKEYS=”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@func-apply-sipheaders:3] ExecIf(“SIP/P2569465875-00000042”, “0?Set(Rheader=1)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@func-apply-sipheaders:4] While(“SIP/P2569465875-00000042”, “0”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] app_while.c: Jumping to priority 7
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@func-apply-sipheaders:8] ExecIf(“SIP/P2569465875-00000042”, “0?SIPRemoveHeader(Alert-Info:)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@func-apply-sipheaders:9] Return(“SIP/P2569465875-00000042”, “”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] app_stack.c: Spawn extension (from-trunk, 311, 1) exited non-zero on ‘SIP/P2569465875-00000042’
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] app_stack.c: SIP/P2569465875-00000042 Internal Gosub(func-apply-sipheaders,s,1) complete GOSUB_RETVAL=
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] app_dial.c: Called SIP/P2569465875/311
[2018-11-06 13:08:31] VERBOSE[2573][C-00000013] chan_sip.c: Got SIP response 503 “Service Unavailable” back from 208.81.0.251:5060
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] app_dial.c: SIP/P2569465875-00000042 is circuit-busy
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] app_dial.c: Everyone is busy/congested at this time (1:0/1/0)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:26] NoOp(“SIP/202-00000041”, “Dial failed for some reason with DIALSTATUS = CONGESTION and HANGUPCAUSE = 34”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-dialout-trunk:27] GotoIf(“SIP/202-00000041”, “1?continue,1:s-CONGESTION,1”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (macro-dialout-trunk,continue,1)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [continue@macro-dialout-trunk:1] GotoIf(“SIP/202-00000041”, “0?noreport”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [continue@macro-dialout-trunk:2] AGI(“SIP/202-00000041”, “trunkalert.agi”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] res_agi.c: Launched AGI Script /var/lib/asterisk/agi-bin/trunkalert.agi
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] res_agi.c: <SIP/202-00000041>AGI Script trunkalert.agi completed, returning 0
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [continue@macro-dialout-trunk:3] NoOp(“SIP/202-00000041”, “TRUNK Dial failed due to CONGESTION HANGUPCAUSE: 34 - failing through to other trunks”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [continue@macro-dialout-trunk:4] ExecIf(“SIP/202-00000041”, “1?Set(CALLERID(number)=202)”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [311@restrictedroute-13cee27a2bd93915479f049378cffdd3:9] Macro(“SIP/202-00000041”, “outisbusy,”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outisbusy:1] Progress(“SIP/202-00000041”, “”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [s@macro-outisbusy:2] GotoIf(“SIP/202-00000041”, “1?emergency,1”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx_builtins.c: Goto (macro-outisbusy,emergency,1)
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] pbx.c: Executing [emergency@macro-outisbusy:1] Playback(“SIP/202-00000041”, “all-circuits-busy-now&please-try-call-later”) in new stack
[2018-11-06 13:08:31] VERBOSE[4328][C-00000013] file.c: <SIP/202-00000041> Playing ‘all-circuits-busy-now.ulaw’ (language ‘en_GB’)
[2018-11-06 13:08:33] VERBOSE[4328][C-00000013] file.c: <SIP/202-00000041> Playing ‘please-try-call-later.ulaw’ (language ‘en_GB’)
[2018-11-06 13:08:34] VERBOSE[4328][C-00000013] pbx.c: Executing [emergency@macro-outisbusy:2] Congestion(“SIP/202-00000041”, “20”) in new stack
[2018-11-06 13:08:36] VERBOSE[4328][C-00000013] app_macro.c: Spawn extension (macro-outisbusy, emergency, 2) exited non-zero on ‘SIP/202-00000041’ in macro ‘outisbusy’
[2018-11-06 13:08:36] VERBOSE[4328][C-00000013] pbx.c: Spawn extension (restrictedroute-13cee27a2bd93915479f049378cffdd3, 311, 9) exited non-zero on ‘SIP/202-00000041’
[2018-11-06 13:08:36] VERBOSE[4328][C-00000013] pbx.c: Executing [h@restrictedroute-13cee27a2bd93915479f049378cffdd3:1] Hangup(“SIP/202-00000041”, “”) in new stack
[2018-11-06 13:08:36] VERBOSE[4328][C-00000013] pbx.c: Spawn extension (restrictedroute-13cee27a2bd93915479f049378cffdd3, h, 1) exited non-zero on ‘SIP/202-00000041’
[2018-11-06 13:08:36] VERBOSE[2434] chan_sip.c: Extension Changed 202[ext-local] new state Idle for Notify User 202

It appears that you have an emergency route that matches 311 and doesn’t rewrite the number, which took priority over the route you set.

That was the problem, works like a charm now. Thanks for your help!