Monday, November 1, 2010

Asterisk 1.8 and native Google Voice support

Last week the Asterisk development team announced Asterisk 1.8's release with native support for Google Talk / Gmail calling.  By doing so, a lot of the hackery that was previously done with bridging and AGI dialers in my earlier posts can be axed.

Even though Asterisk 1.8 was released, I didn't see any developers jumping on creating OpenWRT packages, so I decided to do so myself.  I've produced packages for both ar71xx devices (like the one I detailed in earlier posts) as well as brcm-2.4 devices that the market is flooded with.

These packages can be found at
I've also submitted the packaging changes to a ticket for inclusion in a future OpenWRT release at

So for an ar71xx device, you would add this line to your /etc/opkg.conf:

  src/gz asterisk1.8

If you've got asterisk 1.6 installed, you'll need to remove all of the associated packages for it before proceeding.

opkg remove asterisk16-sounds asterisk16-res-musiconhold asterisk16-res-agi asterisk16-func-db asterisk16-format-g726 asterisk16-form
at-g729 asterisk16-codec-g726 asterisk16-codec-a-mu asterisk16-app-system asterisk16

For Asterisk 1.8, I think these are the only packages you'll need:

opkg install asterisk18 asterisk18-func-db asterisk18-res-musiconhold asterisk18-chan-gtalk asterisk18-res-rtp-asterisk

Configuration Files

Once installed, you need to add your google information to /etc/asterisk/gtalk.conf.  This configuration will dump my incoming gtalk calls directly to a context that will be defined as 'google-in'.

context=google-in ; Context to dump call into

[guest] ; special account for options on guest account


Next configure jabber information in /etc/asterisk/jabber.conf.  This setup will cause you to always be signed into jabber, so make sure to set yourself away and give an informative message to know that it's a computer signed in, not a human.

secret=(your password)
statusmessage=I am asterisk [*]

Lastly configure your /etc/asterisk/extensions.conf dialplan for the new inbound and outbound features.  This is built upon my previous dialplan.  It will support incoming sip or google talk/voice as well as outgoing SIP, toll free, and GV.

; --
; Inbound Calls
; --

; * This extension is where any external SIP calls should route to
exten => s,1,Set(CALLERID(name)=${DB(cidname/${CALLERID(num)})})
exten => s,n,Dial(SIP/101,10)
exten => s,n, Hangup
exten => 101, 1, Dial(SIP/101, 10)

; * From Google (superm1)
exten =>, 1, Dial(SIP/101, 180, D(:1))

; --
; Outbound Calls
; --

; * Default starting context for internal SIP devices
include => local-devices
include => tollfree
include => gv-outbound
include => dial-uri

; * These are for any local extensions we should be supporting
exten => _1, 1, Dial(SIP/101,10)

