[Asterisk-doc] Howdy's and ENUM documentation

Leif Madsen asterisk-doc@lists.digium.com
20 Dec 2003 15:59:43 -0500


On Sat, 2003-12-20 at 15:50, Olle E. Johansson wrote:
> When documenting ENUM make sure you make a difference between an
> ENUM-alike structure and the ENUM system.
>=20
> The ENUM system is the one with the official root e164.arpa. Nothing else
> can be called ENUM. If you use NAPTR and build something for yourself,
> it's an ENUM-alike structure. Don't use the terms "private ENUM" or somet=
hing
> like that. My friend Patrik wrote the RFC's and he is _very_ strict with
> the difference between ENUM and private systems with a similar solution.

Below I have copy/pasted the document that Peter sent me.  If someone
can read it over who is a little more familier with ENUM than I (Olle?)
and verify that things seem good, then I can start converting it to
DocBook and adding it to the book.

Thanks!


ENUM/E164 Call Routing (LCR)


ENUM is a telephony technology that may single-handedly create the
greatest changes in both internet telephony as well as regular telephone
service. In a nutshell, ENUM is a technology which allows users of
disparate networks and technologies to call each other through the use
of a common routing database. This database is stored in DNS records on
a centralized server.


Figure 1: A sample ENUM entry in a DNS record


5.4.3.2.1.enum.fierymoon.com. NAPTR 100 10 "u" "E2U+IAX2"
"!^\\+(.*)$!iax2:guest@127.0.0.1/\\1@local!" .


In the above figure, the record would be parsed by an ENUM compatible
system to read =E2=80=9CPhone number 12345 is to be redirected to
iax2:guest@127.0.0.1/12345@local=E2=80=9D All of the weird mumbo jumbo in t=
he
lines is important =E2=80=93 they=E2=80=99re called Regular Expressions and=
 it=E2=80=99s a topic
too big to be covered in this documentation.=20


Making ENUM Work for You


Imagine you=E2=80=99re the phone company, and you want to offer a new servi=
ce
that allows a single phone number (say, your home number) to ring
multiple phones at once. With ENUM, this is painfully simple. You would
simply create multiple enum entries for the same number, and increment
the priority in the NAPTR line (For hints on how NAPTR=E2=80=99s work, chec=
k the
BIND/DNS documentation.)


For most users, though, ENUM has an even more useful implication: Free
long distance calling over the internet. Take http://enum.fierymoon.com
, a production ENUM registry and database. By simply adding what
exchanges your system can call locally, suddenly people from all over
the world can utilize your Asterisk system to make calls that would
otherwise cost an arm and a leg.


As an example, let=E2=80=99s take John Q. Public, who=E2=80=99s recently mo=
ved to India
to follow a tech job. He has family back in Seattle that he wishes he
could talk to on a daily basis. Before, he would have to have either an
expensive calling card, or some other homebrew solution for
point-to-point internet dialing. Now, with the beauty of ENUM, John can
use enum.fierymoon.com with his hobby asterisk box to see if there is an
ENUM entry in Seattle. Let=E2=80=99s say that Mike Hunt has a T1 in Seattle=
 and
seldom uses it after hours =E2=80=93 he can set up his ENUM records to let
everyone who uses the ENUM database utilize his local calling area.
Suddenly John Q. is making his calls to family and friends for only the
cost of his internet connection.


Setting up ENUM routing on your Asterisk System


ENUM is a relatively easy item to setup on your asterisk system. If
you=E2=80=99re looking to dial out, it=E2=80=99s as simple as using the Enu=
mLookup
application with a properly configured enum.conf (examples below.) If
you=E2=80=99re looking to be an endpoint of ENUM (i.e., if you=E2=80=99d li=
ke to donate
some of your phone service to someone in need) then there is just a bit
more work to be done.


enum.conf:


This configuration file is blindingly simple. It has but one directive
type, =E2=80=9Csearch.=E2=80=9D Let=E2=80=99s say you=E2=80=99ve got five s=
eparate ENUM sources you=E2=80=99d
like to look up from, you=E2=80=99d simply list them in individual search l=
ines:


Figure 2. enum.conf

;

; ENUM Configuration for resolving phone numbers over DNS

;

[general]

;

; The search list for domains may be customized. Domains are searched

; in the order they are listed here.

;

search =3D> enum.fierymoon.com

search =3D> e164.arpa


Remember to restart when you change this file, or else the changes will
not be immediately accepted.


extensions.conf:


Once you=E2=80=99ve changed your enum.conf file, it is just a matter of add=
ing
some extensions to allow you to dial on ENUM:


Figure 3 extensions.conf (snippet)


[enumcheck]

exten =3D> _41NXXNXXXXXX,1,EnumLookup(${EXTEN:1})

exten =3D> _41NXXNXXXXXX,2,Dial(${ENUM})

exten =3D> _41NXXNXXXXXX,3,Hangup

