Asus RT-N16: how to set up ipkg and additional software on router

Update: I am not using Asus firmware anymore, it is very unstable and buggy, so if I write in my article below “stable” read it as “unstable” πŸ™‚

Note: In this post I am talking about installing ipkg on the native firmware from Asus version 1.0.1.2. With dd-wrt, oleg’s firmware there are no problems to install ipkg, just follow the instructions that are posted on their sites.

After trying different firmware, I have decided to stay with Asus firmware 1.0.1.2. The reason for this is one – 100% support for multi functional USB devices (MFD) + good stability of 1.0.1.2. With a powerful enough hardware you may wish to install some useful software on it and here we have several options …

– You can compile packages using the mips toolchain which of course is very interesting, but turns into a loss of time if you just need put a couple of services on the router …

– You can install on the router the ipkg – a package manager similar to apt-get in debian, or yum in fedora … ipkg can install huge number of services on the router, and we just can’t skip this possibility!

What are the other benefits of ipkg? In addition to the huge number of ready-to-install packages ipkg also also takes care of their dependencies, so there will be no need to figure out why, for example, nano will not start and requires a libcurl, or something like that …

With dd-wrt or oleg’s firmware ipkg is already installed, but in our case we will have to suffer a bit, because information on how to install ipkg is hard to collect from multiple places in Internet, and errors sometimes are bizarre, even google can’t help. But as Comrade Lenin said, “patience and hard work wins” πŸ™‚

So, let’s start. Following is required to install ipkg:

1. USB drive, formatted in ext3. You will loose all your data after format!

2. Access to the router via telnet

I recommend regular USB stick because the external disk may need power supply (I read that sometimes RT-N16 can not feed the external USB drive). It has to be formatted in ext3. FAT or NTFS is not suitable. Google on how to format USB driver in ext3.

You must allow access to the router via telnet. Go to the web interface of the router in the section Advanced-Lan-LanIP and check telnetd:

Click Apply and try to connect to router via telnet. You can use putty for this. Here is how it looks like:

Now insert into router a formated USB stick and check whether it is visible:

# cd /tmp/harddisk

# ls

part0

In my case the USB drive is seen as part0, but in your case it can be part1. We need to mount it in /opt. Why exactly /opt? The reason for this is the way ipkg works. It stores all packages and configuration files in /opt.

First, do unmount the drive

umount /tmp/harddisk/part0/

Now mount it to /opt

mount /tmp/harddisk/part0 /opt

Now you need to download ipkg on router, create a folder /opt/etc with a configuration file ipkg.conf, continue to create some more files, install uclibc-opt, add ipkg to $PATH and everything will work πŸ™‚ In order to automate this I created a shell script which runs and make this to work. The script has to be called from /opt. Let’s do it:

cd /opt

wget http://rt-n16.googlecode.com/files/ipkg_rt_n16.sh

chmod +x ipkg_rt_n16.sh

sh ./ipkg_rt_n16.sh

After you run this, the output will be something like this:

# sh ./ipkg_rt_n16.sh

=============================================================================

Shell script to set up ipkg on Asus RT-N16

Written by Volodymyr M. Shcherbyna, volodymyr@shcherbyna.com

Comments, questions? Post them to http://www.shcherbyna.com/?cat=24&lang=en

=============================================================================

Step 1: building directory structure …

Step 2: making folders writable …

Step 3: downloading config file for ipkg …

Connecting to rt-n16.googlecode.com (72.14.221.82:80)

ipkg.conf 100% |********************************************************************************************************************************| 156 –:–:– ETA

Step 4: downloading and configuring ipkg …

Connecting to rt-n16.googlecode.com (72.14.221.82:80)

ipkg 100% |********************************************************************************************************************************| 180k –:–:– ETA

Step 5: probing ipkg by issuing update…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/Packages.gz

Inflating http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/Packages.gz

Updated list of available packages in /opt/lib/ipkg/lists/optware

Downloading http://wl500g.googlecode.com/svn/ipkg/optware/Packages.gz

Inflating http://wl500g.googlecode.com/svn/ipkg/optware/Packages.gz

Updated list of available packages in /opt/lib/ipkg/lists/wl500g-optware

Successfully terminated.

Installing uclibc-opt (0.9.28-13) to /opt/…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/uclibc-opt_0.9.28-13_mipsel.ipk

