call an Asterisk server dynamically using IAX without having a VOIP gateway account?

Posted on 2006-05-16
Last Modified: 2008-01-09
Hi everyone!

I have created an Asterisk server, primarily using IAX2 softphones (idefisk from, highly recommended!)

I have extensions both locally and remotely logged in to it.

I want to dial another asterisk server using one of the logged in extensions.

I know the IP address of the other asterisk server, but I want to be able to add that into the dial string.  So far, this hasn't worked!  I just get facility not subscribed on the IDEFISK software.

Am I going to have to sign up for a VOIP provider account?

I thought Asterisk would have the capability of being a gateway itself and be able to dial other asterisk servers on the internet, when the dialstring is presented with an appropriate extension and ip address?

Hope someone can help me!

Thanks for reading!

Kind regards,

Question by:SixGunZ
    LVL 36

    Expert Comment

    It works fine for me but I am using the DNS name instead of the IP address :-

    exten => _6XXX,1,Dial(IAX2/${EXTEN},60,tT)
    LVL 36

    Expert Comment

    In the above example extn-no is the remote user on the asterisk server and the password is the password for that user account.

    A better way is to put an entry in iax.conf and change the dial command slightly. This enables you to specify additional options like different codecs. For example :-


    then the dial would become :-
    exten => _6XXX,1,Dial(IAX2/extn-no@remote/${EXTEN},60,tT)


    Author Comment

    Thanks for that!

    Does this mean I need an entry for each ext and dns entry though?

    I was hoping there was some form of transparent dial through IAX solution.  This looks like I need to prepare an entry for each ip where there is an asterisk server?

    LVL 36

    Expert Comment

    Yes you need an account on the asterisk box which is being called in order for the call to be authenticated. You can permit ananymous access and bypass this but I would not recomend it. You can also restrict access by source IP address instead of having to configure a username/password but in reality it makes little difference to the configuration.

    You might also wish to have a look at IAX trunks ( which improves the efficincy if you have multiple calls between two asterisk servers. It effectivly reduces the bandwidth used.

    Author Comment

    Hmmmm......  A little confused....

    Okay, let me give you an example of what I'm after:

    I know of several companies, who use asterisk as a voip-pbx gateway (just as I'm doing at the mo)

    We want to interconnect these businesses using IAX, but don't want to create accounts for each business on each server.

    I would like to send a company my details, for them to dial me, something like:


    Then they tap this number into their idefisk (softphone) and hey presto, it dials me by finding port 4569 mapped to my asterisk server and then finding me as 201 behind that!

    If necessary, I would enable guest login for this.  Er, how is that done?  Looked at the documentation, but to be honest, it's rocket science to me!!

    I think I may be chasing rainbows, but if it can be done, then I would be over the moon (er, or the rainbow!!)

    Thanks in advance,

    LVL 36

    Expert Comment

    Have a look at

    On each asterisk server all you need to do is create an entry like :-


    Then anyone can connect and the calls come into the [guest] context in extensions.conf.
    You will want to organise the different contexts and inclusions so that people coming into guest can only dial internal extensions and not make onward calls back out your PSTN for example.

    Author Comment

    Okay...  Getting there.  Thanks for that - it actually makes a bit of sense to me!

    Now - outbound dialling.....

    If I want to dial another asterisk server, how do I do that from my softphone?  The documentation explains that macros have to be written to match a dial pattern, which in turn will dial a specific server.

    How do I specify the username/password/server/extention from the softphone client?  I have tried putting a dial pattern in outbound routes as ".@." which should have matched a pattern of say, but the pattern is invalid - it wont let me use it!!  Guess numbers are all it will allow...

    If that is the case, how on earth do you specify a server to dial without using a macro to dial a specific server?
    LVL 36

    Expert Comment

    The best way is to define a local prefix for remote locations. For example use the prefix 8 for a remote internal call. Then use a 2 digit destination code followed by that destinations local extension.
    For example if you want to dial extension 6000 at siteA which has a location code of 01 you would dial :-

    The dial command to match this in extensions.conf would be :-
    exten => _801.,1,Dial(IAX2/guest@sitea/${EXTEN:3},60,tT)

    ${ENTEN:3} means the number dialed with the first 3 digits removed.
    _801. means its a expression (_) followed by 801 followed by any number of digits (.)

    Author Comment

    Almost there.......

    Okay, how about the "sitea" part?

    How can I define that in the dial string?

    If I know an asterisk server exists at an IP address of say,, how can I enter that as a dialstring on the softphone?

    The above example will always assume that 01 is sitea, which is okay, but this could become a very large list to control.


    exten => _801.,1,Dial(IAX2/guest@sitea/${EXTEN:3},60,tT)
    exten => _802.,1,Dial(IAX2/guest@siteb/${EXTEN:3},60,tT)
    exten => _803.,1,Dial(IAX2/guest@sitec/${EXTEN:3},60,tT)
    exten => _804.,1,Dial(IAX2/guest@sited/${EXTEN:3},60,tT)
    exten => _805.,1,Dial(IAX2/guest@sitee/${EXTEN:3},60,tT)
    exten => _806.,1,Dial(IAX2/guest@sitef/${EXTEN:3},60,tT)
    exten => _807.,1,Dial(IAX2/guest@siteg/${EXTEN:3},60,tT)
    exten => _808.,1,Dial(IAX2/guest@siteh/${EXTEN:3},60,tT)
    exten => _809.,1,Dial(IAX2/guest@sitei/${EXTEN:3},60,tT)
    exten => _810.,1,Dial(IAX2/guest@sitej/${EXTEN:3},60,tT)


    Is this how asterisk works?
    LVL 36

    Accepted Solution

    Yes that is correct. In addition you will need entries in iax.conf like :-


    That way extensions.conf is where you define all the destinations and iax.conf is where you define the IP addresses and different codecs to use if you wish.

    Author Comment

    Hmmm......  Okay, I guess I'll leave it there then!

    My thanks to you grblades for your kind help.

    I thought asterisk, being so advanced in so many fields, would have been capable of dynamically setting IP addresses in a dialout field.

    it seems the most logical step in the IAX progression.

    It would make so much sense, because you already know the details to route to an extention:

    extention@ip number

    you would set a guest context for incomming calls based on this format to be secure.

    The advantages could be that a client could be non-authenticated (running a softphone unregistered), which would look like an extention on your broadband dhcp ip, and dialing an asterisk would announce you as an external ip to the asterisk server (ergo remote ip) and route you to the guest context.  Same for other extentions registered to asterisk servers.

    Make sense?

    Anyways, just a thought!
    LVL 36

    Expert Comment

    You should be able to do something like this and not have any extra entries in iax.conf :-
    exten => _801.,1,Dial(IAX2/guest@${EXTEN:3},60,tT)

    The disadvantage of doing it this way is that the default IAX settings are always used so you cannot overide codecs or enable/disable the jitter buffer for specific destinations. This is why I recomended you do it the other way.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    In my office we had 10 Cisco 7940G IP phones that were useless as they were showing PROTOCOL APPLICATION INVALID when started. I searched through Google and worked for a week continuously on those phones, and finally got them working. This is a di…
    Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now