Asterisk with Ackermann Euracom

Using an old Ackermann Euracom 180 (or similar) as an 8-way analog adapter with direct dial-through to each individual analog port is pretty straightforward once you get all the bits and pieces together.

The idea is as follows. Many SIP providers e.g. sipgate.de in Germany give you only one free POTS number that can be dialed from everywhere, e.g. 01234-567891. Interestingly, and I think this is due to SER being used as a SIP router, they will send even more digits that were dialed to you in the SIP To: header. So if a caller dials 01234-567891-12, the INVITE contains the To: header "<sip:49123456789112@sipgate.net>". This means we can set this up like a point-to-multipoint PBX with direct dial-through to every ISDN PBX port (in this example, 12). Don't worry, we're not screwing them. In Germany, SIP providers get a fee from Deutsche Telekom for routing inbound and outbound calls so they do get $$$^H^H^H€€€ for every call they process.

Very nice. But — the production versions of Asterisk don't provide the actual incoming number in extensions.conf. ${EXTEN} is either "s" if you register without an explicit extension, or it is the extension you declare in the register statement in sip.conf (the part after the '/'). It's never the actual number we are called with. Asterisk-CVS already contains an application SIPGetHeader that gives you access to each and every header in the current INVITE. Not so asterisk-1.0.x.

Anyway - you'll need an HFC based ISDN card. Be sure to get the latest bristuff package for the HFC card. Let the bristuff scripts download and patch the Asterisk, libpri and zaptel sources, then apply this patch (derived from the original SIPGetHeader patch in bug #0002838 and adapted for a bristuffed asterisk-1.0.8). Compile, stir well and install. This version of Asterisk now lets you access the To: header of the current INVITE.

First, set the HFC card up in TE or NT mode as described in Asterisk zaphfc. For now, I use a second ISDN S0 module for connecting to my Asterisk, and the primary ISDN S0 bus connects to the outside ISDN via the NT. The HFC card runs in TE mode and its ISDN port is connected to the secondary ISDN port of the PBX with a normal ISDN cable, i.e. no crossover. Be sure to check the Ackermann installation manual to get the pinout of the secondary ISDN port.

Now set up DISA in extensions.conf like

[from-isdn]
exten => 22,1,DISA(no-password|externlcr)

[from-isdn] is the context all incoming zaphfc calls are put in. externlcr is a context that uses the cheapest VoIP provider depending on the target number.

This way, if I dial a "0", I get to the ISDN outside line, if I dial "22", I get a dialtone from Asterisk using DISA. Alternatively, you could run the card in NT mode and use an x-over cable to the primary PBX ISDN port. Maybe I can get an automatic outside line this way — I didn't try this yet.

You need to make sure that port 22 in this example cannot by any chance be reached from the outside ISDN because this might lead people to misusing your Asterisk as a free international gateway... (:eek:) So double check your ISDN PBX's internal call distribution and make sure no MSN connects to #22.

Set up an incoming context for SIP calls from your provider. Mine is [from-sip]:

[from-sip]
exten => s,1,SIPGetHeader(Var_TO=To)
exten => s,2,agi,sip_to|${Var_TO}|16|@

You need to clip off the leading characters from ${Var_TO} up to but NOT including the last digit of your official POTS number, as well as the trailing characters starting with the '@'. With the example shown on top of the page, you would clip off 16 characters ("<sip:49123456789") from the left and everything starting with "@" from the right. The sip_to args would then be "sip_to|${Var_TO}|16|@". You need to adapt the sip_to arguments to whatever your SIP provider sends you. Use the "sip debug" function on the asterisk console to find out.

I found it easier to write a small AGI program to do that for me than fiddling with Asterisk expressions. Put it in /var/lib/asterisk/agi-bin, compile and you're all set. The AGI clips off all the junk and sends us to the context [to-isdn]:

[to-isdn]
exten => 1,1,Dial(Zap/g1/11,30,r)
exten => 1,2,Congestion
exten => 1,102,Busy
exten => _11[1-8],1,Dial(Zap/g1/${EXTEN:1},30,r)
exten => _11[1-8],2,Congestion
exten => _11[1-8],102,Busy

