SIP extensions for my Asterisk PBX

Do you have public SIP extensions on your Asterisk?

  • Yes, of course, SIP is the future, and we use them all the time
  • Yes, we have them but they are rarely used
  • No, that’s silly. When we want to call someone who is using VOIP, we route calls over the PSTN!
  • We would like to but we haven’t figured out how to set it up

0 voters

I’m using Asterisk in a very simple configuration right now: I’ve got a SIP trunk (Broadvoice), it goes to Asterisk, and Asterisk connects to various handsets in a few offices. It’s cool, it all works easily. Ordinary PSTN users call in to the number, press whatever extension they want, and it rings at the appropriate phone. Office users can dial “9” followed by the number and call out.

Your bog-standard simple PBX usage example.

Now, I’m a huge fan of SIP, and I know that pure SIP calls have higher call quality and lower costs than calls involving the PSTN. When I call my friends who have SIP, why should the call route through Broadvoice, which degrades the quality and costs money? Makes no sense. I would like to give out a phone number like "sip:joe@mycompany.com"

I’m having a hard time figuring out how to do that.

It looks like I set up a context for joe in sip.conf like this:

[joe] type=friend ; this connection can both make and receive calls host=dynamic context=incomingsip callerid=Joe canreinvite=no nat=no

But then how do I set it up so that when I pick up my handset and dial something, it goes out correctly? Right now the outgoing context in extensions.conf looks like:

exten => _9NXXXXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN:1},60,W) exten => _9NXXXXXXXXX,n,Hangup()

which is probably a very typical type of pattern.

What would I put in there for my outgoing SIP calls, like if I want to call sip:fred@ekiga.net ?

Thanks

I think you should read this:
voip-info.org/wiki/view/DUNDi

Your sip.conf example is for calls from joe, not calls to a local user joe.

In principle, you just configure to permit anonymous SIP connections and then put an appropriate:

exten => joe,1,…

in your dialplan, in, or included in, the default context.

For outgoing calls to fred, you have:

exten => …,Dial(SIP/fred@ekiga.net)

I’ve not played with these, as security issues here mean we don’t want to allow unauthenticated callers.

I don’t think Asterisk makes it easy to dial people who are not in your dialplan, and the caller ID passed to the phone will normally have lost the domain name of the incoming call. There may be ways of doing this, and there may not be any deep reasons for not allowing it.

Hi

[quote]I think you should read this:
voip-info.org/wiki/view/DUNDi[/quote]

Dundi is realy a Asterisk to asterisk thing, what you actually want to use is either enum or inum more than likely both. since you want to catch as many users as possible.

Ian

Ok…

Right, so how do we allow anonymous SIP connections? That’s what we need. They should be directed into some context I assume?

[quote=“david55”]For outgoing calls to fred, you have:

exten => …,Dial(SIP/fred@ekiga.net)[/quote]

But we don’t want to have to pre-define the SIP addresses we can call out to. Eventually people will be putting their SIP addresses on their business cards and so on; we would like to be able to make outbound calls to any SIP address.

That’s the other thing I was wondering about. It would need to pass in full caller ID information, so I can see I have a call coming in from important_bob@customer.com, for example.

I should be able to use SIP addresses instead of phone numbers for general calling purposes, but I’m not sure how to get Asterisk to route it. Surely the goal of all the SIP advocates is to eventually make SIP addresses a viable way of addressing for voice calls, as an alternative (or even replacement) for PSTN numbers?

Thanks for any suggestions.

Hi

Oh the utopian dream, In reality it wont happen. issuing your sip address just opens you up to spit.

enum has been around for some years and is only just taking hold. But mainly in the carrier space, Inum has been arround for a while and is also taking hold.

itu.int/osg/spu/enum/

inum.net/

Ian

But look, I send and receive emails based on username@domainname. Why not make and receive calls on it? It’s not a Utopian dream. Skype was able to achieve the same thing, with less flexibility and mandatory (malware?) software.

