Configuring FON as a wireless client (WPA network)
There are hundred and one stuffs to be done with the FON router! My current D-Link network camera (DCS-2120) wasn’t capable of connecting to my wireless network due to the constraints of DCS-2120 in accepting certain characters in my WPA key. I toyed with the settings in console mode (of DCS-2120) and failed to make it understand the WPA key, so I guess I would need to work around it.
To work around it, I configured FON to be the wireless bridge! The DCS-2120 would connect to the FON through the ethernet port and FON would connect to my network as a wireless client.
Configuring it is easy on OpenWRT (kamikaze). 🙂
Step 1
Ensure you have connectivity with the internet, ssh into FON router and install WPA-Supplicant if you are planning to connect to a WPA secured network.
root@OpenWrt:~# ipkg update
root@OpenWrt:~# ipkg install wpa-supplicant
Step 2
Next would be configuring the ethernet port to be the lan interface and the wan to be the wireless. Now my /etc/config/network looks like this. If you don’t wish to delete off any additional stuffs you have inside, you can comment them off by add a # at the start of the line.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | config interface loopback option ifname lo option proto static option ipaddr 127.0.0.1 option netmask 255.0.0.0 config interface lan option ifname eth0 option proto static option ipaddr 172.16.0.1 option netmask 255.255.255.0 config interface wan option ifname ath0 option proto dhcp |
The ethernet port would distribute Class B address and the FON router itself would be using the IP 172.16.0.1/24
Step 3
Next would be configuring the wireless to be in client mode. My /etc/config/wireless now looks like this
1 2 3 4 5 6 | config wifi-device wifi0 option type atheros config wifi-iface option device wifi0 option mode sta |
Configure the WPA settings. Create a new file /etc/wpa_supplicant.conf (create the file wpa_supplicant.conf at /etc/). In this file, you would specify the SSID of the network to connect to as well as the passphrase for connecting to it.
1 2 3 4 5 6 7 | ctrl_interface=/var/run/wpa_supplicant update_config=1 network={ ssid="<SSID>" psk="<passphrase>" } |
To get the wpa_supplicant to auto-run on startup. We would need to create a shell script.
Create the file /etc/init.d/wpa_start.sh (filename is wpa_start.sh and located at /etc/init.d/)
1 2 | #!/bin/sh wpa_supplicant -Dwext -iath0 -c/etc/wpa_supplicant.conf -B |
Change the permission of the shell script to 755 and creating a symbolic link from /etc/rc.d/
root@OpenWrt:~# chmod 755 /etc/init.d/wpa_start.sh
root@OpenWrt:~# cd /etc/rc.d/
root@OpenWrt:/etc/rc.d# ln -s /etc/init.d/wpa_start.sh S90wpa_start
Reboot the device and FON is configured! Make sure all your settings are correct or you might be locking yourself out of FON due to misconfiguration of network interfaces!