exten =3D> _41NXXNXXXXXX,102,Hangup


In this example, the user would dial 4 followed by the number they were
attempting to call (This extension example utilizes NANPA numbers, i.e.,
North America, only.) The EnumLookup application stores the correct URL
to dial in the ${ENUM} variable if the lookup succeeds.


Configuring your system to allow ENUM calls through your PSTN interface


Allowing users to dial out of your PSTN interface is quite a noble thing
to do! However, you=E2=80=99ll want to protect yourself to make sure your
nobility is not exploited for someone else=E2=80=99s gains! Hopefully in th=
is
section you will understand the necessity of protecting your phone bill.


There are a few steps involved in setting up your dial-out ENUM
configuration:


1) Decide which technology you will use for allowing phone calls, be it
IAX2, SIP, H323, or any other technology that can be formed into a URI.

2) Find a list of local exchanges that you can call and keep it handy =E2=
=80=93
you will need it later.

3) Configure your iax.conf, sip.conf, h323.conf, or any other
configuration files that will require modifications for the particular
protocol you are intending to interface.

4) Configure your extensions.conf to have a context specifically for
allowing ENUM dialout.

5) Add the local exchanges that you found into your astdb so that you
can look them up with your extension.


(As a note, I believe that Asterisk only supports IAX2 and SIP as well
as PSTN for the URI=E2=80=99s enum will return =E2=80=93 I cannot be 100% s=
ure of this
so anyone in-the-know is free to correct me) In our examples, we will be
using an iax2 user for receiving our calls.


iax.conf

Figure 4. Sample iax.conf configuration for an enum user


[enumuser]

type=3Duser

context=3Denumloc

callerid=3D"Enum Lookup" <000>

disallow=3Dall

allow=3Dilbc

accountcode=3Denumuser


Our IAX user setup is pretty simple. All this user needs to do is allow
calls into our ENUM outbound context. In this example, I have limited
the only available codec to iLBC, so I can cut down on bandwidth
consumed in the process. I=E2=80=99ve also assigned an account code of enum=
user,
so that when I pull my CDR records I can see who=E2=80=99s using the ENUM.


extensions.conf








Figure 5. Sample extensions.conf logic for inbound calls


[enumloc]

exten =3D> _1NXXNXXXXXX,1,SetVar(enumok=3D0)

exten =3D> _1NXXNXXXXXX,2,ODBCget(enumok=3D${EXTEN:1:3}/${EXTEN:4:3})

exten =3D> _1NXXNXXXXXX,3,GotoIf(${enumok}?4:900)

exten =3D> _1NXXNXXXXXX,4,ChanIsAvail(Zap/1)

exten =3D> _1NXXNXXXXXX,5,Dial(Zap/1/${EXTEN})

exten =3D> _1NXXNXXXXXX,6,Hangup

exten =3D> _1NXXNXXXXXX,105,Playback(enum-inuse)

exten =3D> _1NXXNXXXXXX,106,Hangup

exten =3D> _1NXXNXXXXXX,900,Congestion


This extension takes a little bit of explanation (There=E2=80=99s a lot goi=
ng on
here, so pay attention!) First of all, we initialize a local variable,
${enumok} to 0. This allows us to have a default variable in case our
astdb lookup returns nothing. Priority two does the actual astdb lookup.
It=E2=80=99s pretty simple, it asks whether the area code and prefix are in=
 the
astdb database =E2=80=93 If they are, great, priority three makes processin=
g
continue at step four. If they are not, then they are played a
congestion tone at priority 900. At step 4, we ask whether our only FXO
device, Zap/1, is in use. If it isn=E2=80=99t, we do the dialing required t=
o
complete the call. If our Zapata device is in use, we playback the file
=E2=80=9Cenum-inuse=E2=80=9D and then hangup.


Now, some of you must be wondering =E2=80=93 =E2=80=9CHow do I get my exten=
sions into
the astdb?=E2=80=9D Well, that=E2=80=99s a hard question to answer, unless =
you are using
ODBCget as opposed to DBGet. I=E2=80=99ll give you a bit of a hint here:


Figure 6: How to create SQL insert queries from a standard NANPA CO/CLEC
list

<?
$fp=3Dfopen("./lpref","r");
while (!feof($fp))
{
$line=3Dfgets($fp);
list($npa,$nxx,$desc,$zone) =3D split(";", $line, 4);
echo "INSERT INTO \"astdb\"
(\"astfamily\",\"astkey\",\"astvalue\")
VALUES('".$npa."','".$nxx."','1');\n";
}
fclose($fp);
?>


After a reload of asterisk, your box should be ready to receive calls
via IAX2 with username =E2=80=9Cenumuser=E2=80=9D, with calls bound to cont=
ext =E2=80=9Cenumloc=E2=80=9D
=E2=80=93 your lookups should make sure the call is local to you, and then =
pass
it along.


--=20
Leif Madsen <leif@hacklocalhost.com>
http://www.hacklocalhost.com