MangoUse DMZ and you get a kick in the dick. Premium Member join:2008-12-25 www.toao.net 1 edit
3 recommendations |
Mango
Premium Member
2009-Aug-4 12:31 pm
[How to] Install Asterisk on an Asus WL-520GU routerAs promised, here's how I built an Asterisk box out of a $37 router. This will likely eventually turn into a post on my blog but I figured I'd subject everyone here to the rough draft first I am not going to go into a great deal of detail with this post. You should be comfortable with basic networking and VoIP concepts such as how to configure a static IP, how to use Telnet/SSH, and how to configure a VoIP phone or ATA. Having said that, if anything does turn out to be particularly vague, I'd be happy to clairfy. I chose the WL-520GU because it was one of the few routers I could find with a USB port. I read about techniques for modifying a WRT54GL to use an SD card but I decided that plugging in a USB device was easier than getting out the soldering iron. I decided Tomato would be my firmware of choice. Tomato is the most popular firmware I see VoIP users use and it has a great reputation for its QoS features. I have heard it is possible to install Asterisk on a router without any additional storage space. The reason I chose the USB technique is that I wanted extra space for things like sounds and music-on-hold files. I also wanted space for logging, if necessary (though usually I leave logging off.) Before we start, you may want to attach the WL-520GU to another router connected to the Internet. Some modems, such as my Motorola cable modem, don't particularly like issuing IP addresses and you will need to reboot the WL-520GU a few times during this process. In order to do this, you will need to be sure both routers have different IP addresses. Now for the first step, which is obtaining DD-WRT. No, that's not a typo; you should install DD-WRT before installing Tomato. There is a good reason for this but I cannot remember what it is, and since this is a "How To" and not "Why", suffice to say "you need to install DD-WRT first." First, download the latest stable version of DD-WRT. Visit » www.dd-wrt.com/ , click the Downloads tab, navigate to the stable folder, navigate to the latest version, then the Consumer folder, then the Asus folder, then the WL520GU folder, and finally to the file dd-wrt.vXX_mini_asus.trx. (Whew!) I have heard rumors that you should not save this file in any directory that has a space in it. I haven't tested this, but I'd recommend you do this to be on the safe side. Now, you need to flash the DD-WRT firmware to the router. I would recommend setting your computer up with a static IP. I discovered that while flashing, the router did not always issue an IP address. As with flashing any firmware, be sure to do this over a wired connection and not a wireless one. You may also need to disable any software firewalls. After setting the static IP, test to be sure that you can access the router's setup page over a wired connection. To flash firmware, you should use Asus' Firmware Restoration Utility. Note: do not use the latest version from Asus' website as it probably won't work. The best version to use is the one on the CD that came with the router. If you have lost it, be sure download the right version of the Firmware Restoration Utility for your specific router. Load the Firmware Restoration Utility and browse to find the trx file you just downloaded. Don't upload it yet! Unplug the power from the router and consider the two buttons on the back. Using a small screwdriver or a ballpoint pen, press the reset button. Hold down the reset button and plug the router back in. When the Power LED begins to flash, release the reset button, and upload the firmware. If all goes well, DD-WRT will be installed. To be sure everything worked, navigate to the setup page and log in. One set of instructions I was following told me to log in with blank username and password admin. Another told me username admin and blank password. Actually, I had to log in with admin/admin. Next, take a look at this forum thread: » www.linksysinfo.org/foru ··· ?t=60185 . This is the thread that talks about a modification of Tomato that has USB support. Navigate to the download link. Note that there are a few flavours available. I chose the ext flavour because I needed tools to partition and format the USB drive. If you have a Linux box that you can use instead, you can download the smaller Standard build, or if you do not require Samba, you can download the even smaller Lite build. Download and unrar the file. The password after we flash Tomato will be different and it is necessary to find out what it will be. In order to do this, telnet into the router. Use the username root and whatever password you used to access the setup page. Type nvram get http_passwd and copy the password that it returns. Now, return to the DD-WRT setup page. Navigate to Administration and then to Firmware Upgrade. Browse to the Tomato firmware you just downloaded and upgrade. Attempt to log in to the Tomato setup page. When I did it, the username was root, and the password was what I found in the previous step. Congratulations! You have just installed Tomato on your router! As with any new router install, before you continue, be sure to do the following: 1) Change the password on the router to something difficult to guess. 2) Secure the wireless connection, or disable it if you don't plan to use it. 3) You may want to disable wireless access to the Tomato setup page. 4) You may want to properly configure such settings as Time Zone. |
|
Mango 3 edits |
Mango
Premium Member
2009-Aug-4 12:51 pm
The next thing I would recommend doing is setting up SSH. SSH is a more secure way of accessing the router. If you're on a private internal network and do not allow remote access to the router, this may not matter, but it's good practice to do anyway. First, download PuTTY and PuTTYGen if you don't have them already. If you're not using Windows, you can use any other flavour of SSH client you prefer. The way I like to access SSH is with an RSA key. Start PuTTYGen. The default settings of SSH-2 RSA and 1024 bits will typically be fine to use. Click the Generate button and follow any prompts that appear. Click 'Save Private Key' and save the file in a safe place. Next, load the Tomato setup page. Navigate to Administration and then Admin Access. Enable the SSH Daemon, and paste the public key in the Authorized Keys box. I recommend disabling Remote Access. Save your settings. Now, load PuTTY. Enter the Host Name or IP Address of your router and select the SSH protocol. Navigate to the Connection category from the list at the left. Select Data and, if you like, enter root as the auto-login username. Next, select SSH, and then select Auth. Browse to find the private key file you just created with PuTTYGen. Return to the Session category, enter a name in the Saved Sessions box, and press the Save button. You should now be able to log into the router using SSH. Now is a good time to set up a script I wrote. This script disables or enables access to the router when the button on the back is pressed. There are two advantages to this. One is that if access is disabled, the router is more secure. The other advantage is that less memory is used, and with 16MB of RAM, every little bit helps. Return to the Tomato setup page. Navigate to Administration and then Buttons / LED. Change the first two dropdown menus to Run Custom Script. Here is the script, which you may paste into the text box below: killall httpd # Stop the web server.
if [ $? -eq 0 ]; then
# The killall command was successful. Let's kill everything else.
killall smbd # These two are for Samba.
killall nmbd
killall dropbear # This is the SSH server.
else
# There was no process running named httpd. Let's restart everything.
cd /www # httpd must be started from the /www directory.
httpd
smbd -D
nmbd -D
dropbear -p 22 -a
fi
Save your settings and test a few times to be sure the script works. At this point you may disable the Telnet service. Note that this script depends on the program "buttons" running. If for any reason buttons is killed, the script will not work. For this reason, I recommend you leave "Enable at startup" turned on for the SSH daemon so that if the button does not work, all you need to do is reboot the router. |
|
Mango 1 edit |
Mango
Premium Member
2009-Aug-4 12:52 pm
We're almost ready to install Asterisk. But first, we need something to install it on. If you've already formatted your USB drive as EXT2, you may skip the next few steps. If not, attach your USB drive and read on. The first drive I used for this project was an OCZ Roadster drive. I discovered however that it ran very very very hot - too hot to touch after only a few hours of use. While this would be no problem for making a quick backup, this would not do for an appliance that is supposed to be on 24/7. The other drive that I had was a Dane-Elec drive which I purchased at the grocery store of all places. It was a great deal because it was labeled 1GB and it's actually a 2GB drive. It runs very cool and is ideal for my purposes. Return to the Tomato setup page, navigate to USB and NAS, and then to USB Support. Enable Core USB Support, USB 2.0 Support, USB Storage Support, and Ext2 / Ext3 File System Support. If the drive automatically mounted itself, unmount it before continuing. Now it is time to partition and format the drive. Note that anything on the drive will be erased during this process. SSH into the router and type fdisk /dev/discs/disc0/disc. To be sure you've selected the correct drive, use the command p. The first line will tell you the size of the drive. The system column will tell you the format. If the drive is currently formatted as FAT32, under the System column should be Win95 FAT32. Type d to delete the current partition, if one exists. Then, type n to create a new partition. Follow the prompts to create a primary partition. If it asks for a partition number, enter 1. Use the defaults for cylinders. Next, enter w to write the partition table and exit fdisk. If you've made a mistake, instead exit by pressing CTRL+C and start over. Congratulations! You have created a partition. Now we need to format it. If you are a beginner such that you require this guide, you should use the ext2 filesystem. Type mkfs.ext2 /dev/discs/disc0/part1 -L USBNote that "USB" may be anything you like. -L specifies a volume label and I decided "USB" would be easy to remember. Finally, run a check on the new partition by typing fsck.ext2 -f -y /dev/discs/disc0/part1Next, you should configure the drive to automatically mount. Return to the Tomato setup page and turn "Automount" on. In the "Run after mounting" box, enter [ -d /mnt/USB ] && mount /mnt/USB /opt . Why? You'll see Save your settings. |
|
Mango 2 edits
1 recommendation |
Mango
Premium Member
2009-Aug-4 12:52 pm
Now you're finally ready to install Asterisk. The way I installed it was with Optware. First, unmount and mount your USB drive to be sure that /opt was properly created. Next, download the Optware install script... wget http://www.3iii.dk/linux/optware/optware-install-ddwrt.sh -O - | tr -d '\r' > /tmp/optware-install.sh
...and run it. sh /tmp/optware-install.sh
Installing Asterisk is as simple as ipkg update
ipkg upgrade
ipkg install asterisk14
ipkg may recommend some other packages to install such as sound and music-on-hold files. Install them if you want. I only installed the uLaw versions because I only use the G.711 codec. If all goes well (and when I did this it did) you will now have Asterisk installed on your WL-520GU. Start it by typing asterisk -vvvc. Or configure it to start automatically by adding /opt/sbin/asterisk to the "Run after mounting" box on the Tomato setup page. At this point you will probably want to play with Asterisk's configuration. When I used the sample configuration files, Asterisk ran, but the audio quality was poor because memory usage was very very high. The sample modules.conf loads a great deal of modules, many which you will not need. I was able to drastically reduce Asterisk's memory usage with the following modules.conf. For a description of these modules, type module show at the console. [modules]
autoload=no ; only load explicitely declared modules
load => app_echo.so
load => codec_ulaw.so
load => pbx_config.so
load => res_features.so
load => chan_sip.so
load => app_dial.so
load => format_pcm.so
load => app_playback.so
load => func_callerid.so
load => app_setcallerid.so
load => func_logic.so
load => app_macro.so
load => app_mixmonitor.so
load => format_wav.so
load => res_musiconhold.so
Reducing logging also improved my call quality as it meant less writing to the USB drive. My logger.conf is now a blank file. I also disabled Tomato's bandwidth monitoring and logging on the Tomato setup page. Also, press the button on the back of the router to disable remote access, if you're not currently using it. Congratulations! You are now the proud owner of a $37 Asterisk box that uses only a few watts of power. Bet you spent less than the Digium Asterisk Appliance, didn't you? That's all for now, but later on I'll post my extensions.conf, as well as my technique for propagating Message Waiting Indicator from your VoIP provider. Happy VoIPing! m. |
|
maziloFrom Mazilo Premium Member join:2002-05-30 Lilburn, GA |
to Mango
Mango, Can you confirm the Tomato firmware can support USB2 on WL-520GU router? If so, how stable is the USB2 driver? I read the from the OpenWRT Table of Hardware list for Asus WL-520GU that even Asus has USB2 support disabled on its firmware. |
|
MangoUse DMZ and you get a kick in the dick. Premium Member join:2008-12-25 www.toao.net |
Mango
Premium Member
2009-Aug-4 1:00 pm
The modified Tomato firmware does indeed support USB2. I've only been using it for a few days, but fortunately it has been very stable.
m. |
|
|
to Mango
do you know if g729 will work ? if yes is there a 'test' g729 codec available for this chipset to test it out ? |
|
|
MartyT join:2004-09-03 Georgetown, SC |
to Mango
The WL-520GU is one of my favorite routers. I use it on all my VOIP installs. Just be sure to get rid of the stock firmware. It really sucks in my experience. Tomato 1.25 is a dream.
Asterisk? My favorite PBX, but FreeSwitch with FreePBX might change that.
With Mazilo lurking around, I see a new convert to the WL-520GU platform. |
|
maziloFrom Mazilo Premium Member join:2002-05-30 Lilburn, GA 1 edit |
to hoolahoous
said by hoolahoous:do you know if g729 will work ? If there is a GPLed G729 source codes, then one should be able to port it to any platform. Unfortunately, I have yet to see a GPLed G729 source codes. However, I believe ITU once had posted some sort of G729 source code on its site and allowed anyone to download it for free. For asterisk, you can configure both your asterisk + ATA devices to use G729 as a default CoDec and they will both work just fine to provide services with G729 calls. |
|
|
HumanG to Mango
Anon
2009-Aug-6 2:16 am
to Mango
Mango2, Thanks for the write-up. Very nice. Just one question though. Why do you need tomato firmware at all? I think some beta version of DD-WRT also support USB2 drives, and via optware-install and ipkg, you can install asterisk. See wiki » www.dd-wrt.com/wiki/inde ··· /Optware and » www.dd-wrt.com/wiki/inde ··· _storage. I am just wondering if you have tried this method or not. said by Mango:As promised, here's how I built an Asterisk box out of a $37 router. This will likely eventually turn into a post on my blog but I figured I'd subject everyone here to the rough draft first ... ... |
|
edmidorTech - the hard way Premium Member join:2008-05-19 Canada |
edmidor
Premium Member
2009-Aug-6 9:00 am
AFAIK Tomato has much smaller memory footprint, which is a good thing for Asterisk. It has QoS that actually works; and it just easier to operate. If I was to install * on a router, I would only go Tomato or OpenWRT |
|
|
to mazilo
said by mazilo:I believe ITU once had posted some sort of G729 source code on its site and allowed anyone to download it for free. For asterisk, you can configure both your asterisk + ATA devices to use G729 as a default CoDec and they will both work just fine to provide services with G729 calls. do you know which chipset wl-520gu has (broadcomm??) ? I have one of these routers flashed to dd-wrt. i need to do transcoding since my VOIP provider does not provide G729 and I want all my extensions to use G729. |
|
MangoUse DMZ and you get a kick in the dick. Premium Member join:2008-12-25 www.toao.net |
to HumanG
said by HumanG :
Why do you need tomato firmware at all? I think some beta version of DD-WRT also support USB2 drives Emphasis mine. Well, there was talk about having to hack the USB driver on DD-WRT to make it even work with my router. That didn't seem like a good idea. Tomato is also the most popular firmware amongst VoIP users that I know, I assume because of it's highly effective QoS, which edmidor mentioned. I haven't tried QoS on any other open source firmware, but I can attest to QoS in Tomato working, and working very very well. On that note. Oddly, it didn't work at all when using port-based QoS. But, it worked a treat when I used IP-based QoS. I have no idea why. m. |
|
Mango |
to hoolahoous
said by hoolahoous:i need to do transcoding since my VOIP provider does not provide G729 and I want all my extensions to use G729. I'm incredibly curious. Why on earth would you use G.729 if not to save bandwidth? m. |
|
Fisamo Premium Member join:2004-02-20 Apex, NC |
to Mango
Very, very, very nice! I just purchased (and installed) a WL-520GU router at home, and I've already replaced the f/w with DD-wrt, so this upgrade should be pretty straightforward. The next challenge(s) will be to get my dialplan, which I 'perfected' using FreePBX imported to this system.
I'm extremely interested in the how-to propagate MWI from the provider to my internal extensions. From what I've heard, it "can't be done" with Asterisk. (Do you have a separate script monitoring SIP packets?) |
|
maziloFrom Mazilo Premium Member join:2002-05-30 Lilburn, GA |
to hoolahoous
said by hoolahoous:said by mazilo:I believe ITU once had posted some sort of G729 source code on its site and allowed anyone to download it for free. For asterisk, you can configure both your asterisk + ATA devices to use G729 as a default CoDec and they will both work just fine to provide services with G729 calls. do you know which chipset wl-520gu has (broadcomm??) ? I have one of these routers flashed to dd-wrt. You should be able to find the information you are looking for on the link I provided in my post above. i need to do transcoding since my VOIP provider does not provide G729 and I want all my extensions to use G729. Even though you can manage to port the G729 CoDec source to any open-source firmware, I presume the CPU on the router will probably not have enough resources to perform a G729 transcoding. On my Asterisk PBX system, it is just configured with a G729 as the default CoDec and it doesn't do any transcoding. |
|
MartyT join:2004-09-03 Georgetown, SC |
to Fisamo
If you are successful in getting your FreePBX generated files into a router based Asterisk system, let us know. I'm not a hardcoder like Mazilo on Asterisk, and would love to simply transfer FreePBX stuff over, but I'm not sure it works that way, at least it didn't when I tried it.
It would be nice to see some kind of AJAX based FreePBX interface for Asterisk when it runs on such a small system, unless someone has succeeded in getting FreePBX to run off the USB drive on a system like this on the WL-520GU. |
|
Fisamo Premium Member join:2004-02-20 Apex, NC |
Fisamo
Premium Member
2009-Aug-6 1:13 pm
said by MartyT:If you are successful in getting your FreePBX generated files into a router based Asterisk system, let us know. I'm not a hardcoder like Mazilo on Asterisk, and would love to simply transfer FreePBX stuff over, but I'm not sure it works that way, at least it didn't when I tried it. It would be nice to see some kind of AJAX based FreePBX interface for Asterisk when it runs on such a small system, unless someone has succeeded in getting FreePBX to run off the USB drive on a system like this on the WL-520GU. Don't hold your breath... I'm very interested in programming and getting things like this work, but I wasn't interested enough at that important 'career choice' time (college) and haven't been able to invest the time since. The other limiting factor for me at this point is that I have to be wary of taking our gateway (the ASUS router) down when my wife's home. I may just have to hook up the old TrendNET while I play. |
|
|
to Mango
Thanks for instruction, after Asterisk installed on the router one needs modify some of the Conf files (extension.conf, iax.conf, modules.conf, sip.conf....) in order to work with your voip provider. Is there a possibility to screen shoots of these files that include couple of providers? |
|
pandora Premium Member join:2001-06-01 Outland |
to Mango
At Newegg about 6 weeks ago, I looked at the WL-520GU and it was $49 with free shipping. The WL-500gp was $69 and there are mega versions of DD-WRT which already have Asterisk installed. Wouldn't it have been easier to pop for another $20 and install the mega version of DD-WRT with Asterisk? |
|
maziloFrom Mazilo Premium Member join:2002-05-30 Lilburn, GA |
mazilo
Premium Member
2009-Aug-8 5:08 pm
said by pandora:At Newegg about 6 weeks ago, I looked at the WL-520GU and it was $49 with free shipping. The WL-500gp was $69 and there are mega versions of DD-WRT which already have Asterisk installed. Wouldn't it have been easier to pop for another $20 and install the mega version of DD-WRT with Asterisk? If that is the case, I definitely will go with a WL-500GP v1 for additional $20. Not only the CPU is clocked to 266MHz, but also the unit comes with a built-in 32MB RAM as compared to a 200MHz with a 16MB RAM on WL-520GU. |
|
1 recommendation |
to pandora
said by pandora:Wouldn't it have been easier to pop for another $20 and install the mega version of DD-WRT with Asterisk? You can get the mega version of DD-WRT to run on the WL-520gU with a USB flash drive. The idea is that you flash the router with the mini/standard version of DD-WRT and then mod it so it boots from the flash drive (which has the mega version on it). I've been doing this since the beginning of the year and it's been working great! See this thread for details: » www.dd-wrt.com/phpBB2/vi ··· ?t=44448 |
|
pandora Premium Member join:2001-06-01 Outland |
to mazilo
said by mazilo:If that is the case, I definitely will go with a WL-500GP v1 for additional $20. Not only the CPU is clocked to 266MHz, but also the unit comes with a built-in 32MB RAM as compared to a 200MHz with a 16MB RAM on WL-520GU. It's not only RAM and CPU speed, but the WL-500gp has 8MB of flash while the WL-520gu has only 4MB. You can flash meta DD-WRT to the 500-gp, but not to the 520gu. |
|
phdeez join:2003-06-05 Winter Park, FL |
to Mango
Do you think you could install Asterisk on CIFS if your router doesn't have a USB port? |
|
pandora Premium Member join:2001-06-01 Outland |
to Boolah
said by Boolah:You can get the mega version of DD-WRT to run on the WL-520gU with a USB flash drive. The idea is that you flash the router with the mini/standard version of DD-WRT and then mod it so it boots from the flash drive (which has the mega version on it). I've been doing this since the beginning of the year and it's been working great! See this thread for details: » www.dd-wrt.com/phpBB2/vi ··· ?t=44448 That is very clever, and could be used by developers to build test firmwares without bricking routers. Thanks for the link! |
|
ropeguru Premium Member join:2001-01-25 Mechanicsville, VA |
to Mango
Great info in this thread. One thing I would like to see someone build or setup is something like freepbx but the freepbx box does only the configuration and monitoring. The router or appliance runs asterisk and pulls its configuration from the freepbx machine.
So each time the router/appliance it copies a config across the network to the local machine. This way if the configuration machine is down or cannot be contacted, the asterisk appliance will continue to function. |
|
maziloFrom Mazilo Premium Member join:2002-05-30 Lilburn, GA |
to phdeez
said by phdeez:Do you think you could install Asterisk on CIFS if your router doesn't have a USB port? Yes and please read my post where I have my asterisk PBX system hosted on a crappy / mediocre WiFi router with no problem. |
|
wifi4milezBig Russ, 1918 to 2008. Rest in Peace join:2004-08-07 New York, NY |
to Mango
This sounds a lot like the install I did on my Buffalo NAS. Does this install allow for the GUI to be used? |
|
|
to Mango
Can I use netgear WNDR-3300 which support dd-wrt and open-wrt? MAzilo, Can you guide me step by step?Can someone provide me step by step instructions? |
|
maziloFrom Mazilo Premium Member join:2002-05-30 Lilburn, GA |
mazilo
Premium Member
2009-Aug-9 1:25 am
said by thepirate:Can I use netgear WNDR-3300 which support dd-wrt and open-wrt? A Netgear WNDR3300 device is flagged as untested under OpenWRT. Here is the list I do to make my FON2100 device runs OpenWRT + asterisk (it is by no means in details): - Consult with the OpenWRT Table of Hardware to find out if your device is supported (the status is on the last column of the table). It contains a lot of information. In my case with a FON2100, it even contains instructions on how to flash OpenWRT firmware on to the device, YMMV.
- Read this document and it has all the necessary information you will need to know on how to download / build OpenWRT from source. Chapter 2 (Development issues) is what one wants to know how to build OpenWRT from source. Once you know how to build the firmware, you may want to configure the build process to include the asterisk package into the firmware. Caution: If your device has 4MB Flash, it may not have enough space. If your device has only 16MB of RAM, it is barely enough to run asterisk smoothly.
My asterisk-1.6.x PBX system is hosted on an underpowered FON2100 device with 8/16MB Flash/RAM. I have to completely strip off all unnecessary functions, i.e. no WiFi, no router, no bridge, no DHCP, etc., to gain more free RAM space for asterisk to use. Basically, now my FON2100 device is no longer acting as a (WiFi) router, but just a plain Linux embedded device with asterisk. At 183MHz, my FON2100 device barely has enough CPU resources to process a single call with AGI scripts. As such, I have over clocked it to 220MHz so that the same call can be processed faster and smoother. That said, I have no idea what will the outcome be to have asterisk runs on your hardware with 4/16MB Flash/RAM. Good luck. |
|