Asterisk User's Guide to the Cisco ATA-186 v.2003062801 by: John Todd (jtodd @loligo.com) Introduction: The ATA-186 is currently Cisco's least expensive device for connecting to SIP VoIP networks. It has two analog lines for attaching standard phones, and an ethernet for connecting to a LAN. For approximately $150 USD new, this device is an extremely well-priced introduction to SIP hardphones, and is well-suited to smaller VoIP implementations. The ATA-188 is a similar device, and can be configured in almost the same way as the ATA-186 is shown below. Asterisk is an Open-Source PBX and telephony toolkit which has a SIP module, allowing the ATA-186 to be used as a device for getting calls into the VoIP or standard PBX network that may be attached through the gateway features that Asterisk can provide. This guide is intended to be a roughshod cookbook for getting your ATA-186 running with Asterisk, but the methods within could just as easily be used to set the device to work with other SIP platforms such as SER or Vocal. I welcome comments and updates to this guide, and will happily integrate them. The permanent home for this guide can be found on http://www.loligo.com/asterisk/Cisco/ ---------------- Step 1: Buy a usable device If you're buying a new unit, this step does not concern you and you can skip to the next point. If you're buying used, these are important issues to remember: 1) See if you can get a unit with SIP/H323 software already installed on it. The seller should know what's on the unit. 2) Make sure the unit is not a "locked" unit. Starting with v2.16, Cisco introduced a setting that would permit the device to be locked such that it is impossible to recover or reset the password under any circumstances. The rumor is that a certain large VoIP long distance company demanded that this be added so that their customers would stop selling the ATA-186 units that came with their inexpensive introductory offer. This "locking" setting is optional, so it is not the case that all v2.16 units are unusable, just that it is possible that they are unusable. Before buying, make the seller state that the device is unlocked and re-settable. If they claim they don't know, or they were unaware of such settings, don't buy the device! You'll be getting a paperweight. ---------------- Step 2: Get the right software on it. The ATA-186 can come in one of several flavors - SIP, H323, SCCP, and MGCP. Default units from the factory come with SCCP, so you will need to get a copy of the SIP/H323 software from somebody. The SIP and H323 images are identical, I believe, but this may have changed recent. The upgrade packages come as .zip files and include a DOS-based upgrade utility which creates a mini-TFTP server on your Windoze machine. Actually, this is quite a handy way to upgrade the software, and I would suggest following the instructions that come with the package. The file is named something like "ata18x-v2-16-030401a-1.zip" How do you get the software if your system didn't come with it? You need to be a registered Cisco user and purchase a SIP license to download the latest versions. Getting to that point is beyond the scope of this document. I would suggest that if you don't have a Cisco contract on your ATA-186 devices that you make sure you purchase the units with the appropriate software on them. Please don't send me email asking for a location of the software files; I will politely refuse and tell you to talk with Cisco about it. ---------------- Step 3: Reset the box to default configurations. Plug the unit in, and plug a phone into the port labelled "Phone 1" on the back - you must use this port to configure the phone. When plugging the unit in, you should see a light under the button on the top flash a bunch of times. There is a "special" key sequence that resets the unit to default configuration. After resetting to default configs, the device will reboot and get it's address from your local DHCP server. See alternate instructions if you don't have a DHCP server. Reset device to - Pick up handset - Press red button - Hear "configuration menu, enter menu number..." - Type: 322873738# - Hear "to save press star, or press the pound key" - Press "*" - The red light will flash, device is now reset to defaults (you may get a short ring) Now, we need to find out what IP address has been picked up: - Pick up handset - Press red button - Hear "configuration menu..." - Type 80# - Write down the IP address that is read back to you Additional steps if you don't have a DHCP server (substitute one of your valid IP addresses in this example): - Pick up phone - Press red button again - 20# 0# 3 - this sets dhcp to "no" - 1# 172*16*10*4 #3 - this sets the IP address - 10# 255*255*255*0 #3 - this sets the mask - 28# 172*16*10*1 - this sets the gateway - Hang up the phone, device will reset with new IP addr parameters ---------------- Step 4: Set up our sip.conf file for Asterisk A typical configuration for an ATA-186 would look like this: [2299] type=friend username=2299 secret=lordwhorfin canreinvite=no host=dynamic dtmfmode=rfc2833 mailbox=2299 nat=1 "[2299]" is the name of this extension, and should be the same as the username "type=friend" means that this device can both make and receive calls "username=2299" is the username of the ATA-186 for authentication "secret=lordwhorfin" is the definition of the password for this particular line "canreinvite=no" means that we don't want SIP endpoints talking to each other directly. I still haven't been able to make REINVITEs work when either end is behind a NAT, so I just get lazy and set everything to "canreinvite=no" "host=dynamic" means that this ATA-186 will move around to different IP addresses and it will use the REGISTER method to tell the server where it is. "dtmfmode=rfc2833" this defines how we pass touch-tones between the ATA-186 and the Asterisk server. The ATA should work with RFC2833 (or "avt") delivery methods, as I have not had problems with it with the exception of when I'm using Iconnecthere.com or any other Cisco device at the far end. Asterisk for some reason refuses to strip out the DTMF signals and re-send them as something that can be understood by the far end. I have no idea how to fix that other than setting "dtmfmode=inband" which actually sends the tones as audio data, which doesn't work very well (if at all.) "mailbox=2299" tells Asterisk to look in mailbox 2299 and send a NOTIFY back to the ATA-186 when there is mail in that box. The ATA-186 will play a stutter dialtone if there is voicemail. "nat=1" should be set, even if the device isn't behind a NAT or PAT. It doesn't hurt to turn it on. Note that each line must have it's own distinct and complete configuration, and if you use both lines on the ATA-186, it will REGISTER twice. Further note that you cannot call one line from the other on the same device using the "direct" extension numbers, so you will have to be clever about naming and aliases within Asterisk. That is outside the scope of this document. ---------------- Step 5: Go to the main configuration page via a web browser Now that you have reset the device and know the IP address of the unit, you'll need to configure it through a web browser. In our examples, we'll assume that the IP address of the unit is 1.2.3.4. Pull up your web browser, and enter: http://1.2.3.4/dev You should now see a menu with "Cisco ATA 186 Configuration" emblazoned at the top of the page, with a bunch of options listed down the page. NOTE: If you get a screen that has only three possible entry blocks and says "Enter UI Password", then the device has not been reset. Attempt the reset configurations again, and if that does not work, it may be the case that you have a device that cannot be reset (v2.16 and up - see other notes) ---------------- Step 6: Change the settings to match your Asterisk server I will only describe those settings which are required to be altered, and why. A complete example of an Asterisk-compatible ATA-186 is included at the bottom of this guide, with all fields intact. You will not need to alter most fields, so anything that is not explicitly referenced here can probably be left alone. Where I list IP addresses, I would suggest using IP addresses and not hostnames. The ATA can resolve names to IP addresses, but unless you have a good reason to use names (large distributed environment, boxes that "disappear" behind NATs out of your control where changing config data may be impossible, etc.) then I would suggest that you use IP addresses. An intelligent network administrator should be able to evaluate which method they will use for their particular configuration. UIPassword: This is the password that will be used to control access to the http://1.2.3.4/dev configuration menu. I strongly suggest leaving this alone until you have worked with all of the other values in the file and have them set the way you want. I would suggest you use a numeric value here, since you want something that can be typed in through the keypad in case that is required (see Cisco's user manual on that process.) ToConfig: Set this to "0" This is the flag that tells the unit if it's been configured or not, and since you're now configuring it, it can be set to "0" UseTftp: This value should be set to "1" even if you're not using a TFTP server to modify your configurations. Why? To get around a bug. The ATA-186's will, when used with Asterisk in particular, sometimes get wedged. They won't send their REGISTER updates when they should, thus making inbound calls impossible. So, someone posted a solution which was to trick the box into rebooting every N seconds, which un-wedges them. Yes, it's a kludge, but as of v2.16 this has not been solved, so we have to configure those settings which tell the system that it needs to reboot. The three settings are UseTftp, TftpURL, and CfgInterval. Note that when the device reboots, it is unavailable for 30 seconds. TftpURL: Enter an IP address that you know isn't running a TFTP server. Yes, strange, but it's faster to get a "reject" than it is to get a timeout. Supposedly you can leave this blank and it will use whatever it gets from the DHCP server, but that is usually not set to anything, so put in an IP address of something you know isn't running tftpd. (format is just 123.123.123.123 - no URL specifier required) CfgInterval: Set this to the number of seconds between forced reboots to clear wedging. 86400 (one day) is a safe number. Dhcp: 0 for "off" and "1" for on. If set to "on", then Static IP address config items will be ignored (though they will still retain their settings if you set them; they just won't be used.) StaticIP: IP address of this box, if you need to statically set it StaticRoute: Static gateway IP address for this box, if you need to statically set it StaticNetMask: Static network mask for this box, if you need to statically set it UID0: This is the Username for line #1. This is the same as the username in your "sip.conf" file for a SIP peer. Thus, you would enter "2299" if your sip.conf looked like our example listed at the top of this document. PWD0: Using the example above, enter "lordwhorfin" in here as the password for line #1 UID1: Same thing as UID0, but for "Phone 2" jack PWD1: Same thing as PWD0, but for "Phone 2" jack GkOrProxy: Set this to the IP address of your Asterisk server. UseSIP: Set this to "1" so we are using SIP instead of H.323 SIPRegInterval: Set this to the number of seconds between REGISTER attempts. This is how often the ATA-186 sends a "heartbeat" to the SIP server, which tells the server the phone is still "alive" and also tells the server what IP address that number can be reached on. If you are behind a NAT or PAT, I would suggest a very low timer here, something like 120 seconds. This is because NAT or PAT gateways will 'time out' mappings between the outside world and the inside private IP addresses unless traffic keeps trickling through the mapped settings. Unless you have a very large number of phones, the increased REGISTER traffic will not adversely effect your Asterisk server. If your ATA-186 is on a "real" IP address, I would suggest leaving this number fairly high, like around 1800 or 3600 seconds, because there's no need to keep sending the heartbeat more frequently. At the time of this writing (2003-06-28) it may be the case that there are two other options rather than reducing the SIPRegInterval to keep NAT/PAT mappings open, but they both rely on the Asterisk server. It appears that the Asterisk server sends a NOTIFY to the ATA-186 every minute regardless of voicemail status, and the replies for this may help to keep NAT/PAT mappings active. It is also possible to specify a "qualify=" statement in the sip.conf for each peer, which will request a SIP "OPTIONS" call on each ATA-186 every minute, and then time the response interval. This can serve two purposes: it will gauge the response time of the network between the ATA-186 and the Asterisk server and remove any phones that reply in an interval greater than that specified by the "qualify=" line. Secondly, the OPTIONS request will generate traffic and keep the NAT/PAT session alive. If you don't understand what any of this means, don't worry about it and just set SIPRegInterval to 120. SIPRegOn: Set this to "1" so that SIP REGISTER messages are sent. NatServer, NatIP, NatTimer: Ignore these. You might be tempted to fool with them, but you SHOULD NOT MEDDLE WITH THEM. It will only lead to heartache and woe. Asterisk takes care of all the details; don't try to outsmart the system. AudioMode: Lots of settings are contained within this binary number, but we're only concerned about one bit for each line. Your voice calls will sound better if you turn off VAD (also known as "Voice Auto Detection" or "Silence Suppression") on each line. VAD causes data packets to stop flowing if you are silent, which leads to some voice clipping of the first few milliseconds of each time you talk, and also leads to some strange silences on the line which make people ask "Are you still there?" more frequently than is normal. The default setting of "0x00150015" has VAD turned on, but setting this register to "0x00140014" turns it off for both lines. ConnectMode: If you have a system with v2.15 or earlier, you will need to modify this setting. In order for the ATA-186 to work properly behind NAT or PAT systems, it needs to do some clever analysis of the headers in replies to it's initial REGISTER messages. To turn this processing on, set ConnectMode to "0x00460400". The default is "0x00060400" NOTE: If you have v2.16 you MUST NOT CHANGE THIS SETTING. Cisco confusingly changed the meaning of that bit in v2.16, and has Via: header processing turned on by default. In other words, if you have v2.16, you're fine. Don't mess with ConnectMode. TimeZone: Some phones set their date/time from the caller ID clocking messages, and you'll need to set the appropriate timezone in your ATA-186 so it can give the right date/time data to your phone. The formula for how the phone sets it's clock is: (Local Time=GMT + TimeZone, if TimeZone <= 12) or (Local Time=GMT + TimeZone - 25, if TimeZone > 12) Let me say right here that this is one of the DUMBEST and most INCONVENIENT ways of setting a timezone I've ever seen in my life. Why isn't this just a GMT offset, guys? Anyway, Pacific Coast USA time is the default at "17", Mountain is "18", Central is "19", and Eastern is be "20". GMT would be "0", and the rest of Europe gets better math scores than we loutish Americans, so you can figure it out on your own. I have no idea how it handles daylight savings time; I have not experimented with that setting. NTPIP: Set this to the IP address of your favorite NTP (Network Time Protocol) server. I use time.apple.com at 17.254.0.31 AltNTPIP: Set to the IP address of your favorite NTP backup server. I use the other address for time.apple.com at 17.254.0.26 ---------------- Step 7: Test/Debug The device will reboot when you hit "Apply" I would suggest that you install the ethereal package and then use the "tethereal" command-line application to watch SIP messages and their responses. Example: "tethereal port 5060" This will tell you far more than any debug messages can hope to offer. If the phone successfully registers on the Asterisk server, you will see within 30 seconds or so a note like this on your Asterisk console: "-- Registered SIP '2413659251' at 18.33.17.3 port 28705 expires 120" Try calling the line from some other phone. Voila! If the phone rings, but you get no voice channel, you've got a NAT/PAT problem where RTP isn't getting through but your SIP messages (port 5060) are. This is more complex than this guide can cover - see the Asterisk mailing list or the IRC channel. If the phone does not ring, see if your SIP messages are making it from the Asterisk server to your ATA-186. If the phone does not successfully register with the Asterisk server, make sure your outbound messages are making it to the Asterisk server, and that your replies are being sent back to the correct destination IP address. Step 8: Optional codec settings If you have purchased the G.729 codecs from Digium ($10 per concurrent channel license - worth it just to have 'em) then you need to set the following options: LBRCodec: 3 RxCodec: 3 TxCodec: 3 Default settings: LBRCodec: 0 RxCodec: 2 TxCodec: 2 Using the G.729 codec will reduce the bandwidth between your ATA-186 and your Asterisk server to around 30kbps per active channel, versus around 82kbps per G.711 channel (the default.) Sound quality suffers slightly, but it's still better than a cell phone IMHO. ---------------- Misc: http://1.2.3.4/reset = resets device without pulling the plug http://1.2.3.4/stats = short statistics for RTP sessions/software rev http://1.2.3.4/refresh = request TFTP files for this device (not covered in this guide) ---------------- References: http://www.cisco.com/univercd/cc/td/doc/product/voice/ata/ http://www.asterisk.org/ http://www.djernes.org/~shawn/ata186.htm ---------------- Full Example configuration for ATA-186 v2.16: Cisco ATA 186 Configuration UIPassword: * ToConfig: 0 UseTftp: 1 TftpURL: 10.0.1.1 CfgInterval: 1800 EncryptKey: Dhcp: 1 StaticIP: 0.0.0.0 StaticRoute: 0.0.0.0 StaticNetMask: 255.255.255.0 UID0: 2413659251 PWD0: ******* UID1: 0 PWD1: * GkOrProxy: 24.3.22.9 Gateway: 0 GateWay2: 0.0.0.0 UseLoginID: 0 LoginID0: 0 LoginID1: 0 AltGk: 0 AltGkTimeOut: 0 GkTimeToLive: 300 GkId: . UseSIP: 1 SIPRegInterval: 120 MaxRedirect: 5 SIPRegOn: 1 NATIP: 0.0.0.0 SIPPort: 5060 MediaPort: 16384 OutBoundProxy: 0 NatServer: 0 NatTimer: 0x00000000 LBRCodec: 0 AudioMode: 0x00140014 RxCodec: 2 TxCodec: 2 NumTxFrames: 2 CallFeatures: 0xffffffff PaidFeatures: 0xffffffff CallerIdMethod: 0x00019e60 FeatureTimer: 0x00000000 Polarity: 0x00000000 ConnectMode: 0x00060400 AutMethod: 0x00000000 TimeZone: 17 NTPIP: 17.254.0.31 AltNTPIP: 17.254.0.26 DNS1IP: 0.0.0.0 DNS2IP: 0.0.0.0 TOS: 0x000068b8 SigTimer: 0x01418564 OpFlags: 0x00000002 VLANSetting: 0x0000002b NPrintf: 0.0.0.0.0 TraceFlags: 0x00000000 RingOnOffTime: 2,4,25 IPDialPlan: 1 DialPlan: *St4-|#St4-|911|1>#t8.r9t2-|0>#t811.rat4-|^1t4>#.- DialTone: 2,31538,30831,1380,1740,1,0,0,1000 BusyTone: 2,30467,28959,1191,1513,0,4000,4000,0 ReorderTone: 2,30467,28959,1191,1513,0,2000,2000,0 RingBackTone: 2,30831,30467,1943,2111,0,16000,32000,0 CallWaitTone: 1,30831,0,5493,0,0,2400,2400,4800 AlertTone: 1,30467,0,5970,0,0,480,480,1920 CallCmd: Af;AH;BS;NA;CS;NA;Df;EB;Ff;EP;Kf;EFh;HQ;Jf;AFh;HQ;I*67;gA*82;fA#90v#;OI;H#72v#;bA#74v#;cA#75v#;dA#73;eA*67;gA*82;fA*70;iA*69;DA*99;xA;Uh;GQ; [model information for the above configuration] ata000bbe3ba4aa Version: v2.16 ata18x (Build 030401a) DHCP Assigned: IP[10.0.1.8] Subnet[255.255.255.0] Route[10.0.1.1] MAC: 0.11.190.59.164.170 SerialNumber: INM0652D1B6 ProductId: ATA186I2 Features: 0x00000000 HardwareVersion: 0x0006 0x0000