Linux-Call-Router HOWTO

This is a simple step-by-step instruction to get LCR running quickly. The full documentation is still essential to learn and understand all features. I suggest to read this overview first and then read the full documentation for details.

Table of contents:

1. What you need
2. Downloading
3. Compile
4. Configure
5. Run LCR
6. Asterisk

1 What you need:

These parts are needed to use LCR:
The 'mISDN' kernel driver is the next generation ISDN driver that will replace 'HiSax' driver. Don't be confused, but the mISDN-API for LCR has changed. First mISDN was available from user space via device. The current API will provide a socket interface. The mISDN driver will be part of the Linux kernel.

The mISDNuser package is developed with the mISDN kernel driver.

To connect PBX4Linux to a telephone line or to connect a telephone to it, an ISDN card is needed that is supported by mISDN. These cards are supported:
The HFCS-PCI cards are the cheapest ones, because they are used for budget card and offer large fifos.

To connect a telephone to PBX4Linux, a second ISDN card is needed. If no external line should be used, one card is enough of course. The card must be capable of NT-Mode. This mode allows to connect telephones as the card would be an NT. The NT-Mode is also supported by the library that comes with 'mISDNuser'.

In order to connect a telephone directly to a card, you need to:
All can be done easily by using an old NT. If you don't know what to do now, read the documentation on how to do this in details. Here is an easy way on doing it, if you wan't to start quickly:
NOTE: Ethernet cross link cables don't work, because they use differen pairs than ISDN does.

Plug one end of your new cross link cable to your ISDN card that should run in NT-Mode, and one to your telephone. If you need external power supply, connect an old NT to your ISDN card using the cross link cable, and your telephone with a NORMAL ISDN (or Ethernet) cable to your NT, using the second plug.

This is all you physically need, now get the software and get it to work.

2 Downloading:

Visit the homepage and get a suggested snapshot:

3 Compile:

Before you compile, you need to check, if your Linux kernel already has mISDN. If so, you may skip the installation of mISDN kernel driver. If not, you must provide the latest stable kernel source and the latest mISDN package. Please install a kernel from source, boot it and then continue to install the mISDN modules. Unpack mISDN and install the modules:
$ tar -xvzf mISDN-x.xx.tar.gz

$ cd mISDN

$ make

$ make install
Note: If you have already some version of mISDN, the installed modules will have lower priority than the kernel modules. In this case you must remove mISDN directory from your kernel modules tree, if you like to upgrade to a newer mISDN version.

Alternatively you may have mISDN already in your kernel tree. Do this in this case:

You need to do the following konfigurations in your kernel config:
*** TBD ***
Be sure to compile them as modules. Select the cards you need (maybe all, since they are only loaded when needed).

Compile your kernel as usual, reboot and test it.

In order to provide Layer-3 protocol and tools, install mISDNuser package:
$ tar -xvzf mISDNuser-x.xx.tar.gz

$ cd mISDNuser

$ make

$ make install
An importaint librariy will be created:

Compile LCR:

$ tar -xvzf lcr-xxxxxxxx.tar.gz (or better get from git archive)

$ cd lcr

$ ./configure

$ make

$ make install
Configuration files will be installed at "/etc/lcr/". Sound files will be installed at: "/share/lcr/". Extension's data file will be stored at: "/var/lib/lcr/". Don't worry about your old configuration files, you might already have from older version. New files will only be installed, if they don't exist already. If they don't exist, default configuration files will be installed. The binaries are installed in "/usr/local/bin" by default.

4 Configuration:

Begin with creating an rc-script that is used to start and stop mISDN driver. Follow the instruction there. 'genrc' will ask for the locations of the modules. If you have problems with that, refer to the documentation. Run it with:
$ genrc
Execute 'lsmod' and see if all modules are loaded. Importaint is 'mISDN_core", the mISDN driver itself. Also importaint is 'mISDN_dsp', which will feature audio/hdlc bridging and handling. Without, LCR will not work. Also an ISDN interface driver must be loaded. In this example, we have two HFCS-PCI cards, so we loaded 'hfcpci' module.
$ lsmod
Module                  Size  Used by
hfcpci                 28300  0
mISDN_dsp             203600  0
mISDN_core             80396  17 mISDN_dsp,hfcpci
After your mISDN start scrip is generated, start it with "sh <script name> start". Be sure that the mISDN-modules are loaded. Check syslog for details.

The first thing will be to query the current available isdn ports:
$ lcr query
** Linux-Call-Router **  Version XXXX

Port  1 name='hfcs-pci.1': TE/NT-mode BRI S/T (for phone lines & phones)
  - 2 B-channels
Port  2 name='hfcs-pci.2': TE/NT-mode BRI S/T (for phone lines & phones)
  - 2 B-channels
In this case there are two ISDN cards available with mISDN driver. Both cards can run in TE-mode or NT-mode. The NT-mode is used to connect telephones to it. The TE-mode is used to connect your ISDN line to it. LCR will select the desired mode.

