Instalasi ENUM di Asterisk Ubuntu

From OnnoWiki
Revision as of 00:51, 21 August 2010 by Anton (talk | contribs) (→‎Edit enum.conf)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Secara sederhana ENUM adalah penggunaan Nomor Telepon di Internet. Ada baiknya anda membacaKonsep Dasar ENUM sebelum melakukan Implementasi ENUM.

ENUM Server pada dasarnya DNS Server, dapat di konfigurasi dengan

Agar call di astersik dapat mengenal ENUM, kita perlu mengedit

  • File /etc/asterisk/enum.conf - memberitahukan domain ENUM.
  • File /etc/asterisk/extensions.conf - agar mengenal ENUM saat call.


Edit enum.conf

Tidak banyak yang harus di ubah di /etc/asterisk/enum.conf, hanya pastikan bahwa ada entry

search => e164.arpa
search => e164.org
search => e164.id
search => e164.or.id

Dengan cara itu, kita dapat pastikan bahwa informasi ENUM yang ada di e164.arpa, e164.org dan e164.id akan dapat di ketahui dengan baik oleh asterisk kita.

Kita perlu menyadari bahwa top domain ENUM tidak harus e164.id, bisa saja top level domain yang digunakan adalah e164.perusahaan.co.id, e164.sekolah.sch.id dll. Secara konsensus, kita biasanya menggunakan e164 di hostname untuk menandakan bahwa host / domain tersebut adalah ENUM. Memang tidak ada keharusan untuk itu.

Edit extensions.conf

Untuk Asterisk versi lama 1.2 untuk melakukan routing di ENUM kita dapat memasukan ENUMLOOKUP menggunakan perintah

exten => _62X.,1,ENUMLOOKUP(${EXTEN},sip,,1,e164.id)
exten => _62X.,2,Dial(${ENUM})
exten => _62X.,102,Playback(im-sorry)

atau

exten => _+X.,1,ENUMLOOKUP(${EXTEN},sip,,1,e164.id)
exten => _+X.,2,Dial(${ENUM})
exten => _+X.,102,Playback(im-sorry)


Sayangnya ENUMLOOKUP tampaknya tidak lagi di aktifkan di Asterisk versi terbaru 1.4. Sumber Anton Raharja http://www.antonraharja.web.id/tmp/enum14.txt


command ENUMLOOKUP sudah tidak ada di asterisk 1.4, gantinya sbb: ada 2 langkah yang perlu dipelajari, yaitu mendefinikan macro dan menggunakan macro nya keseluruhan kode ditulis di extensions.conf oh ya, ini sudah digunakan di server voiprakyat, dan berjalan baik2 saja, tapi saya lom coba di asterisk default takutnya ada salah2 ketik variable dan typos lainnya


LANGKAH PERTAMA (1) mendefinisikan macro-enumexten