package uclibc-opt suggests installing ipkg-opt

Configuring uclibc-opt

Updating /opt/etc/ld.so.cache

Successfully terminated.

Step 6: setting ipkg to PATH variable …

Step 7: everything done, trying to update

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/Packages.gz

Inflating http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/Packages.gz

Updated list of available packages in /opt/lib/ipkg/lists/optware

Downloading http://wl500g.googlecode.com/svn/ipkg/optware/Packages.gz

Inflating http://wl500g.googlecode.com/svn/ipkg/optware/Packages.gz

Updated list of available packages in /opt/lib/ipkg/lists/wl500g-optware

Successfully terminated.

That’s it! Now we need to add ipkg into $PATH, so that we would not need to call it /opt/bin/ipkg but just ipkg:

export PATH=$PATH:/opt/bin:/opt/sbin

Now we can try to install ssh server on router:

# ipkg install dropbear

Installing dropbear (0.52-5) to /opt/…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/dropbear_0.52-5_mipsel.ipk

Installing psmisc (21.4-1) to /opt/…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/psmisc_21.4-1_mipsel.ipk

Installing ncurses (5.7-1) to /opt/…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/ncurses_5.7-1_mipsel.ipk

Configuring dropbear

Will output 1024 bit rsa secret key to ‘/opt/etc/dropbear/dropbear_rsa_host_key’

Generating key, this may take a while…

Public key portion is:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgnHrYkGZhdoywaH7l0FpiCdKHG//oPXy1VeNk7mN/5TjrNaf3m0F7QAIRI1LuoRaVfYNxcz47Y39YpxTc4894WZfq2AYWb8pxFoF7h96E4WEtDiAQ1Sj6IbDgAvJ35ymGYxPIhF2RV30Jq/L6UnvKdcmRyCQxtSnBkx5lO9v4EhuuUs= admin@RT-E0CB4E87B123

Fingerprint: md5 a9:d1:04:1a:57:c4:54:bc:8c:c1:05:78:c4:d7:3d:48

Will output 1024 bit dss secret key to ‘/opt/etc/dropbear/dropbear_dss_host_key’

Generating key, this may take a while…

Public key portion is:

ssh-dss AAAAB3NzaC1kc3MAAACBAKbc+V1lKJgHOQ2TQkbOmF/KzSEu6bq6SKzlQU+bq+GR8GLueBbCz09H9gkK1UijRDoEJBEtNHZerOx+HThiCjGr0Ej+0hWFFJ0zM2/G/MrXMjRX97+mZN/TB3vWXT+IcL7VO9btqoHPy3talXTZ9M1GIM+Lcsbdbq47jhQW1p33AAAAFQD5B+GhJHE6l8Do9W0saBn3nySAZwAAAIBhq9N2U3f8OPU0K0i+PwDARd4CQ3WxzJ5lAfZenZvXRgfu0A6Po72opszoKxz3AN85IDwVBVjmdAkY25UmYztI4oca/yToZ3IqhdRNU4yXW82oimBzdML2DB0udJfJAcur9G0XP7Lw7TyFl8a1X3p9UBLLaA8WXOoxGbrM1AOItAAAAIAytoysFr40uPqwhHvSRR4JSo6Kz8dHvB2nsRnOlwXoQTB9rIBqe+OoDPELlN3jGHikQpiLj23275Kyw6xic4PMD31vArMlZ9vjrtBTaFSDPn0G6w678ZV2kftBUuj2cUBZD2VjlScEzNwbfnY8TEWSjZbL+mm6w1BO4Uj3rpRW8A== admin@RT-E0CB4E87B123

Fingerprint: md5 5c:52:f4:91:57:6f:02:c6:27:85:7b:1f:59:61:08:a3

mkdir: cannot create directory ‘/root’: Read-only file system

/opt/etc/init.d/S51dropbear: line 11: pidof: not found

Configuring ncurses

Configuring psmisc

Successfully terminated.

And some text editor, vim or nano … I prefer vim:

# ipkg install vim

Installing vim (7.2-2) to /opt/…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/vim_7.2-2_mipsel.ipk

Configuring vim

Successfully terminated.

You can test vim by typing vim in console. You can try to connect to your router via ssh, it should work. If you want to see how many packages are avialable via ipkg visit these urls: http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable and http://wl500g.googlecode.com/svn/ipkg/optware.

