example asterisk and cisco configuration files for the collectors network
The following page contains example configuration files for Cisco IOS 12.4.x and Asterisk 10.7.x for use in connecting old TDM digital switches to the collectors network.
1. Configure the Definity and/or Meridian side of the T1 PRI trunks as described on my nortel at home or definity at home pages.
2. The pertinent portions of the Cisco as regards VoIP are as follows:
!
!
no network-clock-participate slot 1 
voice-card 1
 dspfarm
!
!         
isdn switch-type primary-qsig
isdn gateway-max-interworking
!
!
!
voice service voip 
 h323
  call service stop
 sip
  session transport tcp
!
!
controller T1 1/0
 framing esf
 linecode b8zs
 pri-group timeslots 1-24
 description PRI T1 to meridian
!
controller T1 1/1
 framing esf
 linecode b8zs
 pri-group timeslots 1-24
 description PRI T1 to definity
!
!
translation-rule 1
 Rule 0 ^90 0
 Rule 1 ^91 1
 Rule 2 ^92 2
 Rule 3 ^93 3
 Rule 4 ^94 4
 Rule 5 ^95 5
 Rule 6 ^96 6
 Rule 7 ^97 7
 Rule 8 ^98 8
 Rule 9 ^99 9
!
!
interface Serial1/0:23
 description meridian T1 D-channel
 no ip address
 encapsulation hdlc
 logging event nfas-status
 logging event subif-link-status
 isdn switch-type primary-ni
 isdn timer T310 120000
 isdn protocol-emulate network
 isdn incoming-voice voice
 isdn guard-timer 20000
 isdn send-alerting
 no cdp enable
!
interface Serial1/1:23
 description definity T1 D-channel
 no ip address
 encapsulation hdlc
 logging event nfas-status
 logging event subif-link-status
 isdn switch-type primary-ni
 isdn timer T306 30000
 isdn timer T310 40000
 isdn incoming-voice voice
 isdn T309-enable
 isdn send-alerting
 no cdp enable
!
!
voice-port 1/0:23
 bearer-cap Speech
!
voice-port 1/1:23
 bearer-cap Speech
!
!
!
!
!         
dial-peer voice 7000 pots
 destination-pattern 7...
 supplementary-service pass-through
 direct-inward-dial
 port 1/0:23
 forward-digits 4
!
dial-peer voice 8000 pots
 destination-pattern 8...
 supplementary-service pass-through
 direct-inward-dial
 port 1/0:23
 forward-digits 4
!
dial-peer voice 5000 pots
 destination-pattern 50..
 supplementary-service pass-through
 direct-inward-dial
 port 1/0:23
 forward-digits 4
!
dial-peer voice 5100 pots
 destination-pattern 51..
 supplementary-service pass-through
 direct-inward-dial
 port 1/0:23
 forward-digits 4
!
dial-peer voice 5200 pots
 destination-pattern 52..
 supplementary-service pass-through
 direct-inward-dial
 port 1/0:23
 forward-digits 4
!
dial-peer voice 5300 pots
 destination-pattern 53..
 supplementary-service pass-through
 direct-inward-dial
 port 1/0:23
 forward-digits 4
!
dial-peer voice 5400 pots
 destination-pattern 54..
 supplementary-service pass-through
 direct-inward-dial
 port 1/0:23
 forward-digits 4
!
dial-peer voice 5500 pots
 destination-pattern 55..
 supplementary-service pass-through
 direct-inward-dial
 port 1/1:23
 forward-digits 4
!
dial-peer voice 5600 pots
 destination-pattern 56..
 supplementary-service pass-through
 direct-inward-dial
 port 1/1:23
 forward-digits 4
!
dial-peer voice 5700 pots
 destination-pattern 57..
 supplementary-service pass-through
 direct-inward-dial
 port 1/1:23
 forward-digits 4
!
dial-peer voice 5800 pots
 destination-pattern 58..
 supplementary-service pass-through
 direct-inward-dial
 port 1/1:23
 forward-digits 4
!
dial-peer voice 5900 pots
 destination-pattern 59..
 supplementary-service pass-through
 direct-inward-dial
 port 1/1:23
 forward-digits 4
!
dial-peer voice 3000 pots
 destination-pattern 3...
 supplementary-service pass-through
 direct-inward-dial
 port 1/1:23
 forward-digits 4
!
dial-peer voice 4000 pots
 destination-pattern 4...
 supplementary-service pass-through
 direct-inward-dial
 port 1/1:23
 forward-digits 4
!
dial-peer voice 9 voip
 description SIP trunk to CNET
 destination-pattern 9T
 translate-outgoing called 1
 session protocol sipv2
 session target ipv4:75.151.27.68
 session transport udp
 codec g711ulaw
!
!
sip-ua 
 retry invite 3
 retry response 3
 retry bye 3
 retry cancel 3
 timers trying 1000
 timers notify 1000
 timers info 1000
 sip-server ipv4:75.151.27.68
!
!

2. Download the latest version of Asterisk (10.7.0) and install:
tar xvfz asterisk-10.7.0.tar.gz
cd asterisk-10.7.0
./configure && make && make install && make samples
3. Go to /etc/asterisk. Delete the stock extensions.*, enum.conf, iax.conf, sip.conf files. If you are using Asterisk as only a VoIP tandem and not as an end office (no FXS or FXO ports in your Asterisk machine) you can remove zaptel.conf as well.
4. Configure /etc/asterisk/extensions.conf like so. Note that I've made some changes to the dial-cnet macro from what is spit out by the configuration generator on the CNET site: I fixed for Asterisk 10.x compatibility by replacing pipes with commas, and I added a step to set the caller ID to the value defined by the CNETANI variable.
; This is the extensions.conf file.  It should be placed in the /etc/asterisk directory.
; THIS CONFIGURATION PROVIDES SIP AND IAX2 CONNECTIVITY TO LEGACY 
; OR COLLECTIBLE TELEPHONE SYSTEMS.
;
; THIS EXAMPLE FILE ASSUMES A CERTAIN CONFIGURATION, BUT CAN EASILY BE
; MODIFIED TO PROVIDE FOR DIFFERENCES WITH INDIVIDUAL PHONE SWITCHES.
;
; THIS SAMPLE SYSTEM IS CONFIGURED AS FOLLOWS:
;       + THE CNET NETWORK HAS NO AREA CODE.
;       + THIS TANDEM HAS THE ASSIGNED OFFICE CODE OF 734.
;       + 4-DIGIT DIALING TOWARDS ELECTROMECHANICAL PHONE SYSTEM
;       + 8-DIGIT DIALING RECEIVED FROM ANALOG SWITCH FOR CNET
;         CALL DESTINATIONS IN NORTH AMERICA.
;       + COUNTRY CODE + CITY CODE + NUMBER RECEIVED FROM ANALOG
;         SWITCH FOR INTERNATIONAL CALL DESTINATIONS ON CNET 
;
; ===================================================================
;
; The [general] category is for certain variables.  
;
[general]
;
; You can include other config files, use the #include command (without the ';')
; Note that this is different from the include command that includes contexts within 
; other contexts. The #include command works in all asterisk configuration files.
; A good use for #include would be to load a file that has your username and
; passwords.  That way, you can share your files with others without letting them have 
; your account information. Obviously, if you just use your Asterisk to connect
; to others on the private network, you won't even need usernames and passwords.
;
;
;#include "filename.conf"
;
;
; The "Globals" category contains global variables that can be referenced
; in the dialplan with ${VARIABLE} or ${ENV(VARIABLE)} for Environmental variable
; ${${VARIABLE}} or ${text${VARIABLE}} or any hybrid
;
;
[globals]
CNETANI=17340100
CONSOLE=Console/dsp             ; Console interface for demo.
MYNAME=Sean Caron               ; for CallerID.
;
;
; Any category other than "General" and "Globals" represent 
; extension CONTEXTs, which are collections of extensions 
; dialing plans, and permissions.  
;
; Extension names may be numbers, letters, or combinations
; thereof. If an extension name is prefixed by a '_'
; character, it is interpreted as a pattern rather than a
; literal.  In patterns, some characters have special meanings:
;
;   X - any digit from 0-9
;   Z - any digit from 1-9
;   N - any digit from 2-9
;   [1235-9] - any digit in the brackets (in this example, 1,2,3,5,6,7,8,9)
;   . - wildcard, matches anything remaining (e.g. _9011. matches 
;       anything starting with 9011 excluding 9011 itself)
;
;   
; Macros can be called from other contexts.  What they do is perform a certain
; function, and then return to the originating context.
;
[macro-dialswitch]
;
exten => s,1,Dial(SIP/${ARG1}@ypsi-1-core-1)
exten => s,2,Congestion                       ; If trunk is busy, send fast busy.
;                                        
;
;
[macro-dialcnet]                                         ;version bjc1.01 - asterisk 1.4 and asterisk 1.2

