Router Tech

From Fab Lab wiki

Revision as of 09:55, 23 June 2010 by Amy (Talk | contribs)
Jump to: navigation, search

Contents

Introduction

The FabFi instructions on this page are specific to FF 3.0. You can get the old stuff HERE

Every fabfi 3.0 node serves a wireless and wired mesh network, a local lan, and can be uplinked directly to the web. In order to reconfigure the router with all these new features 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.

As of FabFi version 3.0, we have expanded our support to cover the Asus wl-520gu, and have completely revamped the installation model to be faster and simpler. The following sections detail the downloading, installation, and configuration of this firmware for the Linksys WRT54GL or Asus WL-520GU.

Building Fabfi (OpenWRT) Images

While we do distribute a built image, a lot more flexibility is available if you're willing to build your own. Learn how to do it two different ways HERE

Installing the Fabfi Image (from factory configuration)

As of v3.0, we are now supporting multiple routers. After the image download instructions, you will find a link to a dedicated page for each router with device specific instructions. Before you begin, make sure your router is supported in the next section. This is VERY important...

Determining if Your Router is Supported

Fabfi developers currently build and test images for:

  • Linksys wrt54gl
  • Asus wl-520gu

There are plenty of other routers that could work, we just haven't gotten to them yet. See Using Other Routers for directions and support if your router isn't listed.


Downloading and Installing Fabfi (OpenWRT) Firmware

