Search Computer Help Please

Showing posts with label enumlookup. Show all posts
Showing posts with label enumlookup. Show all posts

Tuesday, November 24, 2009

Setting up enumlookup Asterisk 1.4

The enumlookup function can be setup in Asterisk 1.4 simply by editing the extensions.conf file , the enum.conf file does not need to be used and I think its pretty much obsolete now.

First thing you want to do if identify which phones or services will be allowed to perform an enumlookup. e.g include localphones , your local extensions will be able to perform enumlookup's. lot of people forget to include the phone or service for example to add localphones and internal

[enumlookup]
include=> localphones
include=> enumlookup
include=> internal

ensure you include everyone with permission to use this function

The basic enumlookup script for Asterisk 1.4 looks like this

[enumlookup]

include => common

include => internal

include => enumlookup

; This example expects an ${EXTEN} that is an e.164 number (like

; 14102241145 or 437203001721)

; Search through e164.arpa and then also search through e164.org, you can change the e164.org to your own ;enum server or different enum registry

; to see if there are any valid SIP or IAX termination capabilities.

; If none, send call out via Zap channel 1, you could redirect it to a SIP trunk if it fails if you prefer

;

; Start first with e164.arpa zone...

;

exten => _X.,1,Set(sipcount=${ENUMLOOKUP(+${EXTEN},sip,c)}|counter=0)

exten => _X.,2,GotoIf($["${counter}"<"${sipcount}"]?3:6)

exten => _X.,3,Set(counter=$[${counter}+1])

exten => _X.,4,Dial(SIP/${ENUMLOOKUP(+${EXTEN},sip,,${counter})})

exten => _X.,5,GotoIf($["${counter}"<"${sipcount}"]?3:6)

;

exten => _X.,6,Set(iaxcount=${ENUMLOOKUP(+${EXTEN},iax2,c)}|counter=0)

exten => _X.,7,GotoIf($["${counter}"<"${iaxcount}"]?8:11)

exten => _X.,8,Set(counter=$[${counter}+1])

exten => _X.,9,Dial(IAX2/${ENUMLOOKUP(+${EXTEN},iax2,,${counter})})

exten => _X.,10,GotoIf($["${counter}"<"${iaxcount}"]?8:11)

;

exten => _X.,11,NoOp("No valid entries in e164.arpa for ${EXTEN} - checking in e164.org")

;

; ...then also try e164.org, and look for SIP and IAX NAPTRs...

;

exten => _X.,12,Set(sipcount=${ENUMLOOKUP(+${EXTEN},sip,c,,e164.org)}|counter=0)

exten => _X.,13,GotoIf($["${counter}"<"${sipcount}"]?14:17)

exten => _X.,14,Set(counter=$[${counter}+1])

exten => _X.,15,Dial(SIP/${ENUMLOOKUP(+${EXTEN},sip,,${counter},e164.org)})

exten => _X.,16,GotoIf($["${counter}"<"${sipcount}"]?14:17)

;

exten => _X.,17,Set(iaxcount=${ENUMLOOKUP(+${EXTEN},iax2,c,,e164.org)}|counter=0)

exten => _X.,18,GotoIf($["${counter}"<"${iaxcount}"]?19:22)

exten => _X.,19,Set(counter=$[${counter}+1])

exten => _X.,20,Dial(IAX2/${ENUMLOOKUP(+${EXTEN},iax2,,${counter},e164.org)})

exten => _X.,21,GotoIf($["${counter}"<"${iaxcount}"]?19:22)

;

; ...then send out PRI.

;

exten => _X.,22,NoOp("No valid entries in e164.org for ${EXTEN} - sending out via Zap")

exten => _X.,23,Dial(Zap/g1/${EXTEN})

;

; end example 3

Simply pasting this into your extensions.conf will work as long as you have specified who to include at the very beginning.

for the dialing pattern, here we use .X_ which specifies anything starting with the digit 0-9 and anything after that will be matched. So anything really.

that's about it , goodluck

Monday, November 23, 2009

Setup ENUM Server with Linux and Bind9