; * Toll free numbers (don't use GV for these)
exten => _411, 1, Dial(SIP/,60)
exten => _1800NXXXXXX,1,Dial(SIP/${EXTEN},60) 
exten => _1888NXXXXXX,1,Dial(SIP/${EXTEN},60) 
exten => _1877NXXXXXX,1,Dial(SIP/${EXTEN},60) 
exten => _1866NXXXXXX,1,Dial(SIP/${EXTEN},60)

; * Route the call using the google voice bridge
;append an area code if necessary
exten => _NXXXXXX,1,Set(CALLERID(dnid)=1512${CALLERID(dnid)})
exten => _NXXXXXX,n,Goto(1512${EXTEN},1)
;append a 1 if necessary
exten => _NXXNXXXXXX,1,Set(CALLERID(dnid)=1${CALLERID(dnid)})
exten => _NXXNXXXXXX,n,Goto(1${EXTEN},1)
;do our real dialing
exten => _1NXXNXXXXXX,1,Dial(Gtalk/superm1/${EXTEN}
exten => _+1NXXNXXXXXX,1,Dial(Gtalk/superm1/${EXTEN}

; * Dialing by SIP URL eg
exten => _[a-z].,1,Dial(SIP/${EXTEN}@${SIPDOMAIN},120,tr)
exten => _[A-Z].,1,Dial(SIP/${EXTEN}@${SIPDOMAIN},120,tr)
exten => _X.,1,Dial(SIP/${EXTEN}@${SIPDOMAIN},120,tr)

Advantages / Disadvantages
  • This configuration is far quicker and more like a real phone.  When you dial a number, it will be connected within seconds rather than 30's of seconds.
  • The quality seems better than the old way (and in theory should be less hops, and less latency)
  • You have to always be signed into Google Talk/Chat with this solution.  If people IM you and you aren't on a computer, then the IM is lost in your gmail history.
  • If you are signed into Gmail Chat and the computer supports video (has the plugin installed) then your SIP phone won't ring.
Thanks to Paul Jennings for helping to provide a quite functional configuration to get started here for me, as well as AST/Calling+using+Google for detailing all the options actually available to configure.

This post seems to be the post that people are linking to and reading mostly when setting up Asterisk 1.8.  Just want to make sure I mention, there have been improvements since this post (as detailed in other future blog postings).  To avoid having to relive the learning experience I did with my other improvements, my (scrubbed for passwords) configs are available at


  1. Just what I'm looking for. The code for supporting Google Voice in Asterisk. Thanks for sharing!

  2. Mario:
    Thanks for your good work. I just got openwrt installed in my new buffalo router and want to try this out. Can you give an example of sip.conf? My main question is which context I should use?

  3. twinclouds:
    Take a look at my first post, i've got a sample device listed in there for sip.conf:

  4. Hi, Mario:
    It works perfectly. Thank you very much again.
    If I would like to build such a package for Kirkwood can you point me to where I can find the procedures? Namely, where to find makefile and source codes?
    I know it is too ambitious, because I have never build packages for OpenWRT before. However, I just want to try.
    Thanks again for your good work.

  5. twinclouds:
    Great, glad that worked. will get you started on checking out the source tree.

    Run make menuconfig to configure for your device.

    Add the asterisk package into the proper packages directory.

    Run make menuconfig again and select all the asterisk packages you want to build

    Run make and it should spit out an image after a few hours.

    Surely you'll run into some other problems along the way, but that should get you started.

  6. Hi, thanks for putting all this together. I was trying to follow your how-to but I got lost modifying sip.conf. I don't have a Gizmo5 account and they closed the sign up process, what sip server can I use instead?

  7. Mario:
    I installed your brcm1.4 Asterisk1.8 on an old SimpleShare NAS with OpenWRT. Your package also worked perfectly. However, when start Asterisk, I did notice some errors and warnings but they seems having no affect the gtalk ability. The errors are:
    "ERROR[891]: netsock2.c:245 ast_sockaddr_resolve: getaddrinfo("OpenWrt", "(null)", ...): Name or service not known" and "ERROR[891]: acl.c:693 ast_ouraddrfor: Cannot create socket
    == SIP Listening on
    == Using SIP CoS mark 4".
    Maybe you can find the cause. These errors happened on both packages.

    For doublel's questions about the sip.conf, I provide an example worked for me below.

    callerid="user1" <101>

  8. Hi Mario

    Can you please build and upload the skypeforasterisk plugin at the software website for openwrt ?

    Any help would be greatly appreciated.


  9. Salim:
    I'm not sure it will work on mips. It seems to only be for x86:

    Someone on the #8132 ticket posted that too. Their fix was:
    Also, while starting, I had to adjust /etc/hosts in order to change the first line to : localhost localhost.

    At some point I should post my current config files that aggregate all of these posts together. I suppose it's not too much fun for others to live all of the stuff that i've (slowly) learned about maintaining and improving an Asterisk setup :)

  10. doubele:
    I've added a block to the top right of the blog to provide all of my sample configs in one place. These are scrubbed a little, but otherwise what I use in production.

  11. Mario:
    What do you mean you need by "Also, while starting, I had to adjust /etc/hosts in order to change the first line to : localhost localhost"? I thought the suggestion as to change the first line to localhost localhost. I guess the is the name of OpenWRT server defined in /etc/config/system.

  12. Somehow, the host name in triangle blankets ware deleted automatically. It probably did the same thing to you.

  13. twinclouds:

    I'm not sure entirely exactly that meant since i haven't had that problem on my system. I copied it out ticket 8132.

    Here's mine:
    root@supermarioworld:~# cat /etc/hosts localhost. supermarioworld

    I'm not sure if I added that second line or if it was done by openwrt at some point.

  14. Mario:
    Thank you for your prompt response. I changed the hosts file according to ticket 8132 as:

    root@SimpleShare:~# cat /etc/hosts localhost SimpleShare localhost.

    After that, I still see a few warnings but the errors are gone.

  15. Hi Mario,

    I'm working slowly to get this awesome config working at my home router, but I have a question, on the disadvantage part you don't mention anything about voicemail handling, I would like not to loose the option to send calls to Google Voice voicemail if I don't answer, do you think this will happen with this setup?

  16. Hi Carlos:

    By default with my collection of configs the calls should still go to google voice voicemail if you don't answer.

  17. Mario:
    I also tried on an ASUS 520GU router and there was not enough memory. It appears at least 8 MB flash will be needed. Is this true?

  18. I haven't checked the exact size that's needed, but the 520GU has a USB port, you should be able to get away with doing this with a small thumb drive and an external rootfs. My first blog post talks about what I did to make that work.

  19. Hi Mario,

    Thank you for your previous answer I guess I was worry Google Voice servers would see like if the call was picked up by my asterisk immediately, I guess this is not the case.

    Could you please comment on your firewall rules, do you do anything fancy to avoid sip spammers cracking or overwhelming your router? Also do you have QoS implemented?

    BTW it may be helpful to others that if you want to connect your sip client from outside your home network you need to open at least 5060 port on your OpenWRT firewall. In your /etc/config/firewall add:
    config 'rule'
    option 'src' 'wan'
    option 'dest_port' '5060'
    option 'target' 'ACCEPT

    This will be very handy for me in my upcoming trip abroad, now my Android phone wont be a dead brick, at least as long I have WiFi access.

    Thanks Mario, awesome post!

  20. Oh and one last thing(who I'm kidding ;-)), is there anyway to have the gmail password on jabber.conf in a hash or any non plain text from?, I'll love to set up this for my girlfriend, but I don't want to have access to her password.


  21. Carlos:
    Firewall rules:
    * I don't have anything to avoid overwhelming the router. This hasn't been a problem yet, but if it is, the only real thing that can be done is moving sip to a non-standard port on the outside.

    Avoiding Crackers:
    * Choose extension names that aren't quickly guessable.
    * Looking through my logs, people who try to crack are commonly going for the numeric extensions, so alphanumeric helps.

    * Yes, i've got QoS setup, but I haven't updated it for the way that GV works with Asterisk 1.8 yet.
    * I installed the qos-scripts package
    * Modify /etc/config/qos for your up and down BW via a speedtest
    * If you come up with some good rules that cover the new GV ports, i'm all ears.

    PW in jabber.conf:
    * I could see where you're coming from not wanting to have that access. I double checked through the 1.8 source and didn't see support for hashes rather than PW's. Glancing through the code it seems to transmit a sha1sum of the password anyhow, so perhaps the author of res_jabber would be open supporting that instead.
    * If you want to contact him, according to the docs:
    The maintainer of res_jabber is Philippe Sultan .
    * If he gets that support added i'll be glad to pull that patch into the packages I built. It would be quite useful to have.

  22. Carlos:
    Oh and one other thing. If your phone is Android, give Csipsimple a chance rather than sipdroid. I've personally found better performance with it.

  23. Nice, I'll give a try to Csipsimple.

    I submit a feature request to the asterisk bug tracking:

    I know most devs like this way better, I'll also send an email to the author, let see if he finds this useful and implements it quickly.

    Thanks for all your help.

  24. Mario:
    Thank you for your suggestion to install it on external USB drive. I might try it. On the other hand, it is probably easier to buy anther one with 8GB flash and sell the 520GU on Ebay.
    Your packages work very well on OpenWRT as I said before. However, I had problem with Asterisk 1.8 on Dockstar/Debian and others also did. It must a bug in the Dockstar/Debian/Asterisk1.8 combination. I installed using exactly the same procedure on VMWare/Ubuntu on my PC had no problem. On the other hand, I installed FreePBX/Asterisk 1.4/1.6 on Dockstar/Debian had no problem either. Do you know how I can inform Asterisk 1.8 development community about the issue?

  25. Carlos:
    Great thanks for filing that.

    I'm not positive that you'll be able to fit even with a 8MB flash for sure. Before you sell your 520GU, I'd make sure that the new one you pick up is from somewhere returnable and really does fit.

    The usbrootfs stuff is quite nice to have though. You don't feel cramped whenever you want to try something new on the router.

    As for your Dockstar/Debian problem, I'm not sure on the specifics of the problem so it's hard to say where the best people to go to would be. If it's actually a Debian problem there's dozens of debian mailing lists and IRC channels. If it's an Asterisk problem, #asterisk on freenode is a good starting point, or Digium's asterisk mailing lists.

  26. Mario:
    Thank you for your response. You are really so helpful.
    I know 8 MB flash will work because I have installed your packages on an old SimpleShare NAS which has 8 MB. In total it uses about 5.5 MB with Asterisk 1.8 but not much other packages.
    I will try the usbrootfs approach as well but right now, with the Simpleshare working, I really want to compile Asterisk for Dockstar. I downloaded from as you said. Now I need to find what to do. The first question I have is where I should get the Asterisk 1.8 code for compilation. I know I can get it form Digium's asterisk download page just not sure if it is the right think to do and where to put it. Just hope there is a good how to write up about how to compiling such packages as you did. This seems a very steep learning curve.
    I will try to contact the Digium's and Debian Forums to see if I can get more information and help.
    Thank you for taking time to answer my questions, as always.

  27. It was working this morning but it stopped working this evening without any change. I could hear the rings but cannot reach the other side. Not sure what happened. The asterisk log shows:
    *CLI> == Using SIP RTP CoS mark 5
    -- Executing [8586584251@gv-default:1] Set("SIP/102-00000000", "CALLERID(dnid)=18586584251") in new stack
    -- Executing [8586584251@gv-default:2] Goto("SIP/102-00000000", "18586584251,1") in new stack
    -- Goto (gv-default,18586584251,1)
    -- Executing [18586584251@gv-default:1] Dial("SIP/102-00000000", "Gtalk/asterisk-gv/") in new stack
    -- Called asterisk-gv/
    WARNING[676]: channel.c:5544 ast_channel_make_compatible_helper: No path to translate from Gtalk/ to SIP/102-00000000
    NOTICE[672]: chan_gtalk.c:1942 gtalk_parser: Remote peer reported an error, trying to establish the call anyway
    Anybody know what is the problem.

  28. twinclouds:
    Not sure what's going on here, but mine and my buddy's boxes are both busted too. To make matters worse, it's still working on the gmail client. It seems something was changed on the google end that's busting it for asterisk..

  29. Seems to be happening to others with asterisk too:

  30. I switched the google voice number but still does not work. I think what wardmundy said is probably what happening, but I think Google is monitoring the ip address rather than the number. In Ward's solution, he disconnected the jab to connect with gtalk during the evening ours. I don't know the Asterisk 1.8 keeps such a connection or not, i.e., does jabber logs into gtalk whenever asterisk 1.8 is on? If not, his solution will not work.

  31. I left mine disconnected for a few hours and tried again and no luck still. I'm not sure that's what it is yet. Someone has opened a ticket with Asterisk upstream:

    If a patch shows up there, i'll be glad to rebuild with it..

  32. Mario:
    Thanks for keeping up on this issue. Hope we can have a solution to the problem.
    As for build asterisk 1.8 packages, with help from you and others, I have been making progress. I have been able to build Openwrt rootfs for Dockstar from svn source and it worked. During the process, I was also able to build asterisk 1.6 packages. Look at the asterisk 1.6.x directory, I assume what I need to do are as follows: (1) Create a new asterisk 1.8.x directory; (2) Copy everything inside the directory 1.6.x into the 1.8.x directory; (3) copy the patch file you submitted to ticket 8132 to the patches directory (rename if necessary). Is my thinking correct or I need to something else or different? Additionally, there are two things I would like to have your input: (1) Do I need need to change Makefile or just make patch is sufficient? For the existing patch, do I need to delete it or just change the new patch to 200xxxx.patch?
    Thanks again for your help.

  33. Maybe I just need to edit the Makefile and the patch file according to your diff files?

  34. twinclouds:
    I've got a temporary hack to restore outbound dialing at

    For building, you should apply that whole patch to the directory. It doesn't go in the patches directory, it actually patches Makefile and one of the patches in patches/

  35. Mario:
    Thank you for your response. I tried your hack but somehow it give me some errors so I have not make it work yet. I think the reason is that I didn't update my conf files to your latest. It was o.k. before but will probably need to be updated for your patch. For example, astagidir was not in the right place in
    the asterisk.conf file. It's too late now. I will try it tomorrow or over the weekend.
    I tried to patch the directory. However, the version of 1.6.x is one newer than yours. So the patch has a lot of errors. I did have a patched file but I am not sure I can use it.
    If I use your conf files and your new hack, will these work on Asterisk 1.6? If they can, I don't need to do asterisk 1.8 for now. Maybe wait a little bit for the problem being solved.
    Thank you very much, as always.

  36. twinclouds:
    Yeah there's potentially some other stuff that's been done (like setting agi directories) that might have been mentioned in my earlier blog posts. I've updated the config files posted to the web to match that hack. Feel free to compare to them.

    As for if this will work with 1.6.x, it will only work with 1.6.x if you use gizmo for incoming (which i've outlined in earlier blog posts too).

  37. Mario:
    With your help and others, now I am able to building the rootfs/Images of Openwrt and the asterisk 1.6 packages. I also used your patch/diff files to made new Makefile and patchs for Asterisk 1.8 (with some manual editing). I put them in a new folder asterisk-1.8.x on the side with asterisk-1.6.x. However, the make menuconfig cannot recognize the new asterisk-1.8.x. Could you tell me how you make such a new package or point me to something I can read?
    Sorry the trouble for you again.

  38. I put the asterisk-1.8.x folder into ~/trunk/package/ directory. (I don't know if it is the right place to put it and if there's anything else I need to do.) Now the menuconfig can recognize it. However, "make menuconfig" returns: there are errors in Makefile. It looks like the compiler cannot find the undefined symbol 'PACKAGE_asterisk14' and some recursive dependencies. Not sure what I can do now.

  39. Mario:
    With your help, I have been making a lot of progress in compiling my own rootfs and making packages for the Kirkwood platform. However, since I am still very new to Openwrt, now I have some troubles of compiling the Asterisk 1.8 package. Among other things, I cannot directly use your patch file because they upgraded the Asterisk 1.6.x directory (from .13 that you use to .14). It will be a great help if you can provide me your patched 1.8.x directory so I will know I have something working and to figure other problems out, not to chase multiple problems at the same time. I would really be very appreciated. Thanks in advance.

  40. Mario -
    Thanks for all your work on this. I've patched my custom OpenWrt build with your Asterisk 1.8 patch submitted in ticket #8132 ( I'm running on a TP-Link TL-WR1043ND (ar71xx). Everything built fine without any errors. However, I get a segmentation fault when asterisk starts (without any other error indications).

    On the other hand, when I install your Asterisk 1.8 packages via opkg, it seems to work fine.

    Any ideas on what the problem may be? Maybe some missing dependency? I'm stumped here. Thanks.

  41. Mario:
    I have the same problem (segmentation fault) on my build brcm-47xx. Not sure why. I used brcm-47xx because in the svn build, I have no way to select brcm-2.4 to build the image with block-extroot. How do you build the packages for brcm-2.4? BTW, extroot on brcm-47xx works perfectly.
    Many many thanks for your help during the past year.
    Merry Christmas and Happy New Year!

  42. I guess I have solved my problem and would like to share with others have the same problem. The Asterisk 1.8.0-2 compiles and runs fine with backfire. I have also compiled openwrt with extroot also under backfire. (both for brcm47xx) I guess the key is not to use the latest (trunk). Since all I need is something that works, I guess I don't need the latest code anyway.

  43. Hi Mario:
    Thank you for your Asterisk 1.8 package. I am using it with openwrt on a wrt54gl router.
    I managed to have TLS running and now I would like to setup SRTP.
    For now it seems I am missing the res_srtp module. I tried compiling it myself but couldn't get it to work. This is what I get starting up asterisk with my own
    [Jan 13 17:08:31] WARNING[9890]: loader.c:387 load_dynamic_module: Error loading module '': File not found
    res_adsi => (ADSI Resource)
    [Jan 13 17:08:31] WARNING[9890]: loader.c:400 load_dynamic_module: Module '' did not register itself during load
    [Jan 13 17:08:31] WARNING[9890]: loader.c:839 load_resource: Module '' could not be loaded.
    [Jan 13 17:08:31] WARNING[9890]: loader.c:387 load_dynamic_module: Error loading module 'res_crypto': File not found

    If you still have the toolchain setup could you add this module to your package.

  44. THANK YOU! Installed Asterisk 1.8 with your config files on my WNDR3700 running DD-WRT. Plugged in all my google info, connected my sipura ATA to the 101 account, and it WORKS!

  45. Have a question about the 1st bullet under disadvantages. What do you mean by "You have to always be signed into Google Talk/Chat with this solution. If people IM you and you aren't on a computer, then the IM is lost in your gmail history."? Do I have to have my PC on and sign into my google voice account?

  46. Kate:
    Glad it works!

    If you don't leave a PC or Android phone signed in simultaneously as the Asterisk then any instant messages sent to you will be missed. They'll actually come in, but be marked immediately read in your gmail, so you will never see them.

  47. Question about the dialing plan. Is there a reason why we don't want to route toll free calls through GTalk?

  48. Any chance you could integrate this patch into these packages?

    This lets you set your status to invisible, so asterisk doesn't make your status always online.

  49. James:
    You are welcome to do that too. This was mostly because if talk went down for any reason (or started requiring money) I could still use it for my conference calls for work.

    Thanks for the pointer. I've included the patch. Hopefully it will land upstream too.

  50. Thank you very much for the fast response, and adding that patch!

    When I try to install the new packages, I get the following error:
    Collected errors:
    * opkg_install_cmd: Cannot install package asterisk18-res-rtp-asterisk.

    It appears to run fine though.

  51. Tom:
    I believe that package is no longer part of the distribution that landed upstream is all. I'll probably have to adjust some of my documents about it.

  52. Hi, I tried the brcm-2.4 packages on my openwrt w500gp router with kamikaze 8.09.2, unfortunately I get this error:

    * Packages were found, but none compatible with the architectures configured

    why? Thanks

  53. Federico:

    I just refreshed the Packages.gz on that architecture. Can you check if the problem still persists? Can you post the line you added to opkg.conf?

    It should be:

    src/gz asterisk1.8

  54. Hi, I can't see the post on the blog, did you receive the notification e-mail?

  55. Hi, I finally got it working, could you please compile and upload chan_skinny?

  56. Hey, I took a look at Asterisk's source code, and before they compute the SHA1 sum of the password, they are concatenating the clear-text password in jabber.conf to some sort of "id" which iksemel parses out from somewhere. At the moment, I am imagining this is some sort of session ID which is negotiated per session. Hence, I don't see ANY way that a SHA1 hash can be stored in jabber.conf instead of a clear-text password, since there is no way to reconstruct the SHA1 of the password+ID from the SHA1 of just the password. Has anybody looked and reached a different conclusion?


  57. Very nice tutorial!

    Here is another similar tutorial on Asterisk
    hope it helps!!

  58. Interested in advertising On


    We can offer you up to $60 for a link on one of your site’s internal pages. We are working on a project to increase our page rank and site visibility. We just need to turn words that are already in the article into links for us. Let us know if you are interested. We can pay you within 48 hours of the link being up.

    We basically require space for small text based ads that will not use that much space of your site. We assure you the relevance of the ads to your website and its content. Moreover, we will also help you in generating income from your website by placing the advertisements of our 7-8 clients. We can help you grow your revenue via placement of relevant advertisements on your site.
    Additionally, if you needed sponsored content, we are ready to offer you that as well. The payment is done via PayPal.

    So, what are you waiting for? Let us develop business and grow together!

    Best Regards,

    Robert Showerman
    Marketing Manager

  59. hi,

    I am using asterisk (inspired by OP) for gvoice+csipsimple on my android phone. It works pretty good and I put my instructions here.


  60. Sorry to revive an old topic, but can you post an optware build with SRTP enabled? I tried building it myself, but was unsuccessful.