segunda-feira, setembro 01, 2014

Installing iftop on Asus RT16n on DD-WRT | Linux | KB9JJA

Installing iftop on Asus RT16n on DD-WRT | Linux | KB9JJA

Installing iftop on Asus RT16n on DD-WRT

iftop is a nice command line utility that allows you to see network activity in more detail than the utilities built into DD-WRT. 
I have multiple Asus RT-16N routers that I run DD WRT Version 24-SP2 Big on, and wanted to load this utility on each of them. A search on google found some info but not of it worked. This is my solution to installing iftop on the RT-16 with DD-WRT v24 sp2.
For all the samples here I am using as the address of my DD-WRT router. You will need to substitute the IP address of your router when you see this number.

1)  We need to prepare the router for reconfiguration. By default the install of DD-WRT does not turn on either ssh or jffs filesystem support.
Let start with turning on ssh.
Log in to your DD-WRT router and from the main screen select Services -> Services and find the location on the screen that is labeled “Secure Shell” At a minimum you want to enable SSHd.

Be sure to hit the “Save” then “Apply Settings” button on the bottom of the page.

Next we are going to go to the Administration section. Under Management if you have not already reset the default password to your router change the password here. You have enabled ssh and now someone can ssh to your router you want a strong password at a minimum. 

Scroll down the page a little further and find the JFFS2 Support section. Here we want to Enable JFFS2 Support and also Enable Clean JFFS2 (Warning if you already have used JFFS2 and you select Enable Clean if will erase/format the disk partition) You only want to select this once when you first turn on JFFS2 in most cases)


Scroll to the bottom of the page and select “Save” then “Apply” Once the router is done you will not see how much space you have available for the JFFS2 filesystem, and note that the Clean JFFS2 is not set to Disable. Once the file system has been cleaned (Formatted) DD-WRT sets this radio button back to Disable as seen below.


I am not sure if it is needed or not but I rebooted my router as this point.
Now we are going to ssh into the router from another computer.
From a linux terminal window
$ ssh -l root

$ ssh -l root
DD-WRT v24-sp2 big (c) 2010 NewMedia-NET GmbH
Release: 11/21/10 (SVN revision: 15778)
root@'s password: 
Enter your root password (Same as the admin password you set up on the web configuration page) and you should see the DD-WRT Logo on the screen and get a # root prompt.
OK so now lets check if everything we did so far is correct. lets see if the jffs2 filesystem is mounted in our environment. Enter the df command at the prompt.
# df
You should see something similar to 
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 6016      6016         0 100% /
/dev/mtdblock/4          24960       904     24056   4% /jffs
The numbers are not important what is important is that the /jffs is shown and mounted.
Now we have a file system that we can write to which will allow us to save things and install additional software.
Now we need to update the package manager to get the latest versions of software that we can install.
# ipkg update
Connecting to (
ipkg_download: ERROR: Failed to retrieve, returning t
ipkg_update: Error downloading to /jffs/usr/lib/ipkg/lists/backports
Notice that we received an error when trying to download updates from to /jffs/usr/lib/ipkg/lists/backports
So we need to fix the ipkg system. If we look at the URL that failed in a browser there are no files in the rc5 section any more. After snooping around a bit I did find that there is a backports/0.9 section, so we need to point ipkg to the 0.9 folder in place of the rc5 folder.
The file that contains the configuration information for ipkg is at /etc/ipkg.conf which is a read only file system so we can not change it there. Instead we need to make a copy of it to the  jffs file system we now have mounted. The we can tell ipkg where to get its configuration file from with a shell variable.
# mkdir /jffs/etc
# cp /etc/ipkg.conf /jffs/ipkg.conf
We now need to edit our new ipkg.conf file to point to the 0.9 folder
# vi /jffs/ipkg.conf
Change the line that reads
src backports
To read
src backports

Save the file, and lets try the update again.
We now need to tell ipkg to use the new config file
# export IPKG_CONF_DIR=/jffs/etc/
Now lets try the update again
# ipkg update

It should be successful this time. note that the next time you need to install something you will have the enter the export IPKG_CONF_DIR=/jffs/etc/ command after you log in to let ipkg know to use this alternate config file. Or as an option you can add it into your .profile for the root user so it will be set every time you log in. 
Now we need to install some packages that lftop is dependent on.
# ipkg install libpcap libncurses libpthread
Now we are going to install iftop but it complains about some of the libraries not being the correct version. I have not problems with the versions of the library installed above. So we just need to tell it to not stop the install on the version error.
# ipkg -force-depends install iftop
Ignore the errors that say it depends on libraries not install.
Note: iftop needs to be run at the root user.
You should now be able to run iftop from the command prompt. To look at the traffic on the bridge interface where most of the action is we will specify the interface on the command line with the -i option. 
Enter the following command.
# iftop -i br0

Your terminal screen should now be filled with the iftop information.

Nenhum comentário: