Tuesday, April 28, 2009

Asterisk PBX System Install - 07 External Line

Issue:
Configure our Cisco 1760 router to connect inbond phone calls.

Quick/Visual/Learning:
Now to configure the Call router
Using a Cisco 1760 with 2 - 2 port FXO cards (For up to 4 analog phone lines)

Note there are 4 slots on the router and we have some 4 port cards. I assume that we could have up to 16 total phone lines connected to the router in that configuration.

For now I am just going to see if I can get one line working.

Router ip address in this case 172.17.2.1

One of the first problems I had was that as I was looking for help I saw some posts that I needed to configure the router like this:
voice service voip
allow-connections sip to sip

The Problem is allow-connections sip to sip was not an option on my router. It turns out I needed to update my router ios to something above version 12.4.15.T

I got 12.4.15.T.8 which requires 128 RAM and 32 Flash
You should be able to see all this informaiton about your router using command:
> show version

See January 23 post on loading IOS

Below are the bits of my router configuration associated with the voice connection.
An easy way to get these on your router is to enter config t mode on the router and copy the commands right into the command window. You may want to copy them a bit at a time instead of all at once so you can see if any errors show up.

I do not claim to be an expert on routing calls over the Cisco 1760 router. Below is what I came up with and it seems to work. If anyone has insight into what is or is not needed please feel free to submit a comment to this post. I put a few comments below to explain some of what I think is going one with this configuration.
This link was very useful in my testing.

-------------------------------------------------
voice call carrier capacity active
voice rtp send-recv
!
(I had to upgrade my IOS to get the sip to sip options you see below)
voice service voip
allow-connections h323 to sip
allow-connections sip to h323
allow-connections sip to sip
sip
bind control source-interface FastEthernet0/0
bind media source-interface FastEthernet0/0
no call service stop
!
!
voice statistics type csr
!
!
dial-control-mib retain-timer 180
dial-control-mib max-size 250
archive
log config
hidekeys
!
!
(below is the ip address of my Ethernet port on the 172.17.x.x subnet going over to the Cisco switch)
interface FastEthernet0/0
description Voice
ip address 172.17.2.1 255.255.0.0
speed 100
full-duplex
!
!
(connection plar 401 is the extension on the Asterisk server where the router will connect. The description is not needed but is here to remind us that 555.765.2211 is the number of the outside line that we are going to connect to the router. )
voice-port 0/0
input gain 6
output attenuation 0
echo-cancel erl worst-case 0
no vad
no comfort-noise
timing hookflash-out 50
connection plar 401
impedance complex2
description 555.765.2211
station-id name External Caller
station-id number 2211
!
!
dial-peer cor custom
!
!
!
(400 seem to be just an assigned number and I don’t think it matters which you use. Pattern 4.. means that I will be connection to a 3 digit extension starting with a 4. Target ip is the ip of my Asterisk server 172.17.1.31 and 5060 is the standard SIP port. Codec g711ulaw is the same ulaw protocol that we well be setting on Asterisk.)
dial-peer voice 400 voip
destination-pattern 4..
session protocol sipv2
session target ipv4:172.17.1.31:5060
session transport udp
incoming called-number .
dtmf-relay sip-notify rtp-nte
codec g711ulaw
no vad
!
(Distnation .T matches all numbers and is used for outbound calls)

dial-peer voice 100 pots
destination-pattern .T
port 0/0
forward-digits all
!
gateway
timer receive-rtp 1200
!
(sip-server below points to our Asterisk pbx)
sip-ua
retry invite 3
retry response 3
retry bye 3
retry cancel 3
timers trying 1000
sip-server ipv4:172.17.1.31
!
!
telephony-service
fxo hook-flash
max-conferences 4 gain -6
transfer-system full-blind
transfer-pattern ....
!
----------------------------------------------

On the Asterisk server we have to configure the sip.conf file to allow the 1760 router to connect over sip.

#vi sip.conf
i


[general]

[Cisco1760]
context=incoming_calls
type=friend
host=172.17.2.1
dtmfmode=rfc2833
disallow=all
allow=ulaw
insecure=very

[207]
context=internal
type=friend
disallow=all
allow=ulaw
host=dynamic

Esc-Key
:wq


You see above the new section added to the sip.conf file for the Cisco router. The section name "cisco1760" was just a name I picked. The context is different (incoming_calls not the context of internal we used on the phones) so that will need to be configured in the extensions.conf file. This keeps incoming calls separate from our internal phones. There are security reasons for doing it this way. Friend says we can send and receive calls, dtmfmode=rfc2833 allows key tones to get through, Host points to the ip address of the router and it is configured for ulaw which is the same as the router. The line insecure=very is important and needs to be there from what I read.
disallow all does not allow any codecs except for the one we specifically allow which is ulaw.

In extensions.conf we need to configure the incoming_calls context.
[globals]

[general]

[default]

[incoming_calls]
exten => 401,1,Answer
exten => 401,n,Background(main-menu)
exten => 401,n,WaitExten(15)

exten => 1,1,Dial(SIP/207,15)

exten => i,1,Playback(pbx-invalid)
exten => i,n,Goto(incoming_calls,401,1)

exten => t,1,Playback(vm-goodby)
exten => t,n,Hangup()



[internal]

exten => 401,1,Answer
exten => 401,n,Playback(tt-weasels)
exten => 401,n,Hangup()

[phones]
include => internal

Under incoming_calls I added extension 401 and it looks a lot like the 401 under the internal context but they are not the same. Incoming_call and internal contexts are completely separate areas of the dial plan. The calling plan defined under incoming_calls does not communicate with the plan under the internal context. So what does this do?

When the router connects to the Asterisk server as a sip device it is assigned to the incoming_calls context. The router then connects on extension 401 because that is what we configured it to do on the router configuration. The 401 extension program under the incoming_ calls context runs and answers the line. It will play back a message that says “Main Menu” and then it waits 15 seconds for someone to enter a number. It does not tell them what number to press because we have not set that part up yet. This is the bare beginnings of setting up a phone tree for routing calls. Looking at the dial plan you can see that extension 1 has been configured. If 1 is dialed during the waiting period the sip device 207 will be called and connected.

The other 2 extensions in the section are there to help in testing. The i extension is for invalid entries. This message gets played if someone enters a number for an undefined or invalid extension. The t extension is the time out action and just hangs up if no numbers are entered in the allotted time.

So we can use this to test by calling in from somewhere (cell phone maybe) on our outside line 555-765-2211 (of course this is not the real number I am using). I hear the “Main Menu” message. I dial 1 and the 207 phone on my desk rings and I can pick it up and talk pretty cool when you get that working for the first time.

Next time we will get outbound calls working
Asterisk PBX System Install - 08 Outbound Calls
Asterisk PBX Install - Index