Asterisk LCR 
Vorschläge oder Erweiterungen könnt Ihr gerne per Email mitteilen.


Das Asterisk-LCR besteht aus mehreren Komponenten. Der erstellten LCR Tabelle von Telefonsparbuch und den PHP-Scripten von Eric Berberich (allesOK im ip-phone-forum.de), welche das automatische Update der LCR Daten anhand der gespeicherten Optionseinstellungen vornimmt und das LCR Routing entsprechend der erhaltenen LCR Steuerdatei durchführt.


Download the Asterisk lcr-package

Latest Release: Older Versions:

The package contains the following files

  • /etc/asterisk/lcr
    • extensions.tsblcr: Macro plus short tutorial
    • tsblcr.cfg: Config demo (downloaded from telefonsparbuch.de)
    • tsblcr.routing: Routing demo (downloaded with the help of tsblcrupdate.php)
    • tsblcrupdate.php: Skript to download the newest routing (tsblcrupdate config.cfg table.routing, see below for cronjobs)
  • /var/lib/asterisk/agi-bin
    • checksip.agi: Skript to test if a sip-peer is configured and connected
    • tsblcr.agi: The actual routing! Brings routing through macro into dialplan!!!
Perhaps you have to copy the files to your special directories ;-)

Cronjob update

Please use other times than the one given here, to spread all update requests over the day!!!
#> crontab -e
05 05 * * * /etc/asterisk/lcr/tsblcrupdate.php /etc/asterisk/lcr/tsblcr.cfg /etc/asterisk/lcr/tsblcr.routing
13 13 * * * /etc/asterisk/lcr/tsblcrupdate.php /etc/asterisk/lcr/tsblcr.cfg /etc/asterisk/lcr/tsblcr.routing
12 21 * * * /etc/asterisk/lcr/tsblcrupdate.php /etc/asterisk/lcr/tsblcr.cfg /etc/asterisk/lcr/tsblcr.routing


  • php4-cli (on debian as root: apt-get install php4-cli)
  • wget, bash, cp, mv
  • crontab -e

FILE: /etc/astersik/lcr/extensions.tsblcr


This file allows to use the least cost routing data provided by www.telefon-sparbuch.de (TSB) within the open source pbx asterisk. The following lines explain in a few steps how to include this LCR into your configuration: In your extensions.conf you should include this file with the #include command. This file contains a macro that interprets the variables set by the agi script tsblcr.agi. This agi script must be located in your asterisk agi-scripts directory, normally: /var/lib/asterisk/agi-bin The macro has at the moment 6 parameters. The first provides the number you want to call. The second determines the file that contains the actual routing table. This file will be automatically downloaded with your own configuration from telefon-sparbuch.de. See later for details. The remaining parameters are needed to set caller id number and name and to determine the outgoing line for pstn calls (if there is one) and one for the location of you sip.conf file. With the last parameter one can give a restarting point (context^exten^prio) if all providers have been tried, the user presses * or, the called party hangs up. This allows further calls/reactions after a call. At the end of the file you see a small demo, how to call the macro.

Downloading a routing file

Go to this webpage and create a profile that meet your requirements. The webpage is mostly self-explaining, but also has a detailed help. There are two things that are *-specific. The names for Sip-Providers. For the common public sip provider telefon-sparbuch.de offers a field, where you have to give the name how this specific provider is called in your sip.conf file. There is also a so called friends list. If you want to route special prefixes over non-public sip-providers you can define it here. For sip providers, you have the possibility to "rewrite" the number. Attention: Be careful with this feature. Let's habe a provider called 'mysip'. If this provider expects the number to dial in international format then you can indicate this by extending the provider name with the flag '/intl'. So type in the appropriate field: 'mysip/intl'. There is another possibility, which is for professional use only. The flag '/offset:length:string' rewrites the called number in the following way: Jump over the first 'offset' digits and replace the following 'length' digits with the characters defined in 'string'. Small example: 'mysip/0:1:+49' rewrites 089xxxx to +4989xxx, but it also rewrites 12345 to +492345. So again the warning: Please be carefull! In doubt leave it out! After telling Telefon-Sparbuch.de about your preferences, you should download the config file to a nice location on your hdd. I prefer /etc/asterisk/lcr/tsblcr.cfg, you can choose your own one. The last step is to set up a regular download for the actual routing data. You should use the provided script tsblcrupdate, which ensures that requests to telefon-sparbuch.de are not cumulative. It takes to arguments: the config file and the file where to store the routing data. The later file is needed to feed the macro.


./tsblcrupdate /etc/asterisk/lcr/tsblcr.cfg /etc/asterisk/tsblcr.routing For a regular update you can edit your crontab entries with 'crontab -e'. Not that it is enough to check two or three times a day for the newest routing data. And try to avoid update times, that a canonical: Do not use 12:00. Choose for such an entry a 'random' time! This ensures that the server is not overloaded and always provides you with the newest routing tables.

Impressum | Haftungsausschluß Copyright © 1998-2008 Telefon-Sparbuch

Seiteninhalt mit GZip um 67.47% komprimiert
(Seitengröße von 19.25Kb auf 6.26Kb komprimiert)