If I can get my Asterisk box to work this way, it will be great, because I have high-quality SIP handsets all over the place (snom / Aastra) and I can easily get my friends to sign up on Ekiga.net. I just need to do my part and get Asterisk to do it.

Any suggestions?

Hi

Yes its possible for “you” as an individual to get you mates to sign to a outside itsp and then set up speed dialsin your server to dial them, I do this to call skype addresses from Asterisk servers. But you have to know their address to define it map it to a “dialable” number, or write a little xml app to dial the calls for you.

as to [quote] It’s not a Utopian dream.[/quote] Yes its possible and very simple to do, But in-reality its soured by the amount of unwanted calls you will receive.

but out dialing is very simple

exten => _35XX,1,NoOp(‘opensky dial’);
exten => _35XX,2,set(spnum=${DB(speed/${EXTEN:2})})
exten => _35XX,3,Dial(SIP/${spnum}|120|j)
exten => _35XX,4,Hangup()

in the above example th address user@domain.com is stored in the astdb and its retrieved and set as variable spnum and then called.

of course in the case of many ITSPs they wont accept unathenticated calls to its users fro the already mentioned spit problems as it would be very easy to create a script that dials lots of names/numbers in order.

Ian

That’s what I want to set up, except I don’t want to put them on speed dials in my server, because I don’t want to have to update the server config all the time for this. It makes no sense. I can easily put them in the address book of Ekiga, or on my snom’s speed dial.

It’s no problem, the snom and the Aastra phones, and Ekiga of course, let me program in full SIP adresses just as easily as a phone number.

I would love to set it up. I’m not at all worried about spit problems. My email anti-spam setup will block spit just as well.

[quote=“ianplain”]but out dialing is very simple

exten => _35XX,1,NoOp(‘opensky dial’);
exten => _35XX,2,set(spnum=${DB(speed/${EXTEN:2})})
exten => _35XX,3,Dial(SIP/${spnum}|120|j)
exten => _35XX,4,Hangup() [/quote]

But how do I do it without using speed dial like that? I really just want to type sip:myfriend@somewhere on Ekiga or my handset and have it route. Shouldn’t be too hard, right? Should be simpler than setting up speed dial on the server.

And it’s just as easy to block them, the same way we block spam.

My server is running snort already. Already, the mail agent (Postfix) feeds back “this is not a valid address” to snort, and then snort blocks the zombie’s IP address, and that’s the end of that. I can just as easily make Asterisk send messages to snort for repeated dial attempts, and I won’t get any spit.

I accept SIP calls from the public. I also place SIP calls to the public when possible:

I use Asterisk to route outgoing calls via SIP if it can find a route, and via the PSTN if it cannot. To place a call, I just pick up my Asterisk extension and dial the destination telephone number as 1+AreaCode+PhoneNumber. (This is known as an e.164 number.) I have no extensions beginning with 1, so the dial plan recognizes this as an outgoing call. The outgoing call rule in extensions.conf looks like this:

[color=green]exten = _1NXXNXXXXXX,1,Macro(lookupdial,${EXTEN})[/color]

Elsewhere, I have defined the following macro:

[color=green][macro-lookupdial]
exten = s,1,Set(dest=${ENUMLOOKUP(+${ARG1},SIP,1,e164.org)})
exten = s,n,GotoIF($[ “${dest}” != “”]?Dialit)
exten = s,n,Set(dest=${ENUMLOOKUP(+${ARG1},SIP,1,e164.arpa)})
exten = s,n,GotoIF($[ “${dest}” != “”]?Dialit)
exten = s,n,Set(dest=${ENUMLOOKUP(+${ARG1},SIP,1,e164.info)})
exten = s,n,GotoIF($[ “${dest}” != “”]?Dialit)
exten = s,n,Set(dest=${ENUMLOOKUP(+${ARG1},SIP,1,e164.televolution.net)})
exten = s,n,GotoIF($[ “${dest}” != “”]?Dialit)
exten = s,n,Set(dest=${ENUMLOOKUP(+${ARG1},SIP,1,enum.org)})
exten = s,n,GotoIF($[ “${dest}” != “”]?Dialit)
exten = s,n,Dial(SIP/${ARG1}@${TRUNK})
exten = s,n,Hangup(21);
exten = s,n(Dialit),Dial(SIP/${dest})[/color]

