OpenWrt Forum Archive

Topic: Setting up a wl-500gP with Kamikaze (AP-mode, samba, DHCP-Server)

The content of this topic has been archived between 26 Mar 2018 and 22 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Network configuration ASUS WL-500gP with Kamikaze 7.06
-----------------------------------------------------------------------------------------------

I looked for a How-To for Kamikaze, but there are only pieces out there
when i bought my router three days ago.
I hope, this How-To will help you.
Please give me Feedback, or correct me, if i made a mistake!

There is a second howto too, for setting up ASUS WL-500gP in sta-mode (routed client mode) with wpa-encryption
http://forum.openwrt.org/viewtopic.php?id=11502
But first, do the basics wink
Okay, lets start:

0. Basics
I used this image for flashing my router:
http://myhost.webhop.net/openwrt/openwr … s-xwrt.trx
The webif-package is already installed. If you have questions to webif see: http://x-wrt.org/
You can access via browser to: http://192.168.1.1 after setting a password (type passwd) per telnet on 192.168.1.1
But, you won't need it, because you have this howto wink  and be carefull if you chance setting, i don't know which files are the webif² is editing.

Basic-Basics like how to work with vi or something like this must be known, otherwise you shouldn't do this howto!

1. Boot from USB-Stick
This is optional, it's nice, because you have a full-functionally fail-save mode on your rom.
Do this, if your network settings are correct and you have ssh-access to the router.
Everytime you restart the router without USB-Stick, you'll get the configuration
you've done before copying the files on the usb-stick (usb2)!
if you're using usb1 have a look at
http://wiki.openwrt.org/UsbStorageHowto … =%28usb%29
First you have format your usb-stick and write a filesystem on it:
We need the following packages

ipkg update
ipkg install kmod-fs-ext2 kmod-fs-ext3 fdisk e2fsprogs kmod-usb2 kmod-usb-storage

Then put your stick into the router, and format it, (with this, you'll create one partition)

root@SR-71:/mnt# fdisk /dev/scsi/host0/bus0/target0/lun0/disc

The number of cylinders for this disk is set to 60801.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

So, then you type

Command (m for help): d

fdisk asks you which partitions you want to delete, delete 1, nexttime 2, 3, 4... (if you have those partitions)
Then type

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-60801, default 1): #[enter]
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-60801, default 60801): #[enter]
Using default value 60801

Let's write that to the stick:

Command (m for help): w
Syncing discs...

So, now we have one partition on your stick, lets make a filesystem:

mke2fs -j /dev/scsi/host0/bus0/target0/lun0/part1

If there's an error like this:

Creating journal (4096 blocks): mke2fs: No such file or directory
        while trying to create journal

try this:

ln -s /proc/mounts /etc/mtab

But, normally everything goes right.
Now we are able to mount the stick: (in this example on /mnt)

mount -t ext3 -o rw /dev/scsi/host0/bus0/target0/lun0/part1 /mnt

Then we make a /tmp/root mount it to /rom and copiing the files (and at last unmount it and the stick)

