Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
h1. Goal (short description)

...



Goal of this HOWTO is to configure VoIP gateway between SIP and E1 using opensource PBX *Asterisk

...

Applicability

It is applicable for:

  • VoIP provider who wants to offer services for customers unsing EuroISDN PRI as conectivity to PSTN
  • Organisation whichs want to connect their existing PBX with EuroISDN PRI or QSIG port(s) to SIP provider
  • Organisation which wants to interconect two existing PBXes with EuroISDN PRI or QSIG connectivity using IP and SIP

Prerequisites (OS, dependencies on other software)

  • Server with some linux distribution
  • ISDN30 PCI card inside this server
  • PBX with EuroISDN or QSIG connectivity or EuroISDN PRI connectivity to PSTN

Configuration (OS agnostic)

Install Asterisk

First it is needed to install Asterisk. In most distributions, this should be easy because Asterisk is packaged with your distro. So use your distribution package manager to install. This howto is not made to focus on installation step. See 3.1.2. Setting up SIP voice services for an institution with Asterisk

Install HW drivers

You have to be sure that drivers for your ISDN PRI card are working. Simplest way is probably to install zaptel drivers (or it is together with your Asterisk package from your distro). See 3.1.2. Setting up SIP voice services for an institution with Asterisk

Ensure that hardware is working

If your hardware is working, you should be able to see something like:

Code Block
*. 

h1. Applicability

It is applicable for:
* VoIP provider who wants to offer services for customers unsing EuroISDN PRI as conectivity to PSTN
* Organisation whichs want to connect their existing PBX with EuroISDN PRI or QSIG port(s) to SIP provider
* Organisation which wants to interconect two existing PBXes with EuroISDN PRI or QSIG connectivity using IP and SIP

h1. Prerequisites (OS, dependencies on other software)

* Server with some linux distribution
* ISDN30 PCI card inside this server
* PBX with EuroISDN or QSIG connectivity or EuroISDN PRI connectivity to PSTN

h1. Configuration (OS agnostic)


h2. Install *Asterisk*

First it is needed to install *Asterisk*. In most distributions, this should be easy because *Asterisk* is packaged with your distro. So use your distribution package manager to install. This howto is not made to focus on installation step. See [3.1.2. Setting up SIP voice services for an institution with Asterisk]

h2. Install HW drivers

You have to be sure that drivers for your ISDN PRI card are working. Simplest way is probably to install zaptel drivers (or it is together with your *Asterisk* package from your distro). See [3.1.2. Setting up SIP voice services for an institution with Asterisk]

h2. Ensure that hardware is working

If your hardware is working, you should be able to see something like:
{code}
cat /proc/zaptel/1
Span 1: WCT1/0 Digium Wildcard TE110P T1/E1 Card 0 HDB3/CCS/CRC4
...
{code}
Please ensure that /proc/zaptel exists and that there are enaught rights to /dev/zap/\* for your asterisk process.

...



h2. Configure Layer1 and Layer2 parameters

...



