All of the instructions you see online are for much older versions of Asterisk. It makes sense, as a phone system is always highly customized and can get very complicated, very quick. It’s hard to upgrade an in-place system to a newer version, especially in Asterisk’s case where the newer stuff broke a lot of the old stuff. However, for a new setup, why not use the latest and greatest? More security fixes, more features, and hopefully less bugs. The downside? There isn’t much documentation out there for things on the newer systems yet. This means learning from scratch and adapting!

Thankfully, once I learned a little more about how to use extensions.conf and iax.conf, it appears trivial to get a C*Net connection going (although this is after 10+ hours of head abuse by scratching and banging, and elevated blood pressure).

So let’s get started!

C*NET Side:

You have to register and activate your office code first. When all is said and done, you will receive your e-mail from one of the great people over on that side with your activation information. If you haven’t received this e-mail yet, receiving calls won’t work. It’s part of a manual entry process on their Asterisk server to allow connection to yours (it maps your office code to your IP). The most important information from this e-mail is your username. Of course your country code, office code, and thousands block are also good things to know.

Networking Side:

You MUST have port 4569 UDP opened/forwarded to your Asterisk box. You can call out to C*Net without this port opened, but you cannot receive calls. It’s a fairly obscure port number, so security wise it probably won’t be subjected to much abuse, but make sure you have something like fail2ban in place to help with security.

Asterisk Side:

First, make sure the IAX2 module is loaded:

asterisk*CLI> module show like iax
Module                         Description                              Use Count  Status      Support Level
chan_iax2.so                   Inter Asterisk eXchange (Ver 2)          0          Running              core

If it’s not loaded, make sure you don’t have it as a noload line in modules.conf. If you are like me, you might have disabled it along with a host of others.

IAX.CONF:

Next, edit iax.conf to give IAX a route into your extensions.conf. The [username] context must be changed to the username you received in your e-mail.

[general]
bandwidth=medium
disallow=all
allow=ulaw
jitterbuffer=no
tos=0x12
calltokenoptional=0.0.0.0/0.0.0.0
requirecalltoken=no
autokill=yes

[username]
type=user
context=from-cnet
sendani=yes

Note: context can also be changed to whatever context you want in extensions.conf, however I would recommend using one specifically for C*Net, for reasons you will see next. Double check to make sure the names match.

 

EXTENSIONS.CONF:

On to the potatoes of the meat and potatoes.

In the [globals] context, add the following:

CNETANI=16361000
MYNAME=Big Bird

Change the CNETANI to be whatever yours is. country code + office code + thousands block. Also change MYNAME to your name.

Now, add a new context for the macro that will actually do the dialing out to C*Net. This macro is a heavily modified version of one from Los Angeles Telephone to work with the newer versions of Asterisk. It will not work in versions like 1.8.

[macro-dialcnet]
exten => s,1,Set(CALLERID(num)=${CNETANI})
exten => s,n,Set(result=${ENUMLOOKUP(+${ARG1},iax2,,1,std.ckts.info)})
exten => s,n,GotoIf($["${result}"!=""]?dialiax)
exten => s,n,Set(result=${ENUMLOOKUP(+${ARG1},sip,,1,std.ckts.info)})
exten => s,n,GotoIf($["${result}"!=""]?dialsip)
exten => s,n,Playback(enum-lookup-failed,noanswer)
exten => s,n,Congestion(10)
exten => s,n,MacroExit
exten => s,n(dialsip),Dial(SIP/${result},120)
exten => s,n,MacroExit
exten => s,n(dialiax),Dial(IAX2/${result},120)
exten => s,n,MacroExit

Basically, it uses something called ENUM lookup to get all the IAX (or SIP) information that Asterisk needs to complete the call to C*NET using the DNS name of std.ckts.info so you don’t have to keep track of IP addresses. This particular macro tries an IAX connection first, tries a SIP connection as a fallback, and then finally fails with a failed lookup message.

Now that we have the macro set up, receiving in and dialing out capabilities can be added. Dialing out uses this macro.

Receiving calls:

Earlier in iax.conf the context “from-cnet” was defined, so that is next to be added:

[from-cnet]
exten => _X.,1,NoOp(Incomming call from C*NET: ${CALLERID(all)})
exten => _X.,n,GoTo(from-internal,${EXTEN:-3},1)

A couple important notes with this section:

The first line is just for my debugging and flow following process. NoOp just simply spits out to console/log what you tell it to. You can completely remove the first line if you would like, just change the n to 1 on the second line if you do so.

The second line forwards the call to another context, which in my case is “from-internal”. Change this to whichever context you use for your extensions. This is useful so you don’t have to define them again. The -3 part of ${EXTEN:-3} tells it to forward the last 3 numbers of the call, since I use 3 number extensions. Change it to 2 to only forward the last 2, etc. For example, if you dial 1-636-1112, it goes to the from-internal context with the digits 112.

Sending calls:

Here we just need to add a few quick lines. These are in my “from-internal” context, but can be place in whichever context you have set up for dialing out definitions.

; Dial out to C*NET
exten => _7X.,1,NoOp(Dialing out from ${CALLERID(all)} to ${EXTEN:1} through C*Net)
exten => _7X.,n,Macro(dialcnet,${EXTEN:1})
exten => _7X.,n,Playtones(congestion)

A couple important notes:

The first line again is just for debugging/logging. The same modification can be made if desired.

Because I have a few different ways to make calls outbound of my Asterisk, I am now on “dial 7 to get an outside line” for C*Net. I can also dial 8 to dial out on my cell phone (via x-link Bluetooth), and dial 9 to dial out on my VOIP line (I know, getting out of control!).

Finally, save your extensions.conf, reload the IAX module and the dialplan:

asterisk*CLI> module reload chan_iax2.so

asterisk*CLI> dailplan reload

 

Troubleshooting:

“CAUSE: No such context/extension”

This is most likely an error in your extensions.conf. Even if you have a NoOp command as the very first line, it won’t spit anything out unless there is something correctly configured to do after. In my case, I had assumed I would at least see output from the NoOp command, and that was incorrect and caused hours of high blood pressure.

“CAUSE: No authority found.”

This is an error in the iax.conf configuration. In C*Net’s case, there must be a context with the correct username, and type must be equal to user (type=user).

Done!

That’s it! Enjoy C*Net and the great people that are part of it. Don’t forget to sign up for the mailing list. There are a lot of very smart people on it, and most with 20+ years of industry experience.

https://www.ckts.info/