Problem with ENUM, FreePBX and Asterisk

I configured an ENUM Server on localhost which seems to work:

# dig @localhost 1.7.6.5.4.3.2.1.5.5.5.1.localhost NAPTR

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> @localhost 1.7.6.5.4.3.2.1.5.5.5.1.localhost NAPTR
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32594
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;1.7.6.5.4.3.2.1.5.5.5.1.localhost. IN NAPTR

;; ANSWER SECTION:
1.7.6.5.4.3.2.1.5.5.5.1.localhost. 86400 IN NAPTR 10 100 “u” “E2U+sip” “!^.*$!sip:[email protected]!” .

;; AUTHORITY SECTION:
localhost. 86400 IN NS ns.localhost.

;; ADDITIONAL SECTION:
ns.localhost. 43200 IN A 192.168.125.209

;; Query time: 5 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jul 16 16:30:32 2012
;; MSG SIZE rcvd: 151

I then edited my /var/lib/asterisk/agi-bin/enumlookup.agi file to include localhost:
$enums = Array(‘localhost’,‘e164.org’,‘e164.arpa’,‘e164.info’);

Asterisk’s ENUM lookup seems to work, as shown in the log below, but the call cannot be completed.

[2012-07-16 16:33:21] VERBOSE[12059] netsock2.c: == Using SIP RTP TOS bits 184 [2012-07-16 16:33:21] VERBOSE[12059] netsock2.c: == Using SIP RTP CoS mark 5 [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] Macro("SIP/112345678901-0000001c", "user-callerid,LIMIT,") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] Set("SIP/112345678901-0000001c", "AMPUSER=112345678901") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:2] GotoIf("SIP/112345678901-0000001c", "0?report") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:3] ExecIf("SIP/112345678901-0000001c", "1?Set(REALCALLERIDNUM=112345678901)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:4] Set("SIP/112345678901-0000001c", "AMPUSER=112345678901") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:5] Set("SIP/112345678901-0000001c", "AMPUSERCIDNAME=Ted") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:6] GotoIf("SIP/112345678901-0000001c", "0?report") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:7] Set("SIP/112345678901-0000001c", "AMPUSERCID=112345678901") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:8] Set("SIP/112345678901-0000001c", "CALLERID(all)="Ted" <112345678901>") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:9] GotoIf("SIP/112345678901-0000001c", "0?limit") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:10] ExecIf("SIP/112345678901-0000001c", "1?Set(GROUP(concurrency_limit)=112345678901)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:11] GotoIf("SIP/112345678901-0000001c", "1?continue") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Goto (macro-user-callerid,s,24) [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:24] Set("SIP/112345678901-0000001c", "CALLERID(number)=112345678901") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:25] Set("SIP/112345678901-0000001c", "CALLERID(name)=Ted") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:26] Set("SIP/112345678901-0000001c", "CHANNEL(language)=en") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:2] Set("SIP/112345678901-0000001c", "MOHCLASS=default") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:3] Set("SIP/112345678901-0000001c", "_NODEST=") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:4] Gosub("SIP/112345678901-0000001c", "sub-record-check,s,1(out,155512345672,)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] GotoIf("SIP/112345678901-0000001c", "1?check") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Goto (sub-record-check,s,6) [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:6] Set("SIP/112345678901-0000001c", "__MON_FMT=wav") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:7] GotoIf("SIP/112345678901-0000001c", "1?next") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Goto (sub-record-check,s,10) [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:10] ExecIf("SIP/112345678901-0000001c", "0?Return()") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:11] GotoIf("SIP/112345678901-0000001c", "0?out,1") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:12] Set("SIP/112345678901-0000001c", "__REC_STATUS=INITIALIZED") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:13] ExecIf("SIP/112345678901-0000001c", "0?Set(__REC_POLICY_MODE=)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:14] Set("SIP/112345678901-0000001c", "NOW=1342427601") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:15] Set("SIP/112345678901-0000001c", "__DAY=16") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:16] Set("SIP/112345678901-0000001c", "__MONTH=07") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:17] Set("SIP/112345678901-0000001c", "__YEAR=2012") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:18] Set("SIP/112345678901-0000001c", "__TIMESTR=20120716-163321") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:19] Set("SIP/112345678901-0000001c", "__FROMEXTEN=112345678901") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:20] Set("SIP/112345678901-0000001c", "__CALLFILENAME=out-155512345672-112345678901-20120716-163321-1342427601.30") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:21] Goto("SIP/112345678901-0000001c", "out,1") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Goto (sub-record-check,out,1) [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] ExecIf("SIP/112345678901-0000001c", "1?Set(__REC_POLICY_MODE=dontcare)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:2] GosubIf("SIP/112345678901-0000001c", "0?record,1(exten,155512345672,112345678901)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:3] Return("SIP/112345678901-0000001c", "") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:5] Macro("SIP/112345678901-0000001c", "dialout-enum,2,155512345672,") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] GosubIf("SIP/112345678901-0000001c", "0?sub-pincheck,s,1()") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:2] GotoIf("SIP/112345678901-0000001c", "0?disabletrunk,1") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:3] Set("SIP/112345678901-0000001c", "DIAL_TRUNK_OPTIONS=tr") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:4] Set("SIP/112345678901-0000001c", "OUTBOUND_GROUP=OUT_2") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:5] GotoIf("SIP/112345678901-0000001c", "1?nomax") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Goto (macro-dialout-enum,s,7) [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:7] Set("SIP/112345678901-0000001c", "DIAL_NUMBER=155512345672") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:8] Set("SIP/112345678901-0000001c", "DIAL_TRUNK=2") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:9] GotoIf("SIP/112345678901-0000001c", "0?skipoutcid") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:10] Set("SIP/112345678901-0000001c", "DIAL_TRUNK_OPTIONS=") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:11] Macro("SIP/112345678901-0000001c", "outbound-callerid,2") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] ExecIf("SIP/112345678901-0000001c", "0?Set(CALLERPRES()=)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:2] ExecIf("SIP/112345678901-0000001c", "0?Set(REALCALLERIDNUM=112345678901)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:3] GotoIf("SIP/112345678901-0000001c", "1?normcid") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Goto (macro-outbound-callerid,s,6) [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:6] Set("SIP/112345678901-0000001c", "USEROUTCID=") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:7] Set("SIP/112345678901-0000001c", "EMERGENCYCID=") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:8] Set("SIP/112345678901-0000001c", "TRUNKOUTCID=") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:9] GotoIf("SIP/112345678901-0000001c", "1?trunkcid") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Goto (macro-outbound-callerid,s,12) [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:12] ExecIf("SIP/112345678901-0000001c", "0?Set(CALLERID(all)=)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:13] ExecIf("SIP/112345678901-0000001c", "0?Set(CALLERID(all)=)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:14] ExecIf("SIP/112345678901-0000001c", "0?Set(CALLERID(all)=)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:15] ExecIf("SIP/112345678901-0000001c", "0?Set(CALLERPRES()=prohib_passed_screen)") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:12] GosubIf("SIP/112345678901-0000001c", "1?sub-flp-2,s,1()") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] ExecIf("SIP/112345678901-0000001c", "1?Return()") in new stack [2012-07-16 16:33:21] VERBOSE[13443] pbx.c: -- Executing [[email protected]:13] AGI("SIP/112345678901-0000001c", "enumlookup.agi") in new stack [2012-07-16 16:33:21] VERBOSE[13443] res_agi.c: -- Launched AGI Script /var/lib/asterisk/agi-bin/enumlookup.agi [2012-07-16 16:33:21] VERBOSE[13443] res_agi.c: -- enumlookup.agi: Looking up 155512345672 on localhost via dns_get_record [2012-07-16 16:33:21] VERBOSE[13443] res_agi.c: -- enumlookup.agi: Looking up 155512345672 on e164.org via dns_get_record [2012-07-16 16:33:22] VERBOSE[13443] res_agi.c: -- enumlookup.agi: Looking up 155512345672 on e164.arpa via dns_get_record [2012-07-16 16:33:22] VERBOSE[13443] res_agi.c: -- enumlookup.agi: Looking up 155512345672 on e164.info via dns_get_record [2012-07-16 16:33:22] VERBOSE[13443] res_agi.c: -- enumlookup.agi: Setting DIALARR to sip/[email protected]% [2012-07-16 16:33:22] VERBOSE[13443] res_agi.c: -- AGI Script enumlookup.agi completed, returning 0 [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:14] ExecIf("SIP/112345678901-0000001c", "1?Set(CONNECTEDLINE(num,i)=155512345672)") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:15] ExecIf("SIP/112345678901-0000001c", "1?Set(CONNECTEDLINE(name,i)=CID:112345678901)") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:16] GotoIf("SIP/112345678901-0000001c", "0?s-,1") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:17] ExecIf("SIP/112345678901-0000001c", "0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^default))") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:18] ExecIf("SIP/112345678901-0000001c", "0?Set(DIAL_TRUNK_OPTIONS=M(confirm))") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:19] Set("SIP/112345678901-0000001c", "TRYDIAL=sip/[email protected]") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:20] Set("SIP/112345678901-0000001c", "DIALARR=") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:21] Dial("SIP/112345678901-0000001c", "sip/[email protected],") in new stack [2012-07-16 16:33:22] VERBOSE[13443] netsock2.c: == Using SIP RTP TOS bits 184 [2012-07-16 16:33:22] VERBOSE[13443] netsock2.c: == Using SIP RTP CoS mark 5 [2012-07-16 16:33:22] NOTICE[12059] chan_sip.c: Failed to authenticate on INVITE to '"Ted" ;tag=as143a42b4' [2012-07-16 16:33:22] VERBOSE[13443] app_dial.c: -- Called sip/[email protected] [2012-07-16 16:33:22] VERBOSE[13443] app_dial.c: -- SIP/192.168.125.209-0000001d is circuit-busy [2012-07-16 16:33:22] VERBOSE[13443] app_dial.c: == Everyone is busy/congested at this time (1:0/1/0) [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:22] GotoIf("SIP/112345678901-0000001c", "1?dialloop:s-CONGESTION,1") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Goto (macro-dialout-enum,s,16) [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:16] GotoIf("SIP/112345678901-0000001c", "1?s-CONGESTION,1") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Goto (macro-dialout-enum,s-CONGESTION,1) [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] Set("SIP/112345678901-0000001c", "RC=21") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:2] Goto("SIP/112345678901-0000001c", "21,1") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Goto (macro-dialout-enum,21,1) [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] Goto("SIP/112345678901-0000001c", "continue,1") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Goto (macro-dialout-enum,continue,1) [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] GotoIf("SIP/112345678901-0000001c", "1?noreport") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Goto (macro-dialout-enum,continue,3) [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:3] NoOp("SIP/112345678901-0000001c", "TRUNK Dial failed due to CONGESTION HANGUPCAUSE: 21 - failing through to other trunks") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:4] Set("SIP/112345678901-0000001c", "CALLERID(number)=112345678901") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:6] Macro("SIP/112345678901-0000001c", "outisbusy,") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] Progress("SIP/112345678901-0000001c", "") in new stack [2012-07-16 16:33:22] VERBOSE[13443] pbx.c: -- Executing [[email protected]:2] Playback("SIP/112345678901-0000001c", "all-circuits-busy-now,noanswer") in new stack [2012-07-16 16:33:22] VERBOSE[13443] file.c: -- Playing 'all-circuits-busy-now.ulaw' (language 'en') [2012-07-16 16:33:23] VERBOSE[13443] pbx.c: -- Executing [[email protected]:3] Playback("SIP/112345678901-0000001c", "pls-try-call-later,noanswer") in new stack [2012-07-16 16:33:23] VERBOSE[13443] file.c: -- Playing 'pls-try-call-later.ulaw' (language 'en') [2012-07-16 16:33:26] VERBOSE[13443] pbx.c: -- Executing [[email protected]:4] Macro("SIP/112345678901-0000001c", "hangupcall") in new stack [2012-07-16 16:33:26] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] GotoIf("SIP/112345678901-0000001c", "1?theend") in new stack [2012-07-16 16:33:26] VERBOSE[13443] pbx.c: -- Goto (macro-hangupcall,s,3) [2012-07-16 16:33:26] VERBOSE[13443] pbx.c: -- Executing [[email protected]:3] ExecIf("SIP/112345678901-0000001c", "0?Set(CDR(recordingfile)=)") in new stack [2012-07-16 16:33:26] VERBOSE[13443] pbx.c: -- Executing [[email protected]:4] Hangup("SIP/112345678901-0000001c", "") in new stack [2012-07-16 16:33:26] VERBOSE[13443] app_macro.c: == Spawn extension (macro-hangupcall, s, 4) exited non-zero on 'SIP/112345678901-0000001c' in macro 'hangupcall' [2012-07-16 16:33:26] VERBOSE[13443] app_macro.c: == Spawn extension (macro-outisbusy, s, 4) exited non-zero on 'SIP/112345678901-0000001c' in macro 'outisbusy' [2012-07-16 16:33:26] VERBOSE[13443] pbx.c: == Spawn extension (from-internal, 155512345672, 6) exited non-zero on 'SIP/112345678901-0000001c' [2012-07-16 16:33:26] VERBOSE[13443] pbx.c: -- Executing [[email protected]:1] Hangup("SIP/112345678901-0000001c", "") in new stack [2012-07-16 16:33:26] VERBOSE[13443] pbx.c: == Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/112345678901-0000001c'

I have two questions:

  1. What is wrong here and how do I fix this?
  2. Is there any way to add my own ENUM server to enumlookup.agi? enumlookup.agi keeps resetting to its original state.

Thanks so much!

Here’s a rephrase:

A(112345678902) wants to call B(112345678901) but instead of dialing 112345678901, A dials 155512345671, which is B’s DID.

I wish to use my own ENUM server to route calls made to 155512345671 to B(112345678901).

With a little experimentation I found that removing @192.168.125.209 allows the call to complete

1.7.6.5.4.3.2.1.5.5.5.1.localhost. NAPTR 10 100 “u” “E2U+sip” “!^.$!sip:112345678901!".

This doesn’t

1.7.6.5.4.3.2.1.5.5.5.1.localhost. NAPTR 10 100 “u” “E2U+sip” "!^.$!sip:[email protected]!”.

Any ideas?

Thanks!