Rooot.net

  • Increase font size
  • Default font size
  • Decrease font size
The first step to getting the things you want out of life is this: Decide what you want.
Home Geek stuff Openwrt OpenWrt as a wifi client

OpenWrt as a wifi client

Most wifi routers are used as access point in infrastructure mode. However it is possible to configure then as wifi client so they can connect themselves to other access points. Here is how to do it on OpenWrt.

Package Installation

A freshly installed OpenWrt already have packages to use the router wifi capabilities. But use encryption you have to install the nas package.

~$ ipkg update
~$ ipkg install nas

Replace WAN with the wifi interface

On a WRT54Gv2, network interfaces are named as follow:

ports LAN : vlan0
port WAN : vlan1
WIFI : eth1

Any error may "brick" your router and you won't be able to access it anymore, so you'd better double check your network interface naming on the OpenWrt wiki.

OpenWrt uses the "wan_ifname" variable in many scripts to get the external network name (usually it's your DSL connexion). To ensure proper behavoir for all other services running on OpenWrt (like firewall) we are going to give this variable the wifi interface name.

~$ nvram set lan_ifname=br0
~$ nvram set lan_ifnames=vlan0
~$ nvram set wan_ifname=eth1

The LAN interface should get a fixed IP address.

~$ nvram set lan_ipaddr=192.168.2.1
~$ nvram set lan_proto=static

But the WAN side will get its IP address from the access point's DHCP server.

~$ nvram set wan_proto=dhcp

Connect to wifi network

First of all we have to list available access points. The "iwlist" command gives us SSID and channel for each detected access point.

~$ iwlist eth1 scanning
eth1 Scan completed :
Cell 01 - Address: 00:12:17:D4:DD:2A
ESSID:"ubikwiti"
Channel:1
Quality:0/0 Signal level:-44 dBm Noise level:-94 dBm
Bit Rate:1 Mb/s
Bit Rate:2 Mb/s
Bit Rate:5.5 Mb/s
Bit Rate:11 Mb/s
Bit Rate:18 Mb/s
Bit Rate:24 Mb/s
Bit Rate:36 Mb/s
Bit Rate:54 Mb/s
Bit Rate:6 Mb/s
Bit Rate:9 Mb/s
Bit Rate:12 Mb/s
Bit Rate:48 Mb/s

To join a network we have to unmount the wifi interface, then set the SSID and channel to be used.

~$ ifdown wan
~$ nvram set wl0_ssid=ubikwiti
~$ nvram set wl0_channel=1

Now let's set the encrpytion method and key. Here I am using WPA2 with TKIP. Please check the OpenWrt wiki for available options.

~$ nvram set wl0_akm=psk2
~$ nvram set wl0_wpa_psk=xxxxxxx

Once all these parameters are set we're good to restart the wifi interface (If you are running nas you have to restart it too).

~$ ifup wan
~$ /sbin/wifi

After a few seconds the router should establish a connexion to the accesss point. If everything is ok you just have to commit your changes.

~$ nvram commit

Happy surfing!

Comments
Add New Search
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."