2015年2月17日 星期二

Raspberry pi Access Point using rl8192cu with bridge interface

As the wifi signal in my room is some weak, I can't even watch youtube on my iPad. I decide to use Raspberry to extend the wifi from living room to my bed room.

Here is my device information
Devcie: Raspberry Pi B+
Wifi device: TL-WN823N (rl8192cu chipset)

In the very beginning, I am trying to use OpenWrt on Raspberry PI.

Target System: (Broadcom BCM2708/BCM2835)
Wireless Drivers: kmod-rt18192cu Realtek RTL8192CU/RT8188CU

The firmware can be compiled and run smoothly on the Raspberry. My HTC one can acess the wifi but my iPad mini 2 seems unavailable to use the wifi. The reason seems to be some driver compatibility which I need to take a lot of time to fix it. Therefore, I choose to flash the firmware back to Raspbian.


First, my network setting is something like that.

Internet ---- wifi router (192.168.100.0/24) ---- HomePlug ---- Raspberry pi(my room)

## Download the require package
sudo apt-get install iw bridge-utills hostapd

I want the wifi router to also take the role of DHCP and DNS. Therefore, I just want to bridge the wireless interface to my ethernet interface.

Edit the config
## In /etc/network/interfaces
auto lo

iface lo inet loopback

auto br-wan
iface br-wan inet dhcp
bridge-ports eth0 wlan0

## In /etc/init.d/hostapd

DAEMON_CONF=/etc/hostapd/hostapd.conf

Time to start the hostapd service
sudo service hostapd restart

There are some error throwing out which said 'nl80211 driver not found'

follow the guy which have modified a good hostapd version to use rtl8192cu chipset
http://blog.sip2serve.com/post/38010690418/raspberry-pi-access-point-using-rtl8192cu

Copy the binary to /usr/sbin/ to overwrite hostapd
## Edit the config /etc/hostapd/hostsapd.conf
## config
interface=wlan0
bridge=br-wan
hw_mode=g
ieee80211n=1
channel=6
ssid=your_ssid
wpa=3
wpa_passphrase=yourssidpw
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Finally:
sudo service hostapd restart

root@raspberrypi:/etc/init.d# service hostapd restart
[ ok ] Stopping advanced IEEE 802.11 management: hostapd.
[....] Starting advanced IEEE 802.11 management: hostapdioctl[RTL_IOCTL_HOSTAPD]: Invalid argument
. ok
root@raspberrypi:/etc/init.d#