It is the 21st of July 2017

How to setup a WLAN Hotspot with Raspberry PI 2, Edimax 7811Un and Huawei E3372 802.11n

Wrapup of what is required to setup a Wifi Hotspot with a Raspberry PI 2 using an EDIMAX EW 7811Un Micro USB Wifi stick and a Huawei E3372 Modem.

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.1.13-v7+ #826 SMP PREEMPT Fri Nov 13 20:19:03 GMT 2015 armv7l GNU/Linux

pi@raspberrypi:~ $ cat /etc/issue
Raspbian GNU/Linux 8 \n \l
pi@raspberrypi:~ $ vcgencmd version Nov 18 2015 15:43:45 Copyright (c) 2012 Broadcom version 0c9af7cde38e223c95c3404f468db8fc5004495c (clean) (release)

 Hostapd for Edimax EW 7811Un

The Edimax EW 7811Un chipset requires a custom hostapd to run in managed mode:

sudo apt-get install hostapd dnsmasq
wget http://www.juergenkeil.de/download/hostapd-2.2.rtl871xdrv.gz
unzip hostapd-2.2.rtl871xdrv.zip
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.orig
sudo mv hostapd-2.2.rtl871xdrv /usr/sbin/hostapd-2.2.rtl871xdrv
sudo chmod +x !$
sudo ln -s !$ /usr/sbin/hostapd

Update: Better use hostapd-rtl from github

Disable power saving (fix raspberry pi wifi drop) See here

pi@raspberrypi2:~ $ cat /etc/modprobe.d/8192cu.conf 
# Disable power saving
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0 rtw_hwpwrp_detect=0 rtw_ips_mode=1

Increase Pi Power supply:

pi@raspberrypi2:~ $ cat /boot/config.txt |grep max_us
max_usb_current=1

Hostapd Configuration

pi@raspberrypi2:~ $ cat /etc/default/hostapd
...
DAEMON_CONF="/etc/hostapd/hostapd.conf"
...

Use driver=rtl871xdrv and noscan=1! (see here and here)

pi@raspberrypi2:~ $ sudo cat /etc/hostapd/hostapd.conf 
interface=wlan0
driver=rtl871xdrv
ssid=BluebeaN
country_code=AT
channel=6
wmm_enabled=1
wpa=3
auth_algs=3
wpa_passphrase=*****
wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP
wpa_pairwise=CCMP
rsn_pairwise=CCMP
macaddr_acl=0
eap_server=0
eapol_key_index_workaround=0
own_ip_addr=127.0.0.1
hw_mode=g
ieee80211d=1
ieee80211n=1
ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+][DSSS_CCK-40][MAX-AMSDU-7935]
noscan=1
eap_reauth_period=0
max_num_sta=8
beacon_int=100
pi@raspberrypi2:~ $ cat /etc/network/interfaces
...
auto wlan0
#allow-hotplug wlan0
iface wlan0 inet static
    address 192.168.0.1
    netmask 255.255.255.0
    up service hostapd restart
    up service dnsmasq restart
...

Update: On Raspberry PI 3 you can use a cleaner setup with dhcpcd

Dnsmasq Configuration

pi@raspberrypi2:~ $ cat /etc/dnsmasq.conf |grep -v -e "^#" -e "^$"
interface=wlan0
dhcp-range=192.168.0.50,192.168.0.150,12h

 Kernel Configuration

pi@raspberrypi2:~ $ cat /etc/sysctl.d/99-sysctl.conf |grep -v -e "^#" -e "^$"
net.ipv4.ip_forward=1

 WvDial Configuration

pi@raspberrypi2:~ $ cat /etc/wvdial.conf 

[Dialer Defaults]
Init1 = ATZ
Init2 = AT^CURC=0
Init3 = ATQ0 V1 E1 S0=0  
Init4 = AT+CGDCONT=1,"IP",""
Modem Type = Analog Modem
Baud = 115200
New PPPD = yes
Modem = /dev/ttyUSB1
ISDN = 0
Phone = *99#
Stupid Mode = yes
Carrier Check = no
Password = { }
Username = { }
Dial Command = ATDT
pi@raspberrypi2:~ $ cat /etc/rc.local
...
_WVDIAL=$(ps -ef|grep -v grep|grep wvdial) || true
if [ ! "$_WVDIAL" ]; then
  wvdial &
fi
...

 Performance

mike@mike-ThinkPad-T510 ~ $ iperf -c 192.168.0.1
------------------------------------------------------------
Client connecting to 192.168.0.1, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.135 port 36351 connected with 192.168.0.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 69.4 MBytes 58.0 Mbits/sec

Featured Apps

Free Money