; 1. Mendefinisikan macro-enumexten
; urutan lookup bisa dilihat dari sini: E164NETWORKS
; yaitu dari e164.or.id -> e164.arpa -> e164.org -> e164.info -> enum.org
; urutan lookup protocol dari: SIP -> IAX -> H323
; ----------------------------------------------------------
[macro-enumexten]
;
; ${ARG1} - Extension to dial
;
exten => s,1,Set(DIAL_NUMBER=${ARG1})
exten => s,n,Set(E164NETWORKS=e164.or.id e164.arpa e164.org e164.info enum.org)
; Checking here to see if there are any e164 networks left to check.
exten => s,n(begin),GotoIf($["${LEN(${E164NETWORKS})}" < "1"]?failed)
; There are, so we take the first one
exten => s,n,Set(ENUMNET=${CUT(E164NETWORKS, ,1)})
; And trim it from the front of E164NETWORKS
exten => s,n,Set(E164NETWORKS=${CUT(E164NETWORKS, ,2-)})
; OK, this is now quite complex. To remain compliant, we have to iterate
; through, in order, the returned records. Since we want to make this
; call over the network, we can ignore tel: lines. Even if it's first
; priority.
exten => s,n,NoOp(EnumLookup ${DIAL_NUMBER} ALL c ${ENUMNET})
exten => s,n,Set(ENUMCOUNT=${ENUMLOOKUP(${DIAL_NUMBER}|ALL|c||${ENUMNET})})
; Documentation is wrong. It can return nothing if the enum lookup fails. Grr.
; Now the count may be zero, so if it is, check the next network
exten => s,n,GotoIf($["${ENUMCOUNT}" = "0"]?begin)
exten => s,n,GotoIf($["x${ENUMCOUNT}" = "x"]?begin) 
; Now, let's start through them.
exten => s,n,Set(ENUMPTR=1)
exten => s,n,NoOp(EnumLookup 1by1 ${DIAL_NUMBER} ${ENUMPTR} ${ENUMNET})
exten => s,n(startloop),Set(ENUM=${ENUMLOOKUP(${DIAL_NUMBER}|ALL||${ENUMPTR}|${ENUMNET})})
; Sanity check the return, make sure there's something in there.
exten => s,n,GotoIf($["${LEN(${ENUM})}" = "0"]?continue)
exten => s,n,GotoIf($["${ENUM:0:3}" = "iax"]?iaxuri)
exten => s,n,GotoIf($["${ENUM:0:3}" = "sip"]?sipuri) 
; It doesn't matter if you don't have h323 enabled, as when it tries to dial, it cares
; about dialstatus and retries if there are any enum results left.
;exten => s,n,GotoIf($["${ENUM:0:3}" = "h32"]?h323uri)
; If we're here, it's not a protocol we know about. Let's increment the pointer
; and if it's more than ENUMCOUNT, we know we've run out of options. Try the
; next e164 network.
exten => s,n(continue),Set(ENUMPTR=$[${ENUMPTR} + 1])
exten => s,n,GotoIf($[${ENUMPTR} > ${ENUMCOUNT}]?begin) 
; OK. If we're here, we've still got some enum entries to go through. Back to
; the start with you!
exten => s,n,Goto(startloop)
; If the prefix is 'sip:'...
exten => s,n(sipuri),Set(DIALSTR=SIP/${ENUM:4})
exten => s,n,Goto(dodial)
; If it's IAX2...
exten => s,n(iaxuri),Set(DIALSTR=IAX2/${ENUM:5})
exten => s,n,Goto(dodial)
; Or even if it's H323.
;exten => s,n(h323uri),Set(DIALSTR=H323/${ENUM:5})
exten => s,n(dodial),Dial(${DIALSTR})
exten => s,n,NoOp(Dial exited in macro-enumexten with ${DIALSTATUS})
; Now, if we're still here, that means the Dial failed for some reason.
; If it's CONGESTION or CHANUNAVAIL we probably want to try again on a
; different channel. However, if it's the last one, we don't have any
; left, and I didn't keep any previous dialstatuses, so hopefully
; someone looking throught the logs would have seen the NoOp's
exten => s,n,GotoIf($[${ENUMPTR} = ${ENUMCOUNT}]?noneleft)
exten => s,n,GotoIf($[$[${DIALSTATUS} = "CHANUNAVAIL"] | $[${DIALSTATUS} = "CONGESTION"] ]?continue) 
; If we're here, then it's BUSY or NOANSWER or something and well, deal with it.
exten => s,n(noneleft),Goto(s-${DIALSTATUS},1)
; Here are the exit points for the macro.
exten => s,n(failed),NoOp(EnumLookups failed)
exten => s,n,Goto(end)
exten => s,n(nochans),NoOp(max channels used up)
exten => s,n(end),NoOp(Exiting macro-enumexten)
exten => s,n,Hangup
exten => s-BUSY,1,NoOp(Trunk is reporting BUSY)
exten => s-BUSY,n,Busy()
exten => s-BUSY,n,Wait(60)
exten => s-BUSY,n,NoOp()
exten => s-BUSY,n,Hangup
exten => _s-.,1,NoOp(Dial failed due to ${DIALSTATUS})
exten => _s-.,n,Hangup
exten => h,1,Hangup


LANGKAH KE DUA (2) MENGGUNAKAN macro-enumexten

; 2. Cara menggunakan macro-enumexten
; ----------------------------------------------------------
; Prefix 62188 for ENUM VoIP Rakyat
exten => _62188ZX.,1,Macro(enumexten,+${EXTEN})
; Prefix + or 00 for ENUM extensions
exten => _+ZX.,1,Macro(enumexten,${EXTEN})
exten => _00ZX.,1,Macro(enumexten,+${EXTEN:2})


Peletakan Code-nya di extensions.conf adalah sebagai berikut,

[macro-enumexten]
...
...
langkah 1 disini
...
...
[default]
...
...
langkah 2 disini


Supaya tidak rewel ada baiknya di set di sip.conf

allowguest=yes
allowexternalinvite=yes



Pranala Menarik