Router Tech 1.0

From Fab Lab wiki

Jump to: navigation, search

Contents

Introduction

In every FabFi link there are two endpoints, upstream (AP) and downstream (STA). The upstream endpoint functions nearly like an out-of-the-box wireless router, whereas the downstream endpoint requires reconfiguration of the router such that the wireless interface is bridged to the WAN interface instead of the LAN. In order to enable this reconfiguration, and enable some other useful options, the default router firmware must be replaced with something more flexible. We have chosen [OpenWRT], an open source, linux based, 3rd party router firmware (which uses a modified bourne shell, for those of you who plan to write scripts) to replace the default firmware. The following sections detail the downloading, installation, and configuration of this firmware for the Linksys WRT54GL.

Installing OpenWRT


OpenWRT supports a variety of routers, but we will be focsuing on the Linksys WRT54GL (because that's all we know anything about). No matter what router you use you must be ABSOLUTELY SURE that is is supported before installing OpenWRT, or there's no telling what could happen. NO TELLING!

Note: if you're using a WRT54GL, you can skip down to Installing OpenWRT on a WRT54GL

OpenWRT for non-WRT54GL users

Follow these instructions to get your router set up before joining us in the 54GL world for configuration

Determining if Your Router is Supported

http://nuwiki.openwrt.org/oldwiki/CompleteTableOfHardware contains a comprehensive hardware support list for wireless routers. Determine the Make, Model and Hardware Revision of the router. This information is usually located on a sticker underneath the router. Then, go to the link above and scroll down to the hardware support table. Find your router in the table according to the Make, Model and Hardware Revision. Once you locate it, scan all the way to the rightmost column in the row for your router. If that cell says "Supported", then your router will work. If it says anything else, go find a supported router. If your router is not in the list, go find a supported router.

Downloading and Installing OpenWRT Firmware

If your router is supported, clicking on the word "Supported" will bring you to a hardware specific page for your router. Somewhere on the page will likely be listed the name of a file ending in ".bin". There may not be a direct link to the file. If this is the case, search for the following in Google:

[filename.bin] site:download.openwrt.org

This will bring you to the correct page to download the file.

If the name of the .bin file is not listed, you will have to determine the chipset of your device (usually Atheros or Broadcom in one of a few different versions) and download the OpenWRT .bin for that chipset (look on the pages for devices with similar chipsets for the name of the binary).

Once you have the binary on your computer, go back to the hardware page for your router and follow the instructions in the "Installation" section to install the binary.

Installing OpenWRT on a WRT54GL

When you take your WRT54GL out of the box, it will be preloaded with a web-based admin GUI. This GUI's firmware upgrade feature will be used to install OpenWRT

Downloading OpenWRT

A copy of the currently deployed FabFi firmware binary is available [directly from us]. As of this posting it is identical to the OpenWRT 7.09 "kamikaze" release, which can be downloaded here:

http://downloads.openwrt.org/kamikaze/7.09/brcm-2.4/openwrt-wrt54g-2.4-squashfs.bin

If you are looking for the binary associated with a particular release, take a look at our [distribution page].

Save the binary to your local machine.

Updating your Router's Firmware to OpenWRT
  • Plug your PC or laptop into one of the four LAN ports on the WRT54G. If you have WiFi or a second ethernet port on your computer, disable it.
  • Go to http://192.168.1.1 in your browser
  • Enter default user name and password (<blank> / admin)
  • Go to 'Administration' tab
  • Go to 'Firmware Upgrade' subtab
  • Click 'Browse' and enter the .bin file you downloaded
  • Click upgrade. The Power LED on the WRT54G should start flashing and continue to do so until the firmware upgrade is complete.
  • Wait for router to reboot
  • Close browser

Configuring the Router

OpenWRT, being a linux based firmware, holds all of its configuration variables (that you care about) in plain text files, with the ones relevant to this application being located in

/etc/config

and

/etc/init.d

the files we explicitily change or add in our configuration are

/etc/config/wireless
/etc/config/network
/etc/config/system
/etc/passwd
/etc/init.d/firewall
/etc/init.d/custom-user-startup
/etc/crontabs/root
/etc/crontab (symbolic link, for convenience)
/etc/setrouter (copy of config script. Not necessary for operation)
/etc/checkwifi (script to check wifi status and fix if down)
/etc/wifi_logs (directory for checkwifi logs)

To edit these files, one must log on to the router using telnet or SSH (depending on whether or not you've set a password already).

If you want to understand exactly what we change, download all these files from your router before running the config script and compare them to the versions that exist after running it.

/etc/init.d/custom-user-startup

should not exist before the config script is run.

The FabFi Config Script

If you were an average person configuring an OpenWRT router, you would log into the the device with telnet or SSH and manually edit the files listed above with

vi 

you would also install software with

ipkg 

and set your password using

passwd

Savvy users might even use the [uci interface], for which you can find a reference [here], though there are some peculiarities it does not explain. (check out the source of our config script to see some of the common ones. We use uci to set all of our variables)

Because there is a significant amount of stuff to change, we have written a shell script that walks through the entire configuration step by step. It will prompt the user to name the link, set a password and download required software. Based on the link name provided, the script selects IP addresses using our Addressing Scheme. After completing the script for both an AP and a STA, the link is ready to deploy.

Your First-Ever Login

Once OpenWRT has been installed on your router you will no longer be able to connect to it with a web-based GUI. (unless you install one. It's a waste of space IMO.) Instead you will need to use telnet. For linux users, simply type:

telnet 192.168.1.1

in your terminal (you should already to be connected to the router through one of the LAN ports and the router should be powered on)

If you're a windows user, you can type a similar command at your command prompt, but because you'll need SSH for all of the following steps, you should download a telnet/SSH client now. We use PuTTY, which can be found here:

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Once you've downloaded PuTTY, select the telnet radio button in its login window and type the ip (192.168.1.1) into it's Host Name field.

Once you're telnetted in, you'll see the OpenWRT splash screen and a command prompt.

Downloading and Running the Config Script

  • Plug a network cable into the WAN (labeled 'Internet') port on your router that's connected to the internet
  • If you haven't already telnetted into your router do so as explained above.
  • Download the config script to your router following command
wget http://fabfi.fablab.af/download/setrouter -O /tmp/setrouter
  • run the script by typing
sh /tmp/setrouter

if you have trouble running the script type

chmod +x setrouter

and try running the script again

  • Follow the instructions in the script. It will ask you for the following:
    • if you need to download config files. If you have not manually placed fabfi_ALL.tar.gz in the /tmp directory, or run setrouter answering 'y' her since the last reboot you should answer 'y'.
    • Wireless Channel (must be the same for both STA and AP)
    • Distance between STA and AP in meters
    • WEP key (must be the same for STA and AP)
    • Number of pair (must be the same for AP and STA, should be unique within fabfi system)
      • Pair number determines class C IP address of the network
    • AP or STA (AP is upstream, STA is downstream. Each pair has 1 AP and one or more STAs)
    • STA number
      • Only for stations. This is 1 unless a pair has multiple stations and determines the class D section of the STA's upstream IP address)
  • The script will prompt you to enter a root password. You will need to use it to log in from now on, so don't forget it.
  • The script will then ask you if you would like to install optional software:
    • nmap: a program to search for computers connected to the router
      • This program is helpful for finding devices connected to your router with static IPs
      • If you plan on installing a lot of other software, skip it because it's big
    • tcpdump: a packet sniffer
      • Good for debugging firewall and routing problems

You're done!

WARNING: if you abort the script after you see the list of settings printed out but before you set a password, you will have to use ssh and the password cisco123 to log in the next time (see below for ssh commands). Everything else will work the same as above.

ADDITIONAL CONFIG NOTE: Our script adds a clone of the root user in case someone accidentally changes the root password and forgets it (it's a dirty hack, I know. We'll figure out a better solution at a later date). If you're creating your own system and don't want our username and password to let you into our system, just delete the 'fab' user in

/etc/passwd

Running the Script Offline

If you won't have access to the internet when configuring the router, you can run offline as long as setrouter and fabfi_ALL.tar.gz are both placed in

/tmp 

For a new install of OpenWRT you will need to set a root password with the

passwd 

command, then transfer the files using scp. On my Windows machine, I like to use WinSCP to transfer files.

Manual File Download

Don't like the config script? A tarball with everything you need for APs and STAs can be found at

http://fabfi.fablab.af/download/fabfi_ALL.tar.gz

place this file in

/tmp

and unzip it with this command (warning: will overwrite files in your etc directory)

tar -C /tmp -xzf <path to tarball>

you will then find tarballs for the APs and STAs in

/tmp/fabfi_configs

unzip the one you want with the command

tar -C / -xzf <path to tarball>

Note: if you don't use the config script, you will encounter a bug in the OpenWRT distribution where ipkg will not be able to find some packages. To fix this change the

src packages http://downloads.openwrt.org/kamikaze/packages/mipsel

line in

/etc/ipkg.conf

to

src packages http://downloads.openwrt.org/kamikaze/7.09/packages/mipsel

Disabling Logging

The current version of our distribution runs a wifi status check/repair/logging script. We recommend you use it because it increases system reliability, but if you want to turn it off comment this line:

*/3 * * * * sh /etc/checkwifi

in

/etc/crontabs/root

you can also directly edit the script in

/etc/checkwifi

The log folder is cleaned up daily by this line in the cron file

/59 23 * * * mv -f /etc/wifi_logs/today.log /etc/wifi_logs/`date +"%Y-%m-%d"`;cd /etc/wifi_logs;a=0; a_in...

Tweaks for Weak Signals

By default, OpenWRT STAs are configured to search for new APs when the signal dips below -60dB. If you only have one SSID configured the setting probably doesn't really matter, but just in case, you can change this setting in the

/etc/init.d/custom-user-startup

file by adding the line

wl roam_trigger -##

where ## is the dB level below which you want the router to roam. For our bikg link in Jalalabad, I have this set at -87dB because the noise floor is so low, and our signal strength is nominally in the mid -70s

Logging into your configured Router

Once you have set a password for your router, telnet will no longer be available. The next time you log in (and from now on) you must use SSH:

  • from upstream
ssh root@<external IP of router>
  • from downstream
ssh root@<LAN gateway IP of router>

For windows users, use PuTTY and select the SSH radio button.

Get the latest

Follow the play-by-play of new router stuff on the blog (filtered for Router Tech)


Wtgphoben 17:26, 24 March 2009 (UTC)

Donate
Ads