Have fun! πŸ™‚

Update: I am not using Asus firmware anymore, it is very unstable and buggy, so if I write in my article below “stable” read it as “unstable” πŸ™‚

Note: In this post I am talking about installing ipkg on the native firmware from Asus version 1.0.1.2. With dd-wrt, oleg’s firmware there are no problems to install ipkg, just follow the instructions that are posted on their sites.

After trying different firmware, I have decided to stay with Asus firmware 1.0.1.2. The reason for this is one – 100% support for multi functional USB devices (MFD) + good stability of 1.0.1.2. With a powerful enough hardware you may wish to install some useful software on it and here we have several options …

– You can compile packages using the mips toolchain which of course is very interesting, but turns into a loss of time if you just need put a couple of services on the router …

– You can install on the router the ipkg – a package manager similar to apt-get in debian, or yum in fedora … ipkg can install huge number of services on the router, and we just can’t skip this possibility!

What are the other benefits of ipkg? In addition to the huge number of ready-to-install packages ipkg also also takes care of their dependencies, so there will be no need to figure out why, for example, nano will not start and requires a libcurl, or something like that …

With dd-wrt or oleg’s firmware ipkg is already installed, but in our case we will have to suffer a bit, because information on how to install ipkg is hard to collect from multiple places in Internet, and errors sometimes are bizarre, even google can’t help. But as Comrade Lenin said, “patience and hard work wins” πŸ™‚

So, let’s start. Following is required to install ipkg:

1. USB drive, formatted in ext3. You will loose all your data after format!

2. Access to the router via telnet

I recommend regular USB stick because the external disk may need power supply (I read that sometimes RT-N16 can not feed the external USB drive). It has to be formatted in ext3. FAT or NTFS is not suitable. Google on how to format USB driver in ext3.

You must allow access to the router via telnet. Go to the web interface of the router in the section Advanced-Lan-LanIP and check telnetd:

Click Apply and try to connect to router via telnet. You can use putty for this. Here is how it looks like:

Now insert into router a formated USB stick and check whether it is visible:

# cd /tmp/harddisk

# ls

part0

In my case the USB drive is seen as part0, but in your case it can be part1. We need to mount it in /opt. Why exactly /opt? The reason for this is the way ipkg works. It stores all packages and configuration files in /opt.

First, do unmount the drive

umount /tmp/harddisk/part0/

Now mount it to /opt

mount /tmp/harddisk/part0 /opt

Now you need to download ipkg on router, create a folder /opt/etc with a configuration file ipkg.conf, continue to create some more files, install uclibc-opt, add ipkg to $PATH and everything will work πŸ™‚ In order to automate this I created a shell script which runs and make this to work. The script has to be called from /opt. Let’s do it:

cd /opt

wget http://rt-n16.googlecode.com/files/ipkg_rt_n16.sh

chmod +x ipkg_rt_n16.sh

sh ./ipkg_rt_n16.sh

After you run this, the output will be something like this:

# sh ./ipkg_rt_n16.sh

=============================================================================

Shell script to set up ipkg on Asus RT-N16

Written by Volodymyr M. Shcherbyna, volodymyr@shcherbyna.com

Comments, questions? Post them to http://www.shcherbyna.com/?cat=24&lang=en

=============================================================================

Step 1: building directory structure …

Step 2: making folders writable …

Step 3: downloading config file for ipkg …

Connecting to rt-n16.googlecode.com (72.14.221.82:80)

ipkg.conf 100% |********************************************************************************************************************************| 156 –:–:– ETA

Step 4: downloading and configuring ipkg …

Connecting to rt-n16.googlecode.com (72.14.221.82:80)

ipkg 100% |********************************************************************************************************************************| 180k –:–:– ETA

Step 5: probing ipkg by issuing update…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/Packages.gz

Inflating http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/Packages.gz

Updated list of available packages in /opt/lib/ipkg/lists/optware

Downloading http://wl500g.googlecode.com/svn/ipkg/optware/Packages.gz

Inflating http://wl500g.googlecode.com/svn/ipkg/optware/Packages.gz

Updated list of available packages in /opt/lib/ipkg/lists/wl500g-optware

Successfully terminated.

Installing uclibc-opt (0.9.28-13) to /opt/…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/uclibc-opt_0.9.28-13_mipsel.ipk