When I dial an outgoing call, the above macro attempts to look up the destination number in five different DNS databases: e164.org, e164.arpa, e164.info, e164.televolution.net, and enum.org. If it discovers a SIP route to the destination number in any of these, it places the call directly to the SIP destination. If all of them come up empty, it places the call via the PSTN using ${TRUNK} for SIP termination service. (TRUNK is defined elsewhere in extensions.conf.) Are there any other publically-accessible e.164 registries that I should be checking?

Actually, my Asterisk switch is currently handling all of the non-local, non-toll-free outbound traffic produced by a population of about 125 pay telephones located on the streets of New Jersey. Most of the calls go via the PSTN, but a few go directly to the destination, SIP all the way. As more SIP users register their telephone numbers in one or more of these databases, and configure their VoIP equipment to accept calls from the public, I expect this situation to improve.

My switch accepts inbound SIP calls from the public, and my listed directory number is registered in one of the enum databases. A very small number of inbound calls arrive via SIP, bypassing the PSTN. Perhaps as more people trust this technology, more will benefit from it. Registering a SIP route to your published telephone number makes this far easier than requiring your callers to dial something like sip://joe@sip.mydomain.com because most PSTN users have only numeric dials. Moreover, unless you hide behind an unlisted number, most people can find your e.164 number in the phone book. If they’re using SIP, then they’re going to reach you that way, even if they don’t realize it when they call.

Thanks for the tips on that. I’ll set that up, and register my number. Might as well.

But I still want to be able to dial by SIP, to be able to make and receive calls without even messing around with phone numbers. Hello, we don’t send emails to 833-524-4335, why should we send calls to it?

I’m still hoping someone might post some configuration hints on how I could make it work like that, separate from any kind of registry, speed dial configuration, etc. I just want to dial a SIP number! If I’m using a client like Ekiga or a snom phone, it’s just as easy to dial a SIP address as it is to type in digits. In fact it’s easier because it’s easier to remember an address like joe@somedomain.com than it is to remember Joe’s number is 922-438-3434.

One thing that would greatly help SIP-to-SIP calling would be if the major consumer SIP providers (Broadvoice, Vonage, etc etc) would somehow interface with these registries and allow direct SIP-to-SIP. That would be great! It would save them costs and greatly improve call quality.

Hi

They all will be internally, But for the reasons oulined the will not open it up to untrusted users. enum and inum are based on mutual trust, and a sharing of user data.

Ian

The basic problem with calling a SIP address from a SIP phone is that Asterisk is a back to back user agent, not a proxy, so it assumes that the domain name part refers to itself and removes it before processing the user part of the destination.

I am not aware of options to stop that behaviour, so you would probably have to change the source code. Alternatively, you would have substitute something else for the @ in the number dialled into the phone, or you might be able to use the standard SIP URL escaping mechanism.

Anonymous inbound calls, if permitted, are handled in the default context.

[quote=“david55”]The basic problem with calling a SIP address from a SIP phone is that Asterisk is a back to back user agent, not a proxy, so it assumes that the domain name part refers to itself and removes it before processing the user part of the destination.

I am not aware of options to stop that behaviour, so you would probably have to change the source code. Alternatively, you would have substitute something else for the @ in the number dialled into the phone, or you might be able to use the standard SIP URL escaping mechanism.[/quote]

That’s really annoying. It would probably take me quite a bit of effort to learn the code to that level. I thought the vision of the Asterisk community was that, one day, SIP would be an alternative to the PSTN, and that would have to include number assignment. We already have domain names; why should I have to pay $25 for a phone number when I’ve already got a domain name? We route email to domains. Why not calls? I thought this was the inspiration behind Asterisk.

Ok, I’ll try to set that up.

If all you want to do is replace a telephone number with a URL (e.g. sip://username@domain.com) you can already do that. The problem is that there are a few hundred million telephones in the world from which such a “number” cannot be dialed. The reason most people want a telephone is to be able to call (and be called by) nearly any one of these telephones, should the need arise.

A tiny fraction of telephone users can dial non-numeric numbers, by using soft phones or, perhaps, some very unusual telephone sets with qwerty keyboards. This situation will probably change over time. For the present, you’ll need a telephone number if you expect to receive telephone calls.

I haven’t studied the Asterisk source code. But if I wanted to allow extensions to dial any arbitrary SIP URL, I would start by enhancing the code that performs wildcard pattern matches in the dialplan. We can already match any numeric pattern. Perhaps a generalized regular expression parser could be used, allowing a pattern that matches a string of alpha characters. Suppose * matched any string of alphanumeric characters, as it does in Unix and MS-DOS filenames. It would then be possible to have a line like this one in your extensions.conf file:

exten => _SIP://@,1,Dial(SIP/${EXTEN:6})

If an extension user dials a text string like SIP://dave@sip.westmark.com this line would match, and would invoke the Dial() function, causing your Asterisk server to connect directly with a SIP-compatible host at the destination.

But suppose, now, that you look up your friend’s number in the directory and it tells you something like 201-345-6789. How, exactly, would you call such a number? You can’t easily find out what carrier serves this number, so what domain would you use? If you knew that Verizon is the serving carrier for most of the 201 area code, you might dial SIP://${EXTEN}@carrier.com to reach it via the PSTN. This is what I attempt to do with the lookup-dial macro described in my previous post in this thread.

Perhaps some day, directory assistance will provide a URL, rather than a numeric telephone address.

The problem isn’t in the extensions.conf processing (“the PABX”) it is in the SIP channel processing. When you phone dials a number what it actually sends is number@asterisk.box.domain.example.com.

To allow raw SIP addresses to be sent from the phone, one would need to modify chan_sip.c so that it didn’t strip the domain name.

Basically the battle is lost at this point (1.6.1.0):

11617 :     	/* Get the target domain */
11618 :     	if ((a = strchr(uri, '@'))) {
11619 :     		*a++ = '\0';
11620 :     	} else {	/* No username part */
11621 :     		a = uri;
11622 :     		uri = "s";	/* Set extension to "s" */
11623 :     	}

[quote=“david55”]To allow raw SIP addresses to be sent from the phone, one would need to modify chan_sip.c so that it didn’t strip the domain name.

Basically the battle is lost at this point (1.6.1.0):[/quote]

Ah, thanks for the reference on that.

That is unfortunate! It seems like it would be a very small change in chan_sip.c to preserve the original address, and it would have a great benefit for someone who wants to be able to handle non-legacy routing? I quote from the Asterisk manual:

Ok, part of that revolution and freedom is being able to address calls without the permission of legacy PSTN carriers.

And then it says…

Ok, I’m ready to do it! But then, isn’t it reasonable for me to want to extend non-numeric addressing to my addressing?

Contrary to what Dave Levenson says…

[quote=“DaveLevenson”]The problem is that there are a few hundred million telephones in the world from which such a “number” cannot be dialed. The reason most people want a telephone is to be able to call (and be called by) nearly any one of these telephones, should the need arise.

A tiny fraction of telephone users can dial non-numeric numbers, by using soft phones or, perhaps, some very unusual telephone sets with qwerty keyboards.[/quote]

I have a few mainstream SIP handsets here and all of them are capable of dialing SIP addresses just as easily as dialing numbers. I have the Aastra 480i CT and the snom 370, two very typical, mainstream SIP phones, and dialing by address is trivial on both of them. The snom 370 in particular makes it super-easy. You go to the phone’s web interface, and you can type in whatever you want, and hit either “dial” (to be connected immediately) or save it as a contact, just the same way I use it with any other number. The Aastra has similar capability. And both of them can take contact lists as XML feeds, making it trivial to mix in SIP addresses.

Of course softphones are designed for such use. Ekiga, Kphone, etc all have a big section where you type in the address you want to dial.

David, I hope that little section of code there in chan_sip.c could have a small modification to make it configurable.

I hate the idea that we could get into a SIP universe, with everyone using SIP phones, softphones, and Asterisk, and still need to deal with carriers to give us phone numbers, even though they aren’t routing the calls. For international users, in some countries the carriers are dysfunctional, and users there would prefer to just skip the whole carrier thing. Also, mobile phones are soon going to all become SIP softphones, and dialing letters in an address is just as easy as dialing numbers on many mobile phones.

The concerns about spit are unfounded. a) I already get call spam right now on my ordinary phone (“this is the second notice that your new car warranty is about to expire!”) and b) email faces exactly the same problem, and we can almost directly use the solutions that exist for email. Right now, today, my Asterisk server is protected against spit by the snort that is running on my server. Some zombie tries to send too much email to invalid users, snort blocks the zombie’s packets, problem solved. It will be no different with SIP addresses.

We are slaves to the legacy carriers. We can free ourselves! But we need a little help from Asterisk to be able to route these non-legacy SIP addresses.

Hi
Have you read any of the documents on enum and inum?

as for [quote]We are slaves to the legacy carriers. We can free ourselves! But we need a little help from Asterisk to be able to route these non-legacy SIP addresses.
[/quote] Well I’m happy yo be a slave since I need my customers to be able to call me and I need to call them. And I can dial users by domain name using speed dials thay you dismissed but now you accept that you need to use a GUI to enter the address, But not all phones have this , and yes aastra can do it via xml interface but not nativly and as for snom again I would have to make a list up for the snom m3 and then upload it. Thats just not workable…

Perhaps I been around too long, It does seem ideas keep coming around. And yes I though dialing but domain would be cool, but that was 6 years ago, I even wrote an app for Mitels sip phones to allow this. Also I used to publish a sip address that could be called. Now its available by enum only. And this means the person calling me doesnt need to think about it. They just dial 11 digits server does a enum lookup finds the address and connects against the 25 characters to dial my direct address.

I have to say that in the 10 years Ive been providing IPPBX systems the abilty to call a sip address just doesnt come up, calling a skype address is a different matter that gets asked all the time at the moment.

Ian

Sure, and that’s why I also have a Broadvoice trunk with a regular phone number. Why not use both? I mainly want SIP addresses to be able to call partners / employees / friends. I also want them for chat use. Ekiga is a fine chat client; why not have chats go peer-to-peer?

Because, I don’t want to have to add every address I call to the Asterisk system. Users should be able to just type it in to their existing SIP phones, which are Ekiga, Aastra, and snom. All of those easily support entering addresses.

I don’t have the M3, I have the snom 370. It’s super-easy to dial by address on it, or to enter an address in its speed dial. Also it’s no problem for our CRM system to send a dial command that includes an address.

No reason not to have both systems, but obviously, an address such as joe@mycompany.com is easier to remember than a 10-digit phone number. I’m not advocating that people cancel their PSTN service. Maybe in 20 or 30 years, but not now.

For us it would be great, and it seems ridiculous that Asterisk blocks this usage, when (according to the manual) Asterisk is inspired by a new vision of telecommunication, including using alphanumeric addresses, and generally allowing users to do things that are beyond the PSTN carriers.

Adding a snip of code to store the full dialed address in some variable seems like it would be a very small change to Asterisk and it would allow people to build a communications network entirely free of PSTN carriers. Ok, that’s not ready to replace your PSTN dial-in numbers, but could be tremendously useful within an organization, or for communicating with partners, and so on. I could imagine even government entities wanting to set that up.

I will pull you up on it being easy to enter a domain address on an Aastra.

Having deployed 100’s of all types of aastra handset it is not simple to enter a alpha address into one compared to numeric one.

Im sorry to say but it all comes down to scale, In a small business that only has a few users then yes its possibel to use names, But scale up to a business that has 100 + users its becomes unworkable. listing an address such as bob@biz.com is fine till bob leaves then you have to deal with teh calls to the job function that bob did.

Ian