This is a detailed recipe for a wifi repeater setup, using two off-the-shelf router/NAT/AP boxes.



Read this Hackaday article, which describes how to get the OpenWRT box running in 'sta' client mode.

Plug the ethernet into the WRT and the laptop. On the laptop, run:

    sudo ifconfig eth0
    sudo ifconfig eth0 down
    sudo route add -net default gw

All traffic is now set to use ethernet instead of wifi. Log into the WRT and issue the following:

    nvram show > /tmp/full.dump

    nvram set lan_ifname=vlan0
    nvram unset lan_ifnames
    nvram set lan_proto=static
    nvram set lan_ipaddr=
    nvram set wifi_ifname=eth1
    nvram set wifi_proto=dhcp
    nvram set wl0_ifname=eth1
    nvram set wl0_mode=sta
    nvram set wl0_infra=1
    nvram set wl0_ssid="[the SSID string]"
    nvram unset wl_mode
    nvram unset wl_infra
    nvram unset wl_ssid

    ifdown lan ; ifup lan
    ifdown wifi ; ifup wifi

Save that "/tmp/full.dump" somewhere safe, off the WRT! e.g. on the laptop, do:

    scp [email protected]:/tmp/full.dump full.dump

Anyway, back to the WRT. Note: those settings haven't been committed to NVRAM yet, so don't reboot. This command will then successfully list your APs in range:

    wl scan ; sleep 1 ; wl scanresults

Now, I'm supposed to be able to do this:

    wl join "[the SSID string]"
    ifdown lan ; ifup lan
    ifdown wifi ; ifup wifi
    udhcpc -i eth1

But OpenWRT's doco is slightly awry there; it doesn't yet work. In my experience, I had to just satisfy myself that the LAN interface was working reliably, save a few local copies of brick-recovery HOWTO documents, cross my fingers, and commit the changes to NVRAM:

    nvram commit; reboot

Anyway, after that reboot, "ping" from the WRT does indeed work, so the WRT is now connected to both the LAN and the neighbour's wifi! Now to get bridging working.

Setting up the repeater router

So, next step is to get the repeater router working. First off, plug the laptop on my laptop, switch from DHCP-assigned-address wifi to the ethernet (this is the same as the first step in the WRT set above):

    sudo ifconfig eth0
    sudo ifconfig ath0 down
    sudo route add -net default gw

Turn on the Netgear POS router, turn off proxies in firefox, and log into the admin interface via whatever IP address/user/password it's set up to use. Go to the "settings / LAN IP Setup" page, and set:

Apply, and reset the laptop's IP to use that network.

    sudo ifconfig eth0 up
    sudo ifconfig ath0 down
    sudo route add -net default gw

Re-login at . Now, go to "settings / Setup / Basic Settings":

Apply. "settings / Wireless", select an SSID string and a channel that differ from the WRT-to-neighbour SSID and channel:

Apply. Next, on the laptop:

    sudo ifconfig eth0 down
    sudo vi /etc/network/interfaces

Add these two lines:

    iface ath0 inet dhcp
      wireless-essid MySSIDString

And bring up the wifi:

    sudo ifup ath0; sudo dhclient ath0

Unplug the ethernet cable, and plug it from an ethernet port on the WRT to an ethernet port on the Netgear.

You should now be able to:

    ssh [email protected]

in other words, you can now ssh from the laptop via wifi, via the Netgear, to the WRT. You can also ping on the WRT, but cannot yet do that from the Netgear or the laptop. Next step is to set up NAT. On laptop:

    scp [email protected]:/etc/init.d/S45firewall S45firewall
    cp S45firewall S45firewall.wifi

Since we're basically using the wifi interface as the internet-facing interface, the changes required are easy; edit 'S45firewall.wifi' and replace "wan_" with "wifi_". Then, copy it back:

    scp S45firewall.wifi [email protected]:/etc/setupmasq
    ssh [email protected]
    rm /etc/init.d/S45firewall

When the machine comes back up, log in again and run that script:

    ssh [email protected]

Check the laptop; everything should now work; HTTP, ping, the works. If you're brave, set up that masq script as '/etc/init.d/S45firewall'; otherwise just remember to re-run it if you accidentally unplug the WRT.

Given all that, you've now constructed a wifi repeater out of left-over bits of off-the-shelf commodity hardware and open-source software!

WifiTwoRouterRepeater (last edited 2006-02-03 16:47:25 by hughes-family)