mkdir /tmp/root
mount -o bind /rom /tmp/root
cp /tmp/root/* /mnt -a

umount /tmp/root
umount /mnt

Now your whole filesystem is copied on the stick.
We need to tell the image stored on the rom to boot from the usb-stick.
To do this it's necessary to delete your /sbin/init (it's linked to the busybox)

rm /sbin/init

and replace it with this:

#!/bin/sh

boot_dev="/dev/scsi/host0/bus0/target0/lun0/part1"

for module in usbcore ehci-hcd scsi_mod sd_mod usb-storage jbd ext3; do {
        insmod $module
}; done

sleep 2s
mount -o rw "$boot_dev" /mnt

[ -x /mnt/sbin/init ] && {
        . /bin/firstboot
        pivot /mnt /mnt
}
exec /bin/busybox init

This file must be executeable and reboot

chmod a+x /sbin/init && reboot

Now, you should boot from usb-stick!

2. Network basics
please, backup your /etc/config/network /etc/config/wireless, and your /etc/dnsmasq.conf
those backups will save your nerves

cp /etc/config/network /etc/config/network.bak
cp /etc/config/wireless /etc/config/wireless.bak
cp /etc/dnsmasq.conf /etc/dnsmasq.conf.bak

First a short Introduction.

http://members.chello.at/spelth/network.GIF

Setting up the IP,Netmask,Gateway and DNS of the Router (Bridge)

uci set network.lan.ipaddr="192.168.2.1"
uci set network.lan.netmask="255.255.255.0"
uci set network.lan.gateway="192.168.0.1"
uci set network.lan.dns="192.168.0.1"
uci commit && ifup -a

Now you should able to ping an address somewhere else.

3. DHCP
For Connected Clients we need a default gateway to 192.168.2.1, set also the dns to 192.168.2.1 (Bridge IP)
and at last an ip-address-pool:
I dicided for dhcp-clients: 192.168.2.2  - 192.168.2.20

This is my /etc/dnsmasq.conf

# filter what we send upstream
domain-needed
bogus-priv
filterwin2k
localise-queries

# allow /etc/hosts and dhcp lookups via *.lan
local=/lan/
domain=lan

expand-hosts
resolv-file=/tmp/resolv.conf.auto

dhcp-range=lan,192.168.2.2,192.168.2.20,255.255.255.0,24h
dhcp-option=lan,3,192.168.2.1
dhcp-option=lan,6,192.168.2.1

dhcp-authoritative

dhcp-leasefile=/tmp/dhcp.leases
except-interface=eth0

read-ethers

DHCP-server works, but not the ip-range... i get a wired-ip of 192.168.2.102 and a wireless-ip of 192.168.2.223
this is a little bit strange.
have a look at these lines:

local=/lan/ 
domain=lan

It is the name of your Interface in /etc/config/network
Edit if needed!

Next step: Turn on the

4. WIFI
Edit your /etc/config/wireless:

config wifi-device  wl0
        option type     broadcom
        option channel  1
# disable radio to prevent an open ap after reflashing:
        option disabled 0

config wifi-iface
        option device   wl0
        option network  lan
        option mode     ap
        option ssid     defcon
        option hidden   0
        option encryption psk
        option key      mykey123

wl0 is my wifi-interface
defcon is my ssid
with this option, wl0 will be bridged with lan

option network   lan

and this is our wpa-psk encryption

option encryption psk
option key    mykey123

To bring the AP on-air type

/sbin/wifi start

5. SAMBA
To turn on the Samba-Server we need:

ipkg install samba-common samba-server

But then samba wouldn't start, because it looks for your Router's name and IP.
So wee need to add a line to /etc/hosts
(this is my /etc/hosts: SR-71 is my Router's name)

127.0.0.1 localhost
192.168.2.1 SR-71

Then you should able to ping yourself with

root@SR-71:~# ping sr-71
PING SR-71 (192.168.2.1): 56 data bytes
64 bytes from 192.168.2.1: icmp_seq=0 ttl=64 time=0.7 ms
64 bytes from 192.168.2.1: icmp_seq=1 ttl=64 time=0.4 ms
64 bytes from 192.168.2.1: icmp_seq=2 ttl=64 time=0.4 ms
64 bytes from 192.168.2.1: icmp_seq=3 ttl=64 time=3.7 ms

--- SR-71 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.4/1.3/3.7 ms

If this was successful, you can edit the
/etc/samba/smb.conf
actually, your /tmp is shared.

And now, turn on SAMBA with

/etc/init.d/samba start

EDIT:
05.07.2007: Write the 0. Basics
05.07.2007: Write the 1. Boot from USB-Stick
06.07.2007: Replaced init script with script from mbm (post 4)
08.07.2007: Correct kmod-fs-ext2, kmod-fs-ext3
11.07.2007: Added the "w" to the fdisk-section
14.04.2008: Correct some grammar mistakes wink

(Last edited by spelth on 16 Apr 2008, 03:54)

Nice tutorial!
I will try it this weekend!
I will write a tutorial 2 about installing it from scratch.

BTW I see that you use a usb stick as swap.
I've read that swap is very bad for a flash drive. You should better add it on the usb disk.

What file did you use to flash your router? Because I read that there are a lot of problems of getting the wl 500 gp up with wlan.

I will edit the howto and post a link at the beginning.

I used a image from x-wrt.org, tried to use other images first, but they don't work at the beginning (especially networking)
When i started working with openwrt i don't know so much about networking on kamikaze and this image works without problems:

http://myhost.webhop.net/openwrt/openwr … s-xwrt.trx

But, notice: wlan is disabled by standard!

(Last edited by spelth on 5 Jul 2007, 16:12)

init script -

#!/bin/sh

boot_dev="/dev/scsi/host0/bus0/target0/lun0/part1"

for module in usbcore ehci-hcd scsi_mod sd_mod usb-storage jbd ext3; do {
        insmod $module
}; done

sleep 2s
mount -o rw "$boot_dev" /mnt

[ -x /mnt/sbin/init ] && {
        . /bin/firstboot
        pivot /mnt /mnt
}
exec /bin/busybox init

thanks for the script, i changed it!

Nice tutorial, could not get samba to work though.  I will just have to read more about samba.


One little code correction:
ipkg install kmod-ext2 kmod-ext3 > ipkg install kmod-fs-ext2 kmod-fs-ext3

Following your how to to write my own and my first remark is that the guide is excellent!
Just some minor faults:
1. Maybe add the w to the fdisk command else the partition isn't written to disk.

deChrLam wrote:

Nice tutorial, could not get samba to work though.  I will just have to read more about samba.


One little code correction:
ipkg install kmod-ext2 kmod-ext3 > ipkg install kmod-fs-ext2 kmod-fs-ext3

Same with a default openwrt installation which works I can't get samba to work.
The smbd is never launched.

BTW this is what I don't understand:

uci set network.lan.ipaddr="192.168.2.1"
uci set network.lan.netmask="255.255.255.0"
uci set network.lan.gateway="192.168.0.1"
uci set network.lan.dns="192.168.0.1"
uci commit && ifup -a

You set your lan to your wan address?

Samba: Did you add your hostname and ip-address to /etc/hosts ?

hm..i've forgotten to post my /etc/config/network, i think:

#### VLAN configuration
config switch eth0
        option vlan0    "1 2 3 4 5*"
        option vlan1    "0 5"


#### Loopback configuration
config interface loopback
        option ifname   "lo"
        option proto    static
        option ipaddr   127.0.0.1
        option netmask  255.0.0.0


#### LAN configuration
config interface lan
        option type     bridge
        option ifname   "eth0.0"
        option proto    static
        option ipaddr   192.168.2.1
        option netmask  255.255.255.0
        option gateway  192.168.0.1
        option dns      192.168.0.1


#### WAN configuration
config interface        wan
        option ifname   "eth0.1"
        option proto    dhcp

I got a little worried by the bridge, and this configuration succeeds.

[ -x /mnt/sbin/init ] && {
        . /bin/firstboot
        pivot /mnt /mnt
}
exec /bin/busybox init

What is pivot?  I know what "pivot_root" does, but "pivot" isn't part of my Kamikaze install.

[edit]
Ahh...I see that pivot is a function in /bin/firstboot.

(Last edited by brucebertrand on 14 Jul 2007, 00:59)

belrpr wrote:

BTW this is what I don't understand:

uci set network.lan.ipaddr="192.168.2.1"
...

You set your lan to your wan address?

Heck, aside from any address-related issues, I don't understand where this quote came from! I don't find any "uci set" commands anywhere in the /etc tree - someone please explain!

whbjr wrote:
belrpr wrote:

BTW this is what I don't understand:

uci set network.lan.ipaddr="192.168.2.1"
...

You set your lan to your wan address?

Heck, aside from any address-related issues, I don't understand where this quote came from! I don't find any "uci set" commands anywhere in the /etc tree - someone please explain!

I saw it wrong. It is another address smile

en usi set command is used to write config files.
If you don't see them then you propably using whiterussian where the command was nvram set

belrpr wrote:

en usi set command is used to write config files.
If you don't see them then you propably using whiterussian where the command was nvram set

I'm Linux-wise but Kamikaze-ignorant.  I've seen the "uci" commands in /etc/init.d/boot, but I thought it was a shell function (See /lib/config) - I didn't know it was a command-line program, and didn't realize that uci commands actually change the /etc/config files. roll

Thanks also to spelth for the pointer to documentation! (Which I'd seen, but I somehow overlooked the "uci" section!)

Hi
Great: but is their anyway of reverting back to "normal" boot.
What I mean is is the flash device and router are under the stairs for my test setup and I would like to restore the default init so on next boot the machine will boot from internal and not use flash
- without leaving my chair to find my box by removing flash ....

And another thing ...

If I have a working kama in internal memory, how could one do  a "test" upgrade on the code on the external memory ...

The simpliest thing to do is, put out your usb-stick during the boot...

2nd post:
Do you mean how to change something on the usb-stick, or something else?

Sometimes, it's hard to physically get to the machines I have :)

Solution is to use the test

[ -x /mnt/sbin/init ] && {
root@OpenWrt:/sbin# ls -la init
lrwxrwxrwx    1 root     root           14 Jan  1 00:23 init -> ../bin/busybox
root@OpenWrt:/sbin# rm init
root@OpenWrt:/sbin# reboot

Alternativly, one can make another "magic" file to test for as to if to boot flash or stick.

So the next problem is how to go to a test 7.07 on the stick and working 7.06 on flash which is what I meant in:
>>And another thing ...

>>If I have a working kama in internal memory, how could one do  a "test" upgrade on the code on the external memory ...

So reading on what to do if I have 7.07 on stick and a working 7.06 in flash.
If I can create 7.07 on stick, without touching the 7.06 in flash, I can then test 7.07 when the family is asleep and switch back to 7.06 so that they don't ring and say Internet isn't working when I'm at work....

http://downloads.openwrt.org/people/mbm/openwrt.html

The firmware itself follows the pattern:
[trx header][kernel][filesystem]

- what program/scripting can extract kernel and filesystem and put it on th stick ...

Reading http://forum.openwrt.org/viewtopic.php?id=11304

(Last edited by oxo on 27 Jul 2007, 23:33)

Hello everyone.
I'm new here.
I've a doubt: Is this configuration enough for ipkg to install the new packages on the usb storage?
How do I know I'm booting from the usb storage?

Best regards

Just ssh to your router and look at the output of mount.  If / is mounted on your USB drive, you're set.

so this:
root@AsusGP:/# mount
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro)
none on /dev type devfs (rw)
none on /proc type proc (rw)
none on /tmp type tmpfs (rw,nosuid,nodev)
none on /dev/pts type devpts (rw)
/dev/mtdblock/4 on /jffs type jffs2 (rw)
/jffs on / type mini_fo (rw)
/dev/scsi/host0/bus0/target0/lun0/part1 on /mnt/sea100 type ext3 (rw)
/dev/scsi/host0/bus0/target0/lun0/part5 on /mnt/sea200 type ext3 (rw)
/dev/scsi/host0/bus0/target0/lun0/part6 on /mnt/sea300 type ext3 (rw)
none on /proc/bus/usb type usbfs (rw)


says I'm not set?

yep...try adding:

/sbin/udevtrigger
echo /sbin/hotplug-call > /proc/sys/kernel/hotplug

to /sbin/init before you try to mount the USB drive.
You might also want to add a "sleep 10s" between the above and mount

Hi thanks for the input.
The problem was not really that.
It was that in the sbin init script:

pivot /mnt /mnt

I did not realise, at first, the correct order for the new and old root.
Anyway is this entirely correct?
Am I not setting up the root in the tmp dir?
That bit left me cofused...
Thanks in advance.