This post will go through the steps for setting up a simple ENUM (Electronic Number Mapping) server on ubuntu linux operating system.

The basic idea behind ENUM is to map your regular E.164 telephone numbers to domain zone files for example your number 98997867 may become 7.6.8.7.9.9.8.9.e164.arpa. Each enum number is given its own zone file which contains a variety of contact methods available for that number. These records are referred to as NAPTR records.

Financial Savings of ENUM

The main reason ENUM exists is to try and connect the IP networks with the telephone networks, with the main objective of avoiding the PSTN (public switch telephone network) and the high costs associated with using these services and termination fee's.

Bind9 DNS Records in Ubuntu

This quick tutorial will go through setting up a simple bind9 enum server capable of hosting an number of records for enum numbers. If your planning on setting up a proper enum server I will cover this topic later on, and how you can hook it up to your Asterisk PBX.

Install Bind9

First ensure you are in root mode using "sudo su"
apt-get -y install bind9

Once bind9 is installed all files and information for bind9 will be found in the directory /etc/bind

once you are in the directory "cd /etc/bind"

you are ready to modify and create the zone files for your enum domain in this example the domain being e164.org

named.conf
named.conf.options
named.conf.enum
db.e164.org

1.) modify named.conf

Modify the file named.conf , using your preferred editor (e.g nano named.conf, or vim named.conf)

Add the following line to the file

include "/etc/bind/named.conf.enum";

This just specifies that the file named.conf.enum will be used to store DNS information used by bind9

2.) Create named.conf.enum (simply edit the file and a new file will be created)

Add the following line to the file, ensuring that the format stays intact

add following line

zone "e164.org" {
type master;
file "/etc/bind/db.e164.org";

};

Here we specify the name of the zone , the type of server (e.g master, slave) and the file that contains the information for the zone.

3.) Create file db.e164.org

add the following to db.e164.org

TTL 86400
e164.org. IN SOA ns.e164.org. root.e164.org. (
2004011522 ; Serial no., based on date
21600 ; Refresh after 6 hours
3600 ; Retry after 1 hour
604800 ; Expire after 7 days
3600 ; Minimum TTL of 1 hour
)
e164.org. 43200 IN NS ns.e164.org.
;
ns.e164.org. 43200 IN A 192.168.1.2

0.9.8.7.6.5.4.3.2.1.e164.org. NAPTR 10 100 "u" "E2U+sip" "!^.*$!sip:info@example.com!".
0.9.8.7.6.5.4.3.2.1.e164.org. NAPTR 10 101 "u" "E2U+h323" "!^.*$!h323:info@example.com!".
0.9.8.7.6.5.4.3.2.1.e164.org. NAPTR 10 102 "u" "E2U+msg" "!^.*$!mailto:info@example.com!".
8.1.2.7.5.9.3.3.1.6.1.e164.org. NAPTR 100 10 "U" "SIP+E2U" "!^.*$!sip:16133957218@example.com!".

The file contains information for the zone e164.org on the private enum server.

at the very bottom of the zone file contains the enum zone files and naptr contact methods associated with the zones.

The first one is E2U or e164 to URI type of NAPTR record which returns a sip uri of info@example.com, this is the URI that will later be used by your Asterisk PBX.


TESTING AND TROUBLESHOOTING

Remember whenever changes are made to zone files the naming service needs to restarted to apply the changes using

/etc/init.d/bind9 restart

To test an ENUM record use the DIG tool

dig @ 8.1.2.7.5.9.3.3.1.6.1.e164.org -t NAPTR

this will return an answer section containing the sip URI
16133957218@example.com


Note: Any problems you may have such as bind9 not restarting correctly or returning a fail are usually due to incorrect format being used or missing zone files.

always check your /var/log/syslog for errors when troubleshooting


Hope people find this useful, in my next posts I will talk about hosting a private domain name to serve enum records within a private network (I-ENUM private) , as well as testing enumlookup using Asterisk 1.4, 1.6.

I may also cover how to setup a more efficient DNS server using powerdns or similar tools which use databases instead of individual files to store zone records.