Asterisk, SIP, Openwrt and Cisco 7912 IP phone

After finishing my previous post I decided to also write a small how-to about configuring Asterisk and flashing the cisco 7912G with the SIP firmware.

Ingredients for today are:

A cisco 7912G IP phone [Get it here] or [here]
SIP firmware for the 7912G phone [Get it here] or [here]
Asterisk package for OpenWrt ipkg install asterisk
Asterisk voicemail package for OpenWRT ipkg install asterisk-voicemail
Asterisk sounds package for OpenWRT ipkg install asterisk-sounds
A small amount of time  


Step one: Install asterisk on a usb stick

Install all asterisk packages on OpenWRT. I would advice you to use a USB stick or USB external disk drive if your router supports USB, especially when using voicemail and you would like to store all voicemails on the router. The router uses flash memory to store all files, and this memory is exhausted after a few (thousands/millions) rewrites. Changing something in a configuration file for testing purposes will therefore rewrite something to flash and thus faster exhaust the memory.

Using a USB stick will require you to install kmod-usb-core, kmod-usb-storage, kmod-usb-uhci and a module for accessing the file system. If you use EXT2 or EXT3, install kmod-EXT2 or kmod-EXT3. If you use FAT install the module kmod-vfat. Plug-in the USB stick and load the appropriate modules. Your USB stick should be available now in /mnt/. What I have done after that is just copying all files in /etc/asterisk to the usb disc and symlinked this to the directory in /etc/. Now changing the asterisk files will no longer rewrite files on the internal flash memory, but on the USB stick instead. I did this with all directories containing asterisk files: agi-bin, firmware, modules,keys, mohmp3,sounds and voicemail and changed the directives astetcdir, astmoddir and astagidir in asterisk.conf to point directly to the new location on the usb disc.

Step two: Configure the SIP software on the Cisco 7912

Download the SIP software for the Cisco 7912 IP Phone. Unzip it on your desktop and open a DOS-box or terminal session.
In the directory you just uploaded, you will find several files. Open the gkdefault.txt. This is your clear-text configuration file and will be used to compile a new binary-configuration file for the IP Phone. It is well documented in sipexample.txt so you should be able to manage on your own, but I will point out some required fields to get you going:

UIPassword: is the password that can unlock the phone to change settings by hand
Proxy: The IP or hostname of your asterisk server
UID: usually your line number, could also be your username
PWD: the password to use when registering to asterisk
LoginID: username to use when registering to asterisk

Now run cfgfmt -tsip_ptag.dat gkdefault.txt gkdefault.cfg in your DOS-box or console and the binary configuration file will be compiled.
Upload the gkdefault.cfg and CP7912080000SIP060111A.sbin files to the TFTP server ( for example on your openwrt box, see for more info my previous post.
If you run a DCHP server on Windows or Linux, you are probably able to add some DHCP options, for example TFTP servers. To make sure that the IP Phone automatically gets the TFTP ip address, add Option 66 and define it with the ip adress of the TFTP server. The Cisco phone should now automatically know where to get the CP7912* file and gkdefault.cfg file.

If you can not add DHCP options, for example when you use a simple internet NAT router you will have to add the TFTP server manually.
In this case, power on the phone and go to the configuration menu by pressing the most right round button.
Then go to ” settings” by using the up and down keys. In this menu, everything is locked by default. You can unlock it by pressing **#. If a password has been set previously, you will have to enter it before you can do any changes to the menu.
When the menu has been unlocked, go to “TFTP server” and edit it to reflect the IP adress of the TFTP server you wish to use.

Step three: Configure Asterisk
There are only two things to do when configuring asterisk: Add the device to sip.conf and add a dialmap to extensions.conf.
To the device to sip.conf open the file and add the following lines:

[1]
disallow=all
allow=ulaw
allow=ilbc
type=friend
dtmfmode=inband
regextn=1
context=sip
secret=cisco
host=dynamic

Now add to the extensions.conf the following lines:

[sip]
exten => 1,1,Dial(SIP/1,20,tr)

Now start asterisk by simply entering ‘asterisk’ in the OpenWRT console. You can connect to the asterisk console by entering asterisk -r where you can debug problems and check a dozen statistics about the current running configuration. Next power-on the IP Phone. It will download the new software, reboot and come back online with the settings you configured.

The above configured asterisk configuration is very basic, but when you register another (soft)phone to the asterisk PBX you will be able to call from one phone to the other. Asterisk is very configurable and has many options and modules that can be configured. These options fall out of scope of this post, but perhaps I will create a separate post about most used asterisk options.

3 Responses to “Asterisk, SIP, Openwrt and Cisco 7912 IP phone”

  1. AlexM says:

    Your blog is interesting!

    Keep up the good work!

  2. Daniel Craig says:

    Hey, I was looking around for a while searching for cisco network security and I happened upon this site and your post regarding Asterisk, SIP, Openwrt and Cisco 7912 IP phone, I will definitely this to my cisco network security bookmarks!

  3. [...] ich nicht viel anfangen. Nachdem Google aus den tiefen des Netzes diesen Blog Eintrag zum Thema OpenWRT, Asterisk und SIP ausgegraben hatte, gab es wenigstens eine SIP [...]

Leave a Reply

You must be logged in to post a comment.