This parameters are set by /etc/zaptel.conf (change xx to your country code (eg. uk or de). Disable crc4 if your operator or PBX does not support it. Next important thing is WHO will be master of clocks. In most situations, networtk part will act as clock source, but ask your operator, if you should be master or not. Misconfiguration of this will do strange errors in framing. 

h3.

...

 zaptel.conf

...



{code
}
loadzone = xx
defaultzone = xx

# PRI TE
span=1,1,0,ccs,hdb3,crc4  ; I am clock master
;span=1,0,0,ccs,hdb3,crc4; Remote side is clock master
bchan=1-15
dchan=16
bchan=17-30
{code}

Next, it is needed to set layer3 parameters and PBX specific parameters. It is stored in /etc/asterisk/zapata.conf. Use same language code as above. Use swtichtype ISDN because it has best support within asterisk. Qsig is not implemented well. Select signalling (either cpe for end device and net for master device). In most situation, your asterisk gateway will act as CPE because your telecomunication operator act as network device (master). Dialplan is unknown, it means that there will be no automatic country or PBX prefixes for calling and we will do this in dialplan (better solution). Echoparaeters are needed for echocancelation to work. But it can be time consuming process to find source of echo and cancelate it. And you can never be sure that it will not appear in some calls. See [http://www.voip-info.org/wiki/view/Asterisk+echo+cancellation&view_comment_id=13700] for more informations. Immediate means if calling to your asterisk will be routed to called number into dialplan. Next, we have to setup calling groups. In this scenario, we have only one calling group which spans all available channels on card. We can group only some of them or more cards together. Any call to your Asterisk box will be routed into fpstn context (see above).

h3.

...

 zapata.conf

...



{code
}
[channels]
language=xx

switchtype = euroisdn
signalling = pri_cpe

pridialplan = unknown
prilocaldialplan = unknown

echocancel=64
echotraining = 150
echocancelwhenbridged=yes

;txgain=-4
;rxgain=-4

immediate=no

group = 1
context = fpstn
channel => 1-15,17-30
acountcode = fpstn

{code}

Next, we have to setup SIP side of our gateway. We will do this in /etc/asterisk/sip.conf. We will not allow unauthenticated clients (we will route them into context guest, see above). Set your realm and domain to something usefull which should be unique. Putting your real domain there is realy good point of start. But remember, this domain and realm setting has to corespond to settings in client, see above. Only opensource codecs are enabled by default. If you buy or own g.729 codec, you can enable it. Again, set language to fit your needs. Localnets are defined to better recognisation of NAT. Lines starting with jb are turning on jitterbuffer which is good to enable. Next, we define phones which we will use. In example, we use 3-digit dialplan and we are starting with number 200. Define next sip clients to fit your needs. It is good if username corespond with peer name (name in []).  It is possible to use database for storing SIP users, which is better for bigger systems, but it is not scope of this document. See [http://www.voip-info.org/wiki/view/Asterisk+RealTime+Sip] or [http://www.sineapps.com/news.php?rssid=1105] for more informations.

...



h3. sip.conf

...



{code
}
[general]
context=guest                   ; Default context for incoming calls (non authenticated)
realm=somecompany.com
domain=somecompany.com

disallow=all                    ; First disallow all codecs
;allow=g729
allow=gsm
allow=alaw
allow=ulaw

language=xx                     ; Default language setting for all users/peers

localnet=192.168.0.0/255.255.0.0; All RFC 1918 addresses are local networks
localnet=10.0.0.0/255.0.0.0     ; Also RFC1918
localnet=172.16.0.0/12          ; Another RFC1918 with CIDR notation
localnet=169.254.0.0/255.255.0.0 ;Zero conf local network

jbenable=yes
jbforce=yes
jbimpl = fixed

[200]
username=200
secret=somesecret200
type=friend
host=dynamic
context=sip

[201]
username=201
secret=somesecret201
type=friend
host=dynamic
context=sip

[...]
...
...

{code}

Next, we have to glue all things together. Calls from E1 are directed into context

...

 fpstn, calls from SIP are directed into context sip. Now we should define routing rules for this contexts

...

extensions.conf

Code Block
.  We assume that operator sends entire number as DNID and we have 9digits country dialplan. Replace 123456 by your PBX prefix. We will reach outside world using 0 as prefix. In fact, this is realy very simple config. In real world, we should use macros and better error reporting. ${EXTEN:6} means that we will strip first six digits from number. Similary, ${EXTEN:1} strips one number from left side. For testing purposes, we created extensions 111, which answers call and do simple echo application. You must have asterisk sounds instaled to make it working.

h3. extensions.conf

{code}
[general]
static=yes
writeprotect=yes 

[fpstn]
include => test
exten => _123456XXX,1,Dial(SIP/${EXTEN:6})

[sip]
include => test
exten => _2XX,1,Dial(SIP/${EXTEN})
exten => _0.,1,Dial(Zap/g1/${EXTEN:1})

[test]
exten => 111,1,Answer()
exten => 111,2,Playback(welcome)
exten => 111,3,Playback(demo-echotest)
exten => 

OS specific help

...

111,4,Echo()
exten => 111,5,Playback(demo-echodone)
exten => 111,6,Playback(vm-goodbye)
exten => 111,7,Hangup()

{code}

h1. Validation, confirmation tests 

If everything went fine, you should be able to register into your asterisk PBX with your SIP phone and call 111. In other side, incoming call to 123456111 should have same effect. Most common problems and solutions:

 * Cannot register SIP phone. 
     * Double check that you have configured sip.conf. Try command asterisk -rvx 'sip show peers'. You should see your peer.

 * Registered, but cannot call anywhere (even test). 
     * Check your codec settings. There should be same codec on phone and in sip.conf 

 * Registered, can call test, but cannot call outside
     * Check zaptel.conf, zapata.conf and rights to /dev/zap for your asterisk process. Try asterisk -rvx 'zap show status' , asterisk -rvx 'pri show span 1'