exten => s,1,Set(NUMBER=${ARG1})                         ;Store number to be called 
exten => s,2,GotoIf($[ ${ARG1:0:1} = "+"]?search)        ;Is number prefixed with '+'?
exten => s,3,Set(ARG1=+${ARG1})                          ;Prefix number with '+'
exten => s,4(search),Set(ENUM=${ENUMLOOKUP(${ARG1},ALL,,1,std.ckts.info)})
exten => s,5,GotoIf($[${LEN(${ENUM})}=0]?no_uri)         ;Is ENUM record found?      
exten => s,6,Gotoif(${DB_EXISTS(ELBD/${NUMBER})}?cdata)  ;Does backup entry exist? 
exten => s,7,Set(DB(ELBD/${NUMBER})=${ENUM})             ;No existing backup so store backup ENUM data 
exten => s,8(test),GotoIf($[${ENUM:0:3} = iax ]?iaxuri)  ;Yes-IAX2 protocol
exten => s,9,GotoIf($[${ENUM:0:3} = sip ]?sipuri)        ;Yes-SIP protocol
exten => s,10,GotoIf($[${ENUM:0:3} = h32 ]?h323uri)      ;Yes-H323 protocol
exten => s,11(no_uri),Gotoif(${DB_EXISTS(ELBD/${NUMBER})}?seek)  ;ENUM="", is there a backup entry?
exten => s,12,Macro(invalid-office-code,${NUMBER})       ;No valid ENUM and no backup entry
exten => s,13,Wait(5)                                    ;Pause
exten => s,14,Hangup                                     ;Done - failed to make call - Goodbye
exten => s,15(seek),Set(ENUM=${DB_RESULT})               ;Set ENUM to backup base entry
exten => s,16,GotoIf(${REGEX("iax2,sip,h323"${ENUM})}?test)      ;If it's a single backup proceed to dial out
exten => s,17,Set(NE=${CUT(ENUM,":",1)})                 ;Get backup entry field 1
exten => s,18,Set(LU=${CUT(ENUM,":",2)})                 ;Get backup entry field 2
exten => s,19,GotoIf($[${NE}>${LU}]?grec)                ;Was last used the last entry in list?
exten => s,20(frec),Set(LU=0)                            ;Reset entry pointer
exten => s,21(grec),Set(LU=$[${LU}+1])                   ;Increment last used pointer
exten => s,22,Set(ENUM=${DB(ELBD/${NUMBER}/${LU})})      ;Read ENUM backup entry
exten => s,23,Set(DB(ELBD/${NUMBER})=${NE}:${LU})        ;Update last used record
exten => s,24,Goto(test)                                 ;Proceed to dial out
exten => s,25(iaxuri),Set(DIALSTR=IAX2/${ENUM:5})        ;IAX2
exten => s,26,Goto(dodial)                               ;Make call
exten => s,27(sipuri),Set(DIALSTR=SIP/${ENUM:4})         ;SIP
exten => s,28,Goto(dodial)                               ;Make call
exten => s,29(h323uri),Set(DIALSTR=H323/${ENUM:5})       ;H323
exten => s,30,Macro(invalid,${NUMBER})                   ;Make Call
exten => s,31(dodial),NoOp(Outbound Caller ID is ${CALLERID(all)})
exten => s,32,Set(CALLERID(all)=${CNETANI})              ;Set CLID to the defined value
exten => s,33,Dial(${DIALSTR})                           ;Dial Out
exten => s,34,Hangup                                     ;Done -call attempted - Goodbye
exten => s,35(cdata),Gotoif($["${DB_RESULT}"="${ENUM}"]?test)    ;Does entry have a single backup?
exten => s,36,Set(SR=${DB_RESULT})                               ;Backup does not match current
exten => s,37,GotoIf(${REGEX("iax2,sip,h323"${SR})}?shuffle)     ;Is more than one backup entry stored?
exten => s,38,Set(NE=${CUT(SR,":",1)})                   ;Get backup entry field 1
exten => s,39,Set(LU=${CUT(SR,":",2)})                   ;Get backup entry field 2
exten => s,40,Gosub(rent)                                ;Check multiple backup entries
exten => s,41,Set(DB(ELBD/${NUMBER})=${NE}:${MR})        ;Store no. of entries and match as entry last used
exten => s,42,GotoIf($[${MR}>0]?test)                    ;If backup exists proceed to dial out
exten => s,43,Set(NE=$[${NE}+1])                         ;Increment entries pointer
exten => s,44,Set(DB(ELBD/${NUMBER})=${NE}:${NE})        ;Update entry count and usage
exten => s,45,Set(DB(ELBD/${NUMBER}/${NE})=${ENUM})      ;Store nth backup entry
exten => s,46,Goto(test)                                 ;Nth entry stored - proceed to dial out
exten => s,47(shuffle),Set(DB(ELBD/${NUMBER}/1)=${SR})   ;Move stored entry to backup entry /1
exten => s,48,Set(DB(ELBD/${NUMBER}/2)=${ENUM})          ;Create second backup entry /2
exten => s,49,Set(DB(ELBD/${NUMBER})=2:2)                ;Store no. of backup entries & last called
exten => s,50,Goto(test)                                 ;Alternative backup entry stored - proceed to dial out
exten => s,51(rent),Set(i=0)                             ;Load test counter
exten => s,52,Set(MR=0)                                  ;Load match store
exten => s,53,While($[${i}<${NE}])                       ;Check multiple entries for a NUMBER looking for a match
exten => s,54,GotoIf($["${DB(ELBD/${NUMBER}/$[${i}+1])}"="${ENUM}"]?mark)        ;Mark entry matching ENUM result
exten => s,55,Set(i=$[${i}+1])                           ;Increment counter
exten => s,56,EndWhile                                   ;Look at next entry if one exists
exten => s,57,Return                                     ;Done searching for ENUM result backup record
exten => s,58(mark),Set(MR=$[${i}+1])                    ;ENUM result already backed up
exten => s,59,Set(i=${NE})                               ;Load counter with no. of last entry
exten => s,60,ContinueWhile                              ;Stop searching