Voila. 01234-567891 will be sent to ISDN PBX port 11 which is my master telephone at my working desk, as well as 01234-567891-11. 01234-567891-12 is another phone, etc. The first exten in [to-isdn] shows you how I use the trailing digit ('1') of my official POTS number to get to my master phone #11. You need to put in there whatever the last digit of your phone number is.

And as if this weren't enough, I declared some softphones as extensions -31, -32, etc. With the method outlined above, you can reach them directly as well. You're not limited to just two digits for an extension so feel free to experiement.

There's one downside to this solution. Technically, Asterisk is phone #22 for the ISDN PBX. This means, the ISDN PBX doesn't get any callerid information from Asterisk. So even if you have callerid capable analog phones you don't see who calls you. I hope this is different when using the HFC card in NT mode. Any hint how to configure Asterisk to make sure callerid is sent to ISDN is welcome!

Next on the schedule is replace the outside ISDN line with an ordinary analog line simply because it's cheaper. For now, there are very few offerings in Germany that separate the DSL account from the normal telephone contract and those that do don't have competitive prices or aren't available on my region. So the best solution is DSL + analog + Asterisk with an internal LCR. The remaining analog port will accomodate my fax and serve as the emergency line for 112 (US: 911) because 112 isn't accessible via VoIP everywhere here.

Happy hacking!



Edit Oct 9, 2005: It seems that the above solution isn't possible everywhere. I've got two messages saying people get "no such user" (or similar) messages when appending digits to the official DID. I can only speculate what happens here. Sipgate (and other providers offering DIDs in your home phone net) need to buy complete number blocks from the local telecom provider (in most cases, German Telekom). I can imagine differences in the phone circuitry - some circuits may route additional digits, others may block them and issue the error message. Somebody called me on my official Sipgate DID, appending -17 for my fax just for testing. I got the call on my primary extension, and the SIP log did not show the additional digits. Very strange. So maybe I'm just lucky, I don't know.

So - I'd really appreciate some more people testing this feature and telling me what happens. You don't need to apply the whole yadda-yadda above. Just fire up asterisk, start "sip debug peer sipgate" and dial your number from another phone, plus two or three more digits. If you see them, it should work for you.








Using an old Ackermann Euracom 180 (or similar) as an 8-way analog adapter with direct dial-through to each individual analog port is pretty straightforward once you get all the bits and pieces together.

The idea is as follows. Many SIP providers e.g. sipgate.de in Germany give you only one free POTS number that can be dialed from everywhere, e.g. 01234-567891. Interestingly, and I think this is due to SER being used as a SIP router, they will send even more digits that were dialed to you in the SIP To: header. So if a caller dials 01234-567891-12, the INVITE contains the To: header "<sip:49123456789112@sipgate.net>". This means we can set this up like a point-to-multipoint PBX with direct dial-through to every ISDN PBX port (in this example, 12). Don't worry, we're not screwing them. In Germany, SIP providers get a fee from Deutsche Telekom for routing inbound and outbound calls so they do get $$$^H^H^H€€€ for every call they process.

Very nice. But — the production versions of Asterisk don't provide the actual incoming number in extensions.conf. ${EXTEN} is either "s" if you register without an explicit extension, or it is the extension you declare in the register statement in sip.conf (the part after the '/'). It's never the actual number we are called with. Asterisk-CVS already contains an application SIPGetHeader that gives you access to each and every header in the current INVITE. Not so asterisk-1.0.x.

Anyway - you'll need an HFC based ISDN card. Be sure to get the latest bristuff package for the HFC card. Let the bristuff scripts download and patch the Asterisk, libpri and zaptel sources, then apply this patch (derived from the original SIPGetHeader patch in bug #0002838 and adapted for a bristuffed asterisk-1.0.8). Compile, stir well and install. This version of Asterisk now lets you access the To: header of the current INVITE.

First, set the HFC card up in TE or NT mode as described in Asterisk zaphfc. For now, I use a second ISDN S0 module for connecting to my Asterisk, and the primary ISDN S0 bus connects to the outside ISDN via the NT. The HFC card runs in TE mode and its ISDN port is connected to the secondary ISDN port of the PBX with a normal ISDN cable, i.e. no crossover. Be sure to check the Ackermann installation manual to get the pinout of the secondary ISDN port.

Now set up DISA in extensions.conf like

