[HowTo] Part One - WL-500g Premium
What is it for?
This is a little "HowTo" for new Users of the Asus WL-500g Premium. It's a synopsis of my own experiences in setting up this box with Oleg's firmware "WL500gp-1.9.2.7-7f-pre4.trx". Thanks to Oleg fort his great work and thanks to all users of this forum, because almost every information I gathered comes from this site here (including the postings from macsat).
Comment: I tried to record every step of setting up the box, so I hope the amount of typos and principal faults is finite. And please be forbear with my grammar and orthography - English is not my native language..
In general: Any corrections, comments, improvements or suggestions are welcome!
2nd comment: principally you have to save every changes on flash fliesystem before you reboot with
Code:
flashfs save && flashfs commit && flashfs enable && reboot
but you can execute more than one of this sections and commit changes to flash at the end, unlike I write you have to flash.
To get access
First of all you've got to get access to your box. Therefore I use Putty, you can get it here: http://www.chiark.greenend.org.uk/~s.../download.html
If you didn't disabled telnet on the Asus-configuration site, you can access your box by opening a telnet-session with IP 192.168.1.1, Port 23, username "admin" and password "admin" (if you haven't changes yet, but you should).
Now you are connected to your box. You can try some commands to play a bit around: top, ps, df, free...
Install ssh-deamon
So, you have access, but with telnet this connection is not encrypted, so we will establish a ssh-connection. Therefore we need to install dropbear.
Create the dropbear-directory:
Code:
mkdir -p /usr/local/etc/dropbear
Generate dropbear-keys; it may take a few seconds:
Code:
dropbearkey -t dss -f /usr/local/etc/dropbear/dropbear_dss_host_key
dropbearkey -t rsa -f /usr/local/etc/dropbear/dropbear_rsa_host_key
Create the script-directory:
Code:
mkdir -p /usr/local/sbin/
Create the post-boot script-file
Code:
echo "#!/bin/sh" >> /usr/local/sbin/post-boot
Mark post-boot-file as executable:
Code:
chmod +x /usr/local/sbin/post-boot
Start dropbear in post-boot-script:
Code:
echo "dropbear" >> /usr/local/sbin/post-boot
You can start dropbear manually to try it out, but we have to reboot anyway:
Save changes in flash and reboot:
Code:
flashfs save && flashfs commit && flashfs enable && reboot
Extend RAM to 32MB
After flashing Oleg's FW on your box, it has by default 16MB RAM, but on the PCB are 32MB. By changing some NVRAM variables you can make the hole 32MB RAM accessable.
Attention! This just works with Premium boxes! Use this section on your own risk! It can damage your box! You shouldn't change the nvram variables with a Premium V2!!!
Code:
nvram set sdram_init=0x0009
nvram set sdram_ncdl=0
nvram commit
reboot
You can check the success by typing
Prepare USB-HDD
If you want to connect a USB-HDD to you box and make it accessible by network you have to partition your HDD and create a linux-accassible filesystem (ext3). For that matter we can create a swap-partition.
Î made the decision to create one big primary partition for data and one little partition at the end of the disk for swap.
Run the partition program by typing
Code:
fdisk /dev/discs/disc0/disc
Fdisk is self-explaining, type m to view the help-page. When you are finished, don't forget to save changes with the w-command before you exit fdisk.
After partition your disk, it's time to create filesystems
Code:
mke2fs -j /dev/discs/disc0/part1
mkswap /dev/discs/disc0/part2
We already created the post-boot scriptfile, now we can create several others too.
Code:
touch /usr/local/sbin/post-firewall
touch /usr/local/sbin/post-mount
touch /usr/local/sbin/pre-shutdown
chmod +x /usr/local/sbin/*
Netx we will modify the post-boot-script with the vi-editor. I wouldn't say it's self-explaining ;) but with a few commands you can use it. With "i" you get into editor-modus, with [ESC] you leave it. With ":wq!" you quit the editor by saving your file. For further information about vi visit http://lug.boulder.co.us/docs/vi_vim_howto.html
Code:
vi /usr/local/sbin/post-boot
Add the following lines to post-boot file:
Code:
#Wait for /opt to mount
mount /dev/discs/disc0/part1 /opt
i=0
while [ $i -le 30 ]
do
if [ -d /opt/etc ]
then
break
fi
sleep 1
i=`expr $i + 1`
done
# Activate swap
swapon /dev/discs/disc0/part2
# Run all active services - active means starts with S
/opt/etc/init.d/rc.unslung
Save changes in flash and reboot.
Code:
flashfs save && flashfs commit && flashfs enable && reboot
Initiate ipkg and install nano, screen, midnight commander
With ipkg there exists a package-system which enables you to easily install additional software-packages. Available packages und information about them you can find here: http://ipkg.nslu2-linux.org/feeds/unslung/wl500g/, http://ipkgfind.nslu2-linux.org/
So, make the necessary dirs and install and update ipkg:
Code:
mkdir /opt/tmp
mkdir /opt/tmp/ipkg
ipkg.sh update
ipkg.sh install ipkg
ipkg update
Now you are able install useful software, for examle nano, a nice, easy to use editor:
Install the terminal-multiplexer screen, a nice tool to handle several terminal-sessions:
Code:
ipkg install screen
Some useful commands for screen are:
Code:
C-a c create
C-a n next
C-a p previous
C-a # #=number of screen beginning with 0
C-a A give a name
C-a " list
C-a K kill
C-a d detatch
screen -r reattach
C-a S split horizontally
C-a X kill 2nd region
In which e.g. "C-a" means to press [ctrl] and [a] at the same time. For further information see: http://www.slac.stanford.edu/comp/unix/package/epics/extensions/iocConsole/screen.1.html
Install midnight commander, THE file-browser:
Midnight commander won't rum without a few lines in the post-boot script:
Code:
nano /usr/local/sbin/post-boot
So add to post-boot-file:
Code:
#to let midnight commander run on terminals, make alias for colored mc
echo "export TERMINFO=/opt/share/terminfo">>/etc/profile
echo "alias mc=\"mc -c\"">>/etc/profile
Install cron, a daemon to run scripts by scheduler:
With cron it is possible to let script-files periodically run, accordingly to its directory in which it is saved.
Code:
mkdir /opt/etc/cron.5mins
mkdir /opt/etc/cron.hourly
mkdir /opt/etc/cron.daily
mkdir /opt/etc/cron.weekly
mkdir /opt/etc/cron.monthly
Now you have to edit the crontab-file:
Code:
nano /opt/etc/crontab
and add the following lines:
Code:
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin
MAILTO=""
HOME=/
# ---------- ---------- Default is Empty ---------- ---------- #
# Syntax for lines is : minute hour day month dayofweek command #
*/5 * * * * admin run-parts /opt/etc/cron.5mins
0 * * * * admin run-parts /opt/etc/cron.hourly
0 0 * * * admin run-parts /opt/etc/cron.daily
0 0 * * 0 admin run-parts /opt/etc/cron.weekly
0 0 1 * * admin run-parts /opt/etc/cron.monthly
It's just an example. To understand how cron works, search for a cron-howto. I didn't used it copious, but I think it works (note: you need cron for the torrent-package). As you can see in the run-parts-script, I have this from macsat, but I modified the crontab-file.
So, we have to create the run-parts-script:
Code:
nano /opt/bin/run-parts
Fill it with the following lines:
Code:
#!/bin/sh
#
# runparts.sh by macsat@macsat.com
# intended for use with cron
#
# based on rc.unslung by unslung guys :-)
#
if [ -z "$1" ]
then
echo "Usage : $0 "
fi
RUNDIR=$1"/*"
for i in $RUNDIR ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done
And make the script executable:
Code:
chmod +x /opt/bin/run-parts
Save changes in flash and reboot:
Code:
flashfs save && flashfs commit && flashfs enable && reboot
[edit@20060725] typos..
[edit@20080827] nvram variables with Premium V2
WL-500g Premium Howto Part Two
Samba
So, you have a HDD connected to your box, now you want to access this disk over network connection. For this we need to configure the samba-daemon.
Create samba-directory:
Code:
mkdir /opt/etc/samba
Create samba-config-file with nano or vi:
Code:
nano /opt/etc/samba/smb.conf
Content of /opt/etc/samba/smb.conf:
Code:
[global]
workgroup = YOURWORKGROUPNAME
guest account = nobody
security = share
browseable = yes
guest ok = yes
guest only = no
log level = 1
max log size = 100
encrypt passwords = no
dns proxy = no
[smbshare]
path=/opt/share
writeable = yes
browseable = yes
force user = admin
[otherdir]
path=/opt/share/otherdir
writeable = yes
browseable = yes
force user = admin
This is just an example, too. It makes the "share"-directory accessible over network under the name "smbshare" and its subdir "otherdir" under the name "otherdir". You can modify that like you want. Under Windows you can connect to this dirs with \\192.168.1.1\smbshare and \\192.168.1.1\otherdir.
Create samba-Init-file:
Code:
nano /opt/etc/init.d/S97Samba
Content of /opt/etc/init.d/S97Samba:
Code:
#!/bin/sh
/usr/sbin/smbd -D -l /opt/var/log/smbd.log -s /opt/etc/samba/smb.conf
/usr/sbin/nmbd -D -n myasus -o -l /tmp -s /opt/etc/samba/smb.conf
Mark init-file as executable:
Code:
chmod 755 /opt/etc/init.d/S97Samba
Save changes in flash and reboot:
Code:
flashfs save && flashfs commit && flashfs enable && reboot
Install (c)torrent
There are two ipkg-packages, which make it possible to download files over bittorrent-protocol with your box. The downloaded files are stored on USB-HDD. This download-solution is not compatible with the Asus download master. But it works very well, I never used Asus dm at all. To control and supervise the downloads oleo wrote a cgi-script, which enables you to control your downloads with browser/webinterface. Thanks to oleo.
Code:
ipkg install ctorrent
ipkg install torrent
The following directories are necessary:
Code:
mkdir /opt/share/torrent
mkdir /opt/share/torrent/source
mkdir /opt/share/torrent/work
mkdir /opt/share/torrent/target
To get the cgi-script run you have to edit the httpd configuration-file:
Code:
nano /usr/local/root/httpd.conf
Content of /usr/local/root/httpd.conf
Code:
A:*
/cgi-bin:admin:admin
.au:audio/basic
.asp:text/html
You have to start the http daemon in one of the start-scripts:
Code:
nano /usr/local/sbin/post-mount
Add following line to /usr/local/sbin/post-mount
Code:
#!/bin/sh
/usr/sbin/busybox_httpd -p 8008 -h /opt/share/www
Now you can edit the torrent configuration file:
Code:
nano /opt/etc/torrent.conf
Mine looks like this:
Code:
##########
# Configuration
# NOTE: no spaces around the = sign
# the config will be sourced (eg. . torrent.conf)
SOURCE=/opt/share/torrent/source
WORK=/opt/share/torrent/work
TARGET=/opt/share/torrent/target
MAILTO=
MAILFROM=
# default MAILER is mini_sendmail
#MAILOPT="-sblackhole.dyndns.org -f"
USER=admin
GROUP=root
DATE_FORMAT="%d %h %H:%M"
# btget port range environment
BTLIB_MINPORT=52846
export BTLIB_MINPORT
BTLIB_MAXPORT=52846
export BTLIB_MAXPORT
#time between logs
LOG_TIME=59
# Seed torrent after completition (YES or NO)
AUTOSEED="YES"
#Colors for command line. # comment out if not needed
GREEN="\033[32;1m"
#NC="\033[0m"
#BACK_UP="\033[1K\033[0G"
NORMAL="\033[0m"
WARN="\033[33;1m"
BAD="\033[31;1m"
BOLD="\033[1m"
GOOD="\033[32;1m"
Now you can put a torrent-file into the source-dir and control it with the cgi-script http://192.168.1.1:8008/cgi-bin/torrent.cgi. That's it.
Install nload
A nice tool to watch the traffic on the network interfaces of the box is nload:
You can use it for example like this:
Code:
nload -t 200 -s 7 -i 2048 -o 256 -u H eth1
-t: time until refresh in ms
-s: smoothness [1-9], 1 means average over litte, 9 over long time
-i: sets scale for incoming traffic, in kBit/s
-o: sets scale for outgoing traffic, in kBit/s
-u: sets units, see helppage -h for more details
In order to make this command more easier to use, you can create an alias in /usr/local/sbin/post-boot:
Code:
nano /usr/local/sbin/post-boot
Add the following line to post-boot file
Code:
echo "alias nld=\"nload -t 200 -s 7 -i 2048 -o 256 -u H eth1\"">>/etc/profile
The Wondershaper-issue
I must admit, that's one thing, that doesn't work well, yet. Wondershaper is a script which provides QoS, but I can't get it run very well.
I tried to start the script with:
Code:
/init/wshaper start "eth1" 1990 190 " " " " "54321" "54321"
But except of some experiments I don't use it, cause it don't work very well for me. For own experiments use nload to watch effects of wshaper.
In my opinion thy syntax is quite complicated. For further information read the following:
- http://wiki.wl500g.info/index.php/PackageWondershaper
- Wondershaper QoS discussion on AsusForum
- http://www.docum.org/docum.org/docs/BB/BB.php
- http://lartc.org/lartc.html
That's it. Preliminary. I hope it helped you a bit. This here are all steps I've done on my box and it's running since a week or two without any problem (except wshaper)...
As I wrote above: Any corrections, comments, improvements or suggestions are welcome! You can help to correct and complete this.
[edit@20060728]: typos
[edit@20060822-Styno]: typo
Also useable for the wl-500gx?
Is your tutorial also useable for the wl-500gx? i have to set one up tomorrow.
Is the memeoty trick also possible?
Thanks
elbling