;
[macro-invalid-office-code]
exten => s,1,Congestion
exten => s,2,Hangup
;
[macro-invalid]
exten => s,1,Congestion
exten => s,2,Hangup
;
[cnet-out]

exten => _1NXXXXXX,1,Macro(dialcnet,${EXTEN}) 
exten => _1NXXXXXX,2,Congestion
;
exten => _X.,1,Macro(dialcnet,${EXTEN})
exten => _X.,2,Congestion
;
[outbound]
;
include => cnet-out
;
exten => i,1,Macro(invalid)
;
[inbound]
;
; This is where the calls that come in
; from CNET are translated into the  
; internal Asterisk extensions that are
; then routed to your electromechanical switch.
;
exten => 17340000,1,Goto(internal,s,1)
; Meridian extensions
exten => 17340100,1,Goto(internal,0100,1)
exten => 17340101,1,Goto(internal,0101,1)
exten => 17340102,1,Goto(internal,0102,1)
; Definity extensions
exten => 17341100,1,Goto(internal,1100,1)
exten => 17341101,1,Goto(internal,1101,1)
exten => 17341102,1,Goto(internal,1102,1)
exten => 17341103,1,Goto(internal,1103,1)
exten => 17341104,1,Goto(internal,1104,1)

exten => _1734XXXX,1,Macro(invalid)

[internal]

exten => s,1,Macro(dialswitch,0100,1) 
exten => s,2,Hangup

