WRT54G: Wireless Client

From ReceptiveIT
Jump to: navigation, search

his page contains an overview on how to configure a LinkSys WRT54GS running OpenWrt as a wireless client router.

Introductory Information Firstly, be sure to have a look at Matt Kemner's guide to turning the Linksys WRT54G / WRT54GS into an AP-client and routing node. It provides a concise overview on how to configure OpenWrt as a client node, and was invaluable.

Configuration Connecting to the WRT Assuming your WRT has just been flashed with OpenWrt firmware, you'll need to telnet to to configure it.

Remove the Firewall The default firewall on OpenWRT provides some basic inbound firewalling and NAT on the WAN interface. We don't want to use NAT, and will be implementing a more appropriate firewall later, so disable the existing firewall by preventing it from being executed:

chmod 644 /etc/init.d/S45firewall

Set Hostname Optionally, you can also set the hostname of the WRT:

 nvram set wan_hostname=MyWrt

Network Configuration Setup WAN Port At this point, I configured the WAN port with a valid IP address on my home network, to me to complete the configuration, and to give the WRT internet access via my network (for installing additional packages).

To configure the WAN (vlan1 interface) port, I used the following:

 nvram set wan_proto=static
 nvram set wan_ipaddr=
 nvram set wan_netmask=

and set a default gateway and DNS server:

 nvram set wan_gateway=
 nvram set wan_dns=

Commit the changes, and reboot:

 nvram commit

The WAN port was then connected to my switch, and I could telnet to the WRT on the IP address I had given to the WAN interface.

Remove Bridge The default OpenWrt configuration has the wireless interface bridged with the LAN ports. To allow routing and firewalling between these interfaces, the bridge needs to be be removed. At the same time, we'll also rename the LAN ports to vlan0:

 nvram set lan_ifname=vlan0
 nvram unset lan_ifnames

Setup LAN Interface Now that the bridge has been removed, the LAN interface (vlan0) can be configured with a static IP address:

 nvram set lan_proto=static
 nvram set lan_ipaddr=
 nvram set lan_netmask=

Setup Wireless Interface Similarly, the wireless interface (eth1) can be configured:

 nvram set wifi_ifname=eth1 
 nvram set wifi_proto=static
 nvram set wifi_ipaddr=
 nvram set wifi_netmask=
 nvram set wifi_gateway=
 nvram set wifi_dns=

Rather than relying on the WRT to use decide which antenna socket to use, we'll force it to only use the main antenna socket, located next to the power socket (-1=auto, 0=main, 1=aux, 3=diversity):

 nvram set wl0_antdiv=0

Wireless Client Configuration Set Client Mode The wireless mode of the WRT can be set to ap (access point mode), sta (station/client mode), or wet (wireless ethernet bridge). As we're using it as a client, the mode gets set as follows:

 nvram set wl0_mode=sta

When using sta or wet mode, you also need to specify if ad-hoc or infrastructure/managed mode is being used, with 0 used to specify ad-hoc mode, and 1 for managed mode:

 nvram set wl0_infra=1

Set the ESSID The ESSID of the wireless network to connect to needs to be specified:

 nvram set wl0_ssid=SGNet

Save and Reboot Before continuing, commit all changes, and reboot the WRT:

 nvram commit

After the WRT has rebooted, verify that the configuration changes have been successfully applied.

Testing Wireless Connectivity Using iwconfig iwconfig can be used to check the status of your wireless link, by running

 iwconfig eth1

If a wireless connection has been established by your WRT, the link quality should have a value greater than zero, and the signal and noise should have valid values:

eth1 IEEE 802.11-DS ESSID:"SGNet"

         Mode:Master  Frequency:2.437 GHz  Access Point: 00:14:BF:94:C1:35
         Tx-Power:19 dBm
         RTS thr=2347 B   Fragment thr=2346 B

Using wl An alternative way is to use a useful utility called wl. The wl utility provides more detail than iwconfig. Install wl using

 ipkg install wl

Once installed, you can use wl to list all the wireless networks that are visible to your WRT, using

 wl scan; sleep 1; wl scanresults

Assuming there is at least one wireless network visible, you should see output similar to

 SSID: "SGNet"
 Mode: Managed   RSSI: -83 dBm   noise: -94 dBm  Channel: 13
 BSSID: 00:0C:F1:96:C9:BD        Capability: ESS
 Supported Rates: [ 1(b) 2(b) 5.5(b) 11(b) ]

You can also use wl to join any wireless network, using

 wl join SGNet

Additional Configuration Package List Assuming your WRT can access the internet, get it to update its ipkg database, and then retrieve a list of the available packages:

 ipkg update
 ipkg list

Install SSH Server Telnet is insecure, as the authentication is in clear text. Instead of using telnet, we'll switch to SSH. Earlier versions of OpenWrt didn't come with an SSH server, so it had to be manually installed:

 ipkg install dropbear

During the installation, you'll be asked to set a password for the root user account.

Test SSH However, more recent versions of OpenWrt, including RC4, come with the dropbear SSH server included. To enable it, you just need to set a password for the root user account from a telnet prompt:


Test it by rebooting:


Remove Telnet Server Verify you can SSH into your WRT as root. If so, you can now stop the telnet server:

 rm /etc/init.d/S50telnet
 killall telnetd

Finalise Network Configuration Once a wireless connection was established, all further administration and configuration was done over the wireless link.

Re-configure WAN Port The WAN port wasn't required, and hence was configured for on-site administration, to provide a way to locally access the WRT for configuration, if required.

 nvram set wan_proto=static
 nvram set wan_ipaddr=
 nvram set wan_netmask=
 nvram unset wan_gateway
 nvram unset wan_dns

Save and Test These changes must be committed, and the WRT was rebooted to test the new configuration:

 nvram commit