Archlinux/Raspberry Pi - Access point with hostapd

WLAN access point with EDiMAX EW-7811Un

Install dependencies

We need the tool hostapd to configure our access point

pacman -S hostapd

Configuration

After the installation we create the configuration file:

nano /etc/hostapd/hostapd.conf

Insert following configuration

#sets the wifi interface to use, is wlan0 in most cases
interface=wlan0

#driver to use, nl80211 works in most cases
#but we need rtl871xdrv
driver=rtl871xdrv

#sets the ssid of the virtual wifi access point
ssid=pirouter

#bridge=br0

#sets the mode of wifi, depends upon the devices you will be using.
#It can be a,b,g,n. Setting to g ensures backward compatiblity.
hw_mode=g
ieee80211n=1

#sets the channel for your wifi
channel=6

#macaddr_acl sets options for mac address filtering.
# 0 means "accept unless in deny list"
macaddr_acl=0

#setting ignore_broadcast_ssid to 1 will disable the broadcasting of ssid
ignore_broadcast_ssid=0

#Sets authentication algorithm
# 1 - only open system authentication
# 2 - both open system authentication and shared key authentication
auth_algs=1

#####Sets WPA and WPA2 authentication#####
#wpa option sets which wpa implementation to use
# 1 - wpa only
# 2 - wpa2 only
# 3 - both
wpa=2

#sets wpa passphrase required by the clients to authenticate themselves
#on the network
wpa_passphrase=PASSWORD

#sets wpa key management
wpa_key_mgmt=WPA-PSK

#sets encryption used by WPA
wpa_pairwise=TKIP

#sets encryption used by WPA2
rsn_pairwise=CCMP

Configure the parameters ssid and wpa_passphrase to match your own needs. After that we will face a driver issue. To install the needed driver of EDiMAX EW-7811Un use following command

#needs time (most expencive: cleaning build area)
pacman -Sy dkms-8192cu
Issue:
The actual version contains a bug with this driver. But we will install an older version: hostapd.zip
# we will need unzip later
pacman -S unzip

#download hostapd
wget http://www.daveconroy.com/wp3/wp-content/uploads/2013/07/hostapd.zip
# if original source isn't available
wget --no-check-certificate -O hostapd.zip https://theartofstrangecode.de/assets/exec/hostapd.zip

#unzip and install
unzip hostapd.zip
mv /usr/sbin/hostapd /usr/sbin/hostapd.bak
mv hostapd /usr/sbin/hostapd.edimax
ln -sf /usr/sbin/hostapd.edimax /usr/sbin/hostapd
chown root.root /usr/sbin/hostapd
chmod 755 /usr/sbin/hostapd
Quellen

Dave Conroy - RaspPi as Wifi Hotspot

Test the access point configuration

#starts hostapd, you are able to quit with [Ctrl]+C
hostapd /etc/hostapd/hostapd.conf

# -B could be used for execution in background

With our connfiguration we will be able to start an access point but devices are nt able to connect. There is no dhcp server available to setup the ip addresses for connection. Lets fix that in the next section…

Quellen


DHCP Server für WLAN-AccessPoint (via dnsmasq)

pacman -S dnsmasq

Configure DNSMASQ as dhcp server changing /etc/dnsmasq.conf

nano /etc/dnsmasq.conf

Add thes lines at the top of the file

domain-needed
bogus-priv
interface=wlan0    # change to your interface
dhcp-range=192.168.0.1,192.168.0.100,12h
Assign ip to wlan0
# delete existing entries
ip addr flush dev wlan0
192.168.0.1/24 dev wlan0
DHCP Server starten
dnsmasq -d  # -d Do NOT fork into the background: run in debug mode.
Start all together

start access point und dhcp server

#starten
hostapd -B /etc/hostapd/hostapd.conf
dnsmasq

#beenden
killall hostapd
killall dnsmasq

With this setup it will be possible to connect to the wifi access point, but not access the internet. For that you will have to create a nat connection or a bridge.