; 0100 = Meridian frame analog
; 0101 = Meridian frame digital
; 0102 = Meridian milliwatt
exten => 0100,1,Macro(dialswitch,8000)
exten => 0101,1,Macro(dialswitch,7000)
exten => 0102,1,Macro(dialswitch,5000)
; 1100 = Definity frame analog
; 1101 = Definity frame digital
; 1102 = Definity milliwatt + silent term
; 1103 = Definity constant milliwatt
; 1104 = Definity three-tone test
exten => 1100,1,Macro(dialswitch,4000)
exten => 1101,1,Macro(dialswitch,3000)
exten => 1102,1,Macro(dialswitch,5501)
exten => 1103,1,Macro(dialswitch,5502)
exten => 1104,1,Macro(dialswitch,5503)

exten => i,1,Macro(invalid)

exten => h,1,Hangup

exten => t,1,congestion

[c3725]

include => inbound
include => outbound
5. Configure /etc/asterisk/enum.conf as so for outbound ENUM lookup:
[general]

search => std.ckts.info
As an aside, you can test to make sure your inbound ENUM entries are working properly after submitting them to the CNET exchange database with nslookup:
blossom:/var/named# nslookup
> server std.ckts.info
Default server: std.ckts.info
Address: 76.164.63.253#53
Default server: std.ckts.info
Address: 68.178.91.34#53
> set type=any
> 0.0.1.0.4.3.7.1.std.ckts.info
Server:         std.ckts.info
Address:        76.164.63.253#53

0.0.1.0.4.3.7.1.std.ckts.info   naptr = 100 10 "u" "E2U+IAX2" "!^\\+*(.*)$!iax2:cnet@75.151.27.68/\\1!" .
> 
6. Configure /etc/asterisk/sip.conf as so:
[general]
port=5060
bindaddr=75.151.27.68
dtmfmode=auto
allow=all
context=c3725
canreinvite=no
nat=no
; enable jitter buffer to make modems and FAXes work
jbenable=yes
jbforce=yes
jbmaxsize=300
jbimpl=fixed

[ypsi-1-core-1]
type=peer
host=75.151.27.69
context=c3725
dtmfmode=auto
disallow=all
allow=ulaw
7. Configure /etc/asterisk/iax.conf like so:
[general]
trunk=yes
;
;
iaxcompat=yes
;
;
; Specify bandwidth of low, medium, or high to control which codecs are used
; in general.
;
; setting bandwidth to high hopefully leads to highest possible call quality
;
bandwidth=high
;
; You can also fine tune codecs here using "allow" and "disallow" clauses
; with specific codecs.  Use "all" to represent all formats.
;
; force g.711ulaw for highest possible call quality
;
disallow=all                    ; Dis-Allow all codecs
allow=ulaw
;allow=alaw
;allow=gsm
;allow=g726
;allow=adpcm
;allow=lpc10
;allow=speex
;allow=ilbc
;
; You can also adjust several parameters relating to the jitter
; buffer.  Specifically, you can provide a maximum jitter buffer,
; you can turn it off entirely, and you can specify an acceptable
; drop rate (per MEMORY_SIZE, by default 3 of 100).  Disabling the
; jitter buffer is generally recommended unless you are on a highly
; jittery network, since usually jitter buffering will cause you additional
; latency.  Finally, you can specify the maximum
; excess jitter buffer, which if exceeded, causes the jitter buffer to
; slowly shrink in order to improve latency.
;
; enable the jitter buffer so modems and FAXes will work
;
jitterbuffer=yes
;dropcount=3
maxjitterbuffer=300
;maxexcessbuffer=100
;
;trunkfreq=20                   ; How frequently to send trunk msgs (in ms)
;
;
; Finally, you can set values for your TOS bits to help improve 
; performance.  Valid values are:
;   lowdelay            -- Minimize delay
;   throughput          -- Maximize throughput
;   reliability         -- Maximize reliability
;   mincost             -- Minimize cost
;   none                -- No flags
;
tos=reliability
;
; Guest sections for unauthenticated connection attempts.  Just
; specify an empty secret, or provide no secret section.
;
[guest]
type=user
context=inbound
sendani=yes
;
[cnet]
type=user
context=inbound
sendani=yes
;
;
8. Start Asterisk and place some calls!
/usr/sbin/asterisk &
home