Download the appropriate image for your router then follow the install directions below. (All the images are available a http://fabfi.fabfolk.com/quickstart/firmware/, but somewhat embarrassingly, we can't get the apache to agree to directory browsing. Thus the direct links are posted here, for now. (the naming algorithm is fabfi-<make>_<model>.<bin|trx>)

How to configure a Linksys WRT54GL

Download these image files: fabfi-linksys_wrt54gl.trx fabfi-linksys_wrt54gl.bin then go to How to configure a Linksys WRT54GL for instructions.

How to configure an ASUS WL-520GU

Download this image file: fabfi-asus_wl520gu.trx then go to How to configure an ASUS WL-520GU .

Initial Configuration

After flashing and rebooting your router, point your browser to http://fabfi and you will see a page containing this message:

You can use telnet from the command prompt on a windows machine or the terminal on a linux or Mac machine. (NOTE: once you have run the config script, you will no longer be able to use telnet. You will use ssh instead. Linux and Mac machines support ssh natively in the terminal. Windows users should download PuTTY)

  • Follow the instructions in the script. It will ask you for the following:
    • Number of the Fabfi (should be unique for every node in the network)
    • Wireless Channel (must be the same for any two nodes you intend to talk over a wireless link) See HERE for more information about slecting channels.
    • Longest expected distance between this node and it's farthest direct neighbor
    • WEP key (must be the same for any two nodes talking directly over wireless. TYPE 'd' to use the default WEP key.
      • Determines IP addresses for the device.
    • Location of the device (defines the SNMP identifier for the device)

When you have completed the script the device will reboot and change its settings. When it reboots you will have to refresh the network connection on your laptop (because therouter's IP addresses will have changed). This can be done by unplugging the net cable, waiting 10 seconds or so then replacing the cable. You can then browse normally.

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 "root" 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

The Port Mapping on the device after setup is as follows:

  • Internet Port: WAN
  • 1-2: MESH
  • 3-4: LAN

Upgrading From Earlier Versions

This section explains upgrading from v2.x or greater to 3.x. If you have a 1.0 device, go HERE first.

Automatic Upgrade

If you already have a 3.x device and simply want to install the latest patches without reflashing your whole image, ssh to your fabfi, download and run the fabfi-update script:

cd /tmp && wget http://fabfi.fabfolk.com/quickstart/fabfi-setup
sh fabfi-setup

If you are upgrading from 2.x or want a clean image with the latest stuff, v3.x implements a remote flashing function driven by the script

/etc/fabfi-scripts/upgrade-pre

any 3.0 or later device will have this script already installed and you can run it from a ssh window. 2.x devices require that you download the script first. NOTE: the upgrade script only works on "standard" configurations. It will figure out your old fabfi# basic wireless settings and switchports, but it doesn't check your interface mappings or unusual vlans. If your configuration is "special", then you will have to do some manual configuration after the fact or try the manual flash procedure in the next section

To Upgrade:

  • ssh to your router
  • Make sure the router has reliable power
  • Make sure the router is connected to the internet
  • Navigate to the fabfi scripts directory:
cd /etc/fabfi-scripts
  • For 2.x devices:
    • download the upgrade script
wget http://fabfi.fabfolk.com/quickstart/firmware/upgrade-pre
  • Run the script(from the fabfi-scripts directory) with
sh upgrade-pre
  • WAIT... (it will take about five minutes. You will see your router reboot twice)
Offline Auto-upgrade
  • place firmware image from the website in the /tmp folder on the router without changing the name
    • You should be using the.trx file built for your device
  • Edit the upgrade-pre script by commenting out the if statement containing the wget for the firmware image as follows:
#if `wget "${SWURL}fabfi-${system}.trx"`
#    then

echo "" > $SYSVARS

echo vlan0=\'`uci get network.eth0.vlan0`\' >> $SYSVARS
echo vlan1=\'`uci get network.eth0.vlan1`\' >> $SYSVARS
echo vlan2=\'`uci get network.eth0.vlan2`\' >> $SYSVARS
echo fabfi_num=\'`uci get network.wifimesh.ipaddr | grep -oe "\.[0-9][0-9]*$" | grep -oe "[0-9][0-9]*"`\' >> $SYSVARS
echo channel=\'`uci get wireless.wl0.channel`\' >> $SYSVARS
echo distance=\'`uci get wireless.wl0.distance`\' >> $SYSVARS
echo wep_key=\'`uci get wireless.@wifi-iface[0].key`\' >> $SYSVARS
echo location=\'`uci get mini_snmpd.@mini_snmpd[0].location`\' >> $SYSVARS
echo "" >> $SYSVARS

#create reboot script file and link to rc.d
echo "#!/bin/sh /etc/rc.common" > $INITS
echo "" >> $INITS
echo "START=04" >> $INITS
echo ". $INITSCR" >> $INITS
echo "" >> $INITS 

ln -s $INITS $INITRC
chmod +x $INITS
tar -czf ffconfig.tar.gz $SYSVARS $INITS $INITRC $PASS  

#flash and reboot
sysupgrade -n -v -f ffconfig.tar.gz fabfi-${system}.trx

#fi
 
  • run the upgrade-pre script. It does not matter where you place this script to run it.

Manual Upgrade

To upgrade your device without saving your settings, you can run sysupgrade with a fresh image:

sysupgrade -n <path to the .trx file for your device>

Logging into your configured router with SSH

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 the web
ssh root@<external IP of router> (this is only used if you're connecting from the public internet)
  • from the LAN (You must be plugged into PORT 4!)
ssh root@10.103.<FF#>.1 (this is the LAN IP, and best if you are directly connected to the router you are SSHing to)

or

ssh root@10.101.0.<FF#> (this is the MESH IP, and should be visible from anywhere inside the FabFi network)

or

ssh root@10.102.0.<FF#> (this is the WIFIMESH IP, and should be visible from anywhere inside the FabFi network)

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


Restoring Default Fabfi Settings

  • ssh to your device and run
firstboot
  • wait about 30 seconds and then hard reboot your device (a soft-reboot may work too but I haven't tried)

Manual Router Configuration

OpenWRT, being a linux based firmware, holds all of its configuration variables (that you care about) in plain text files. The files we change from the default build are too numerous to list here, but you can see what is changed by browsing through the imagebuilder configuration files. NOTE: there are lost of "dead" symlinks that are important. preserve them by unpacking with

tar -xzf <tarfile>

Using the Web GUI to make manual changes

One of the most exciting features of OpenWRT 8 is that it comes with an integrated web GUI. (yes, Mr. Linux geek, GUIs are unnecessary overhead and prone to bugs, but sometimes you just don't want to leave your browser, K?).

Logging into the web GUI

in order to log in, you type the following in your browser:

http://10.103.<FF#>.1

where "<FF#>" is the number of your Fabfi. For example fabfi20 would be:

http://10.103.20.1

For version 3.x and you can also use

http://fabfi

you will then be prompted for a username and password. you should use your SSH username and password here.

Remember that if you attempt to configure the router via ethernet, you MUST be plugged into PORT 4!

GUI Configuration WARNING!!!!

  1. As of OpenWRT 8.09.2, there are a number of minor bugs in the web GUI, mainly having to do with things not getting updated when you click "save & apply". I'm not going to list all the bugs here (mainly because I'm not sure exactly what they all are), but beware that if it hasn't been explicitly tried and explained below, it may or may not work from the GUI.
  2. There are some relationships between settings (such as between channel, ESSID and BSSID) that are required for FabFi, but aren't captured in the GUI, so be sure you know what you're doing before you use the GUI to start changing things.
  3. Not everything has a GUI interface.

FabFi Specific configuration instuctions

All of the sections below detail settings changes I have tested from the web GUI. There are lots of things not listed here that also work, but make sure you test anything not listed here in a safe environment before working on a deployed node (especially if it's remote).

Changing the wireless channel

The wireless meshing protocol in FabFi depends on the BSSID to identify if a wireless signal is a member of it's mesh. There is a peculiar "feature" of the implementation that if a node hears from a neighboring node on boot using the correct BSSID it will switch it's wireless channel to that of the node it hears. It will then stay on this channel for perpetuity unless banged on really hard to switch. The resulting effect is that if you have one node on the wrong channel in a particular mesh, it is possible that over multiple reboots the entire network will switch to that channel (bad!!!). As a result, there must be a 1:1 correlation between the BSSID of the mesh and the channel of that mesh.

For every fabfi, the BSSID is set to:

##:fa:bf:1f:ab:f1

where ## is the channel of the network. For instance a network on channel 6 would be:

06:fa:bf:1f:ab:f1

ch 11 would be:

11:fa:bf:1f:ab:f1


For every fabfi, the ESSID is set to:

fabfi#

where # is the channel of the network. For instance a network on channel 6 would be:

fabfi6

ch 11 would be:

fabfi11

When changing the wireless channel in the web GUI, one must change BOTH the channel and the BSSID at the same time. Here's how to do it:

  1. Log into the web GUI
  2. Click "Administration" on the top right
  3. Go to "Network > wireless > wl0"
  4. In the "Channel" section, select your channel
  5. In the ESSID section change the ESSID to end with the channel # as shown above
  6. In the BSSID section change the BSSID to start with the channel # as shown above
  7. Click "Save & Apply" and WAIT FOR THE PAGE TO RETURN.
  8. Power cycle your router (I am testing the way to ensure the channel is changed when doing remote admin and will post when done)

Get the latest

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


Wtgphoben: 14:14, 09 September 2010 (UTC)

Donate
Ads