package uclibc-opt suggests installing ipkg-opt

Configuring uclibc-opt

Updating /opt/etc/ld.so.cache

Successfully terminated.

Step 6: setting ipkg to PATH variable …

Step 7: everything done, trying to update

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/Packages.gz

Inflating http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/Packages.gz

Updated list of available packages in /opt/lib/ipkg/lists/optware

Downloading http://wl500g.googlecode.com/svn/ipkg/optware/Packages.gz

Inflating http://wl500g.googlecode.com/svn/ipkg/optware/Packages.gz

Updated list of available packages in /opt/lib/ipkg/lists/wl500g-optware

Successfully terminated.

That’s it! Now we need to add ipkg into $PATH, so that we would not need to call it /opt/bin/ipkg but just ipkg:

export PATH=$PATH:/opt/bin:/opt/sbin

Now we can try to install ssh server on router:

# ipkg install dropbear

Installing dropbear (0.52-5) to /opt/…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/dropbear_0.52-5_mipsel.ipk

Installing psmisc (21.4-1) to /opt/…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/psmisc_21.4-1_mipsel.ipk

Installing ncurses (5.7-1) to /opt/…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/ncurses_5.7-1_mipsel.ipk

Configuring dropbear

Will output 1024 bit rsa secret key to ‘/opt/etc/dropbear/dropbear_rsa_host_key’

Generating key, this may take a while…

Public key portion is:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgnHrYkGZhdoywaH7l0FpiCdKHG//oPXy1VeNk7mN/5TjrNaf3m0F7QAIRI1LuoRaVfYNxcz47Y39YpxTc4894WZfq2AYWb8pxFoF7h96E4WEtDiAQ1Sj6IbDgAvJ35ymGYxPIhF2RV30Jq/L6UnvKdcmRyCQxtSnBkx5lO9v4EhuuUs= admin@RT-E0CB4E87B123

Fingerprint: md5 a9:d1:04:1a:57:c4:54:bc:8c:c1:05:78:c4:d7:3d:48

Will output 1024 bit dss secret key to ‘/opt/etc/dropbear/dropbear_dss_host_key’

Generating key, this may take a while…

Public key portion is:

ssh-dss AAAAB3NzaC1kc3MAAACBAKbc+V1lKJgHOQ2TQkbOmF/KzSEu6bq6SKzlQU+bq+GR8GLueBbCz09H9gkK1UijRDoEJBEtNHZerOx+HThiCjGr0Ej+0hWFFJ0zM2/G/MrXMjRX97+mZN/TB3vWXT+IcL7VO9btqoHPy3talXTZ9M1GIM+Lcsbdbq47jhQW1p33AAAAFQD5B+GhJHE6l8Do9W0saBn3nySAZwAAAIBhq9N2U3f8OPU0K0i+PwDARd4CQ3WxzJ5lAfZenZvXRgfu0A6Po72opszoKxz3AN85IDwVBVjmdAkY25UmYztI4oca/yToZ3IqhdRNU4yXW82oimBzdML2DB0udJfJAcur9G0XP7Lw7TyFl8a1X3p9UBLLaA8WXOoxGbrM1AOItAAAAIAytoysFr40uPqwhHvSRR4JSo6Kz8dHvB2nsRnOlwXoQTB9rIBqe+OoDPELlN3jGHikQpiLj23275Kyw6xic4PMD31vArMlZ9vjrtBTaFSDPn0G6w678ZV2kftBUuj2cUBZD2VjlScEzNwbfnY8TEWSjZbL+mm6w1BO4Uj3rpRW8A== admin@RT-E0CB4E87B123

Fingerprint: md5 5c:52:f4:91:57:6f:02:c6:27:85:7b:1f:59:61:08:a3

mkdir: cannot create directory ‘/root’: Read-only file system

/opt/etc/init.d/S51dropbear: line 11: pidof: not found

Configuring ncurses

Configuring psmisc

Successfully terminated.

And some text editor, vim or nano … I prefer vim:

# ipkg install vim

Installing vim (7.2-2) to /opt/…

Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/vim_7.2-2_mipsel.ipk

Configuring vim

Successfully terminated.

You can test vim by typing vim in console. You can try to connect to your router via ssh, it should work. If you want to see how many packages are avialable via ipkg visit these urls: http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable and http://wl500g.googlecode.com/svn/ipkg/optware.

