[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1209
  • Last Modified:

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

Hi everyone!

I have created an Asterisk server, primarily using IAX2 softphones (idefisk from asteriskguru.com, 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,

  • 7
  • 5
1 Solution
It works fine for me but I am using the DNS name instead of the IP address :-

exten => _6XXX,1,Dial(IAX2/extn-no:password@dns.name.of.server/${EXTEN},60,tT)
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)

SixGunZAuthor Commented:
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?

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

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 (http://www.voip-info.org/wiki/view/Asterisk+IAX+channels) which improves the efficincy if you have multiple calls between two asterisk servers. It effectivly reduces the bandwidth used.
SixGunZAuthor Commented:
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,

Have a look at http://www.voip-info.org/wiki/view/Asterisk+IAX+authentication

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.
SixGunZAuthor Commented:
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 201@asterisk.alchemy-uk.com, 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?
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 (.)
SixGunZAuthor Commented:
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?
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.
SixGunZAuthor Commented:
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!
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now