You need to edit "interface.conf" which is found in the installation directory ("/etc/lcr/"). Here is an example what to do add:
port 1

msn 200,201,202,203
port 2
The first interface is called "Ext" and uses port 1 only, the second interface is called "Int" and uses port 2 only, run in NT-mode, also it accepts only calls from extensions with MSN number 201, 202 and 203 only.

Edit "routing.conf" which is found in the installation directory ("/etc/lcr/"). It will define all numbers that can be dialed from external or internal phones. For this tutorial we just want to dial external, dial internal, and dial test mode. Don't delete anything from this file, just consider the following dialing codes:
dialing=1234	: intern extension=200

dialing=0	: extern
dialing=200	: intern
dialing=201	: intern
dialing=99	: test
In both version we dial '0' to make an external calls. '200' will make an internal call to extension '200', '201' respectively. Dialing '99' will dial the test mode.
When an external call is received, the destination number is 'dialed' by the caller. For a normal multipoint ISDN line you will get some "MSN" numbers from your provider. In our case one is "1234". This number will be mapped to the internal extension 200. Other numbers may be used for other entensions or functions.

The last thing is to create and configure the extension. In our case we want to give our internal phone the extension number '200'. Because we have only one internal port available in this example, we need to give only the port number "1". Now incomming calls will ring on internal port "1". Our external phone number is "1234". The extension will then use it as outgoing caller ID for external calls. Run the genextension tool:
$ genextension 200 1 1234
The result and many more options are in "extensions/200/settings" which is found in the installation directory ("/var/lib/lcr/").

Also be sure to program extension number '200' in your ISDN telephone for incomming and outgoing calls.

5 Run LCR:

$ lcr fork
Now LCR will start. Just enter "lcr" without any option for a list of options. If libraries or modules are missing, or errors in config files are found, you will now get notice about it. Correct the errors and start again.

Pick up your phone and see if you get a dial tone. If you don't hear anything, check cabeling and be sure to be connected to your internal ISDN port. Also do some state debugging, as explained below. If you hear an announcement, you might have not set the correct extension number '200'. Check MSN number of your telephone.

If you get a dial tone, dial "995". The test mode with test #5 will be called. You should now hear the 'call on hold' music. Now hang up and try to dial externally using prefix '0'. Call somebody who calls you back for incomming call test.

$ lcradmin state
This tool is usefull to get an overview of what LCR is doing. It also shows the state of all calls and ISDN ports. Also it shows the tail of the log file. Some hotkeys in the bottom line will change detail level.

6 Asterisk:

LCR is not only a stand allone ISDN PBX. You can use it as channel driver for Asterisk PBX. The channel driver is called chan_lcr and is a replacement of chan_mISDN. When using configure, add "--with-asterisk". If Asterisk is installed, the configure script should automatically detect Asterisk and enables support. Then compile and install. The chan_lcr will be installed and loaded next start of Asterisk.

To use Asterisk, you need to define an interface. Edit "interface.conf" which is found in the installation directory "/etc/lcr/".

remote asterisk
context from-lcr
earlyb yes
tones yes
Additionaly you must route calls to Asterisk. This is done using "routing.conf".

interface=ast			: intern
#example 1
interface=Int			: extern interfaces=ast
#example 2
interface=Ext dialing=5678	: extern interfaces=ast prefix=5
... other rules
The first example will route all calls from interface Int to Asterisk. There is no prefix given, so the extension at Asterisk is defined by the dialed digits. The second example will route an external call from interface Ext to MSN number 5678 to Asterisk. The "prefix" is used to define extension digits at Asterisk. The context at Asterisk will be "from-lcr".

Now you may add your extension to "/etc/asterisk/extensions.conf":

In this case, all calls to extension "5" will be forwarded to chan_sip and call whatever you specified for "phone". Please refer to Asterisk's documentation.

Alternatively you can route all calls from one interface. If you have an internal interface for you phone and like to route all calls from it to Asterisk, add "bridge" keyword to "interface.conf" of LCR.

msn 200,201,202,203
port 2
bridge ast
All calls from interface Int will be routed to interface ast, which means all calls from internal phone will be routed to Asterisk. The dialed number defines the extension.

In order to receive calls from Asterisk, you must define the extension in the dial string. Edit "/etc/asterisk/extensions.conf" and add your extensions to your context (e.g. "my-context"):

Dialing "5" or "6" will do a SIP call. Dialing "8" will do a call to LCR using interface "ast". A call from asterisk dialing "0", will get forwarded to LCR using interface "ast2", if defined. It is possible to define multiple interfaces for Asterisk.

To dial from Asterisk to LCR, use the following syntax:


Where "interface" is the Asterisk's interface name used on LCR side. Where "number" is the number to be dialed. For "options" refer to the full documentation.

This was too fast and you still have problems? Drop me a mail with improved guide.