Have fun! πŸ™‚

27,541 views

19 Comments

  1. Teros,

    If DSL-N13 has the same version of linux and hardware it may work as well. The ipkg repository I use in this article is from Asus WL500G router, this is even not an N series router but it is compatible! Unfortunately I don’t have DSL-N13 to try, but I am pretty sure that after you mount USB into /opt and run my script it may work. Try, and give me the output here, I will try to help.

  2. Andrew,

    Yes, unfortunately after reboot you will have to re-run the daemons again, and add /opt/bin and /opt/sbin into $PATH. However, I am working on finding solution for this πŸ™‚ It bothers me as well …

    Asus has released today a new firmware for RT-N16: ftp://ftp.asus.com.tw/pub/ASUS/wireless/RT-N16/ (version 1.0.1.4) and I am downloading already the sources. The channel is really slow. Will see if ipkg can be set up on 1.0.1.4 and what can be done with boot scripts.

  3. I can confirm that ipkg can perfectly run on 1.0.1.4 as it runs perfectly for 1.0.1.2 and 1.0.1.3.

    2 Andrew, yes you can run it via system page, but if you do that from WAN, you can do this only via HTTP, not via HTTPs, which is insecure. Well, maybe I can write a windows application will will use winhttp or wininet to logon and run the command automatically – so that things will be done fast and automated.

    But πŸ™‚ I still play with nvram and I hope I will work out the auto execute scripts on system boot event …

  4. Hi,

    I installed RT-N16-1.9.2.7-rtn-r3121.trx on my RT-N16. In this blog you mentioned that the ipkg is already installed with oleg’s FW, but I don’t seem to locate it. Could you guide me where is it located or do I need to install it.

    Thanks,

    DPal.

  5. I’ve followed similar steps to install transmission on my router with the latest russian firmware (which asus states to be optware compatible). You just need to mount /opt and install ipkg-opt with ipkg.sh included, and install transmission. This firmware also allows mount and unmount custom scripts to be executed (used them to mount the /opt partition automatically, so transmission starts every time I plug in my external hard drive).

    But as always, my setup had a problem: every time transmission-daemon starts a download, the router freezes for a while (hdd led blinks with big intervals) and then continues. With larger files, like 7gb, it simply freezes for hours. Looks like it’s generating a temporary file and this operation consumes every resource on router. I can’t figure it out, since telnetd stops responding too.

    Shcherbyna, do you have any clues?

    You’ve helped me a lot with my old TomatoUSB setup and I really appreciate that but I fell back to asus firmware because the printing/scanning support is definitely better. Ppl from tomatousb should grab this part of it!

    Thanks

  6. Some additional information:

    my external hdd is partitioned this way
    Partition 0 – 480gb ntfs (includes transmission-daemon directories like completed, incomplete and watch-dir)
    Partition 1 – 1gb ext3 (with optwares)

    partition 0 is automatically mounted and partition 1 is mounted with “mount /dev/sda2 /opt”.

    The same configuration works fine under tomatousb firmware.

    Thanks again

  7. After playing with a few settings on transmission’s configuration file settings.json, I managed to get it working with just a little freezing and no crashes at all. Web interface isn’t so responsive and have some associated delays for pausing and resuming AFAIK.

    Here’s what I changed:
    “preallocation”: 2,
    “prefetch-enabled”: 0

    Basically, disabled prefetch and changed preallocation type (I don’t know which types are available, but found the value 2 elsewhere). Both values were set to 1.

    After all, it seems the problem is related to writing on the ntfs partition. Still a work in progress. Gonna try to improve it.

  8. Hi Volodymyr, thank you for the interesting tutorial. I have just bought RT-N16 and it is very good. I am running Asus Firmware 3.x which is the new interface and I like it very much.

    Do you know if there is a way for me to add only Remote WOL functionality to this firmware without leaving a USB drive plugged in all the time? At the moment I don’t want to upgrade to third party firmware because stock does everything I want so far except WOL!

    I guess I would be looking to install ipkg to the internal memory, although I am very new to this and not sure where to start. I have only a little Linux experience (Ubuntu…) and some very small C++.

Leave a Reply

Your email address will not be published. Required fields are marked *

Identify yourself * Time limit is exhausted. Please reload CAPTCHA.