[from-isdn]
exten => 22,1,DISA(no-password|externlcr)

[from-isdn] is the context all incoming zaphfc calls are put in. externlcr is a context that uses the cheapest VoIP provider depending on the target number.

This way, if I dial a "0", I get to the ISDN outside line, if I dial "22", I get a dialtone from Asterisk using DISA. Alternatively, you could run the card in NT mode and use an x-over cable to the primary PBX ISDN port. Maybe I can get an automatic outside line this way — I didn't try this yet.

You need to make sure that port 22 in this example cannot by any chance be reached from the outside ISDN because this might lead people to misusing your Asterisk as a free international gateway... (:eek:) So double check your ISDN PBX's internal call distribution and make sure no MSN connects to #22.

Set up an incoming context for SIP calls from your provider. Mine is [from-sip]:

[from-sip]
exten => s,1,SIPGetHeader(Var_TO=To)
exten => s,2,agi,sip_to|${Var_TO}|16|@

You need to clip off the leading characters from ${Var_TO} up to but NOT including the last digit of your official POTS number, as well as the trailing characters starting with the '@'. With the example shown on top of the page, you would clip off 16 characters ("<sip:49123456789") from the left and everything starting with "@" from the right. The sip_to args would then be "sip_to|${Var_TO}|16|@". You need to adapt the sip_to arguments to whatever your SIP provider sends you. Use the "sip debug" function on the asterisk console to find out.

I found it easier to write a small AGI program to do that for me than fiddling with Asterisk expressions. Put it in /var/lib/asterisk/agi-bin, compile and you're all set. The AGI clips off all the junk and sends us to the context [to-isdn]:

[to-isdn]
exten => 1,1,Dial(Zap/g1/11,30,r)
exten => 1,2,Congestion
exten => 1,102,Busy
exten => _11[1-8],1,Dial(Zap/g1/${EXTEN:1},30,r)
exten => _11[1-8],2,Congestion
exten => _11[1-8],102,Busy

Voila. 01234-567891 will be sent to ISDN PBX port 11 which is my master telephone at my working desk, as well as 01234-567891-11. 01234-567891-12 is another phone, etc. The first exten in [to-isdn] shows you how I use the trailing digit ('1') of my official POTS number to get to my master phone #11. You need to put in there whatever the last digit of your phone number is.

And as if this weren't enough, I declared some softphones as extensions -31, -32, etc. With the method outlined above, you can reach them directly as well. You're not limited to just two digits for an extension so feel free to experiement.

There's one downside to this solution. Technically, Asterisk is phone #22 for the ISDN PBX. This means, the ISDN PBX doesn't get any callerid information from Asterisk. So even if you have callerid capable analog phones you don't see who calls you. I hope this is different when using the HFC card in NT mode. Any hint how to configure Asterisk to make sure callerid is sent to ISDN is welcome!

Next on the schedule is replace the outside ISDN line with an ordinary analog line simply because it's cheaper. For now, there are very few offerings in Germany that separate the DSL account from the normal telephone contract and those that do don't have competitive prices or aren't available on my region. So the best solution is DSL + analog + Asterisk with an internal LCR. The remaining analog port will accomodate my fax and serve as the emergency line for 112 (US: 911) because 112 isn't accessible via VoIP everywhere here.

Happy hacking!



Edit Oct 9, 2005: It seems that the above solution isn't possible everywhere. I've got two messages saying people get "no such user" (or similar) messages when appending digits to the official DID. I can only speculate what happens here. Sipgate (and other providers offering DIDs in your home phone net) need to buy complete number blocks from the local telecom provider (in most cases, German Telekom). I can imagine differences in the phone circuitry - some circuits may route additional digits, others may block them and issue the error message. Somebody called me on my official Sipgate DID, appending -17 for my fax just for testing. I got the call on my primary extension, and the SIP log did not show the additional digits. Very strange. So maybe I'm just lucky, I don't know.

So - I'd really appreciate some more people testing this feature and telling me what happens. You don't need to apply the whole yadda-yadda above. Just fire up asterisk, start "sip debug peer sipgate" and dial your number from another phone, plus two or three more digits. If you see them, it should work for you.








Created by: hmilz, Last modification: Sun 09 of Oct, 2005 (14:28 UTC)
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+