amuck-landowner

Creating an WLAN access point with your Raspberry Pi

wlanboy

Content Contributer
Install required packages:

sudo apt-get install hostapd dnsmasqSet static ip to your wlan interface:

nano /etc/network/interfacescontent: (check for a single wlan0 entry!)

iface wlan0 inet static
address 192.168.20.1
netmask 255.255.255.0Add a configuration to hostap:

nano /etc/default/hostapdcontent: (add config file line):

# Defaults for hostapd initscript
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative
# methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration
# file and hostapd will be started during system boot. An example configuration
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
DAEMON_CONF="/etc/hostapd/hostapd.conf"If you are not sure what driver is needed check your usb devices (driver name will be disbplayed)

lsusb -t
Code:
lsusb -t
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
|__ Port 1: Dev 2, If 0, Class=vend., Driver=smsc95xx, 480M
|__ Port 5: Dev 3, If 0, Class=vend., Driver=rtl8192cu, 480M
Create hostapd.conf:
 

nano /etc/hostapd/hostapd.confcontent:

# interface for ap
interface=wlan0
# driver of wlan stick
driver=rtl871xdrv

ctrl_interface=/var/run/hostapd
ctrl_interface_group=0

# wlan ap configuration
ssid=RaspberryPi
channel=1
hw_mode=g
ieee80211n=0

# wlan security
wpa=2
wpa_passphrase=super-secure-password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP

# country code
country_code=US
Add dnsmasq configuration:

nano /etc/dnsmasq.confContent: (two important lines)

# Configuration file for dnsmasq.

# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
interface=wlan0

# Uncomment this to enable the integrated DHCP server, you need
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
dhcp-range=192.168.20.100,192.168.20.200,255.255.255.0,12h
#set default gateway (if wanted)
#dhcp-option=3,192.168.20.1

Restart services:
 

sudo service hostapd restart
sudo service dnsmasq restart
Enable IP forwarding:

nano /etc/sysctl.confUncomment:

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1Activate settings:

sudo sysctl -p
Setup forwarding rules:

nano /etc/network/if-up.d/apforwarding && chmod +x /etc/network/if-up.d/apforwarding content:

# !/bin/sh
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface wlan0 -j ACCEPT
Reboot your Raspberry Pi.
 

MannDude

Just a dude
vpsBoard Founder
Moderator
Oh snap.... how did I never catch this before? Gosh, I've been so busy lately. I've been looking for a good tutorial on this, as everyone I've ever found, for one reason or another, has failed me in the past.


When I get some free time I plan on reorganizing some things at home and one of the things on my 'to do' list is get one of my Pi's back up. I'll report back!
 

drmike

100% Tier-1 Gogent
This is a good tutorial I need to bookmark already.


Been doing more and more with ARM platform.  Nothing mega exciting, but more.  Using them more than VPS / dedis these days.
 

WasNotWSS

Member
As a directly-related inquiry: Are there any USB based wireless adapters that have better features than, say, this weeks' RealTek? Any that let you bond multiple MAC addresses to? How about throughput? I have some ~150/300/600 and AC plausible devices, but even under x86 Linux, they tend to fall flat due to software fifo issues and unreliable binary blob resources. I've had very good results with Atheros based- but those have mostly been used on my MIPS projects, not ARM.
 
Top
amuck-landowner