User Tools

Site Tools


Sidebar






newpage

linux:network:access_point_-_hostapd

This is an old revision of the document!


Access Point - hostapd

Howto create a WLAN Access-point with the hostapd software

Check, if your wifi card is supported

Find kernel driver:

lspci -k | grep -A 3 -i "network"

Look for the driver in the output: “Kernel driver in use: ath9k”

Check, if the output contains a driver supported by hostapd

modinfo ath9k | grep 'depend'

“depends: ath9k_hw,mac80211,ath9k_common,ath,cfg80211”

in this case, “mac80211” is supported

Install hostapd and dnsmasq dhcp server

apt-get update
apt-get install hostapd dnsmasq

Configure hostapd

Edit /etc/hostapd/hostapd.conf

First test:

#change wlan0 to your wireless device
interface=wlan0
driver=nl80211
ssid=test
channel=1 

Complete config

change SSID, wpa_passphrase and channel

interface=wlan0
driver=nl80211
ssid=NAME-OF-ACCESS-POINT
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=PASSWORD-HERE
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Configure dnsmasq

This is used, because its easier to configure than dhcpd

Edit /etc/dnsmasq.conf and add:

# disables dnsmasq reading any other files like /etc/resolv.conf for nameservers
no-resolv
# Interface to bind to
interface=wlan0
# Specify starting_range,end_range,lease_time
dhcp-range=10.0.0.3,10.0.0.20,12h

# dns addresses to send to the clients - USE GOOGLE DNS-SERVERS
server=8.8.8.8
server=8.8.4.4

Init script to start hostapd

Save this script to /root/bin/hostapdinit

#!/bin/bash
#Initial wifi interface configuration
ifconfig $1 up 10.0.0.1 netmask 255.255.255.0
sleep 2

###########Start dnsmasq, modify if required##########
if [ -z "$(ps -e | grep dnsmasq)" ]
then
 dnsmasq
fi
###########

#Enable NAT
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface $2 -j MASQUERADE
iptables --append FORWARD --in-interface $1 -j ACCEPT
 
#Thanks to lorenzo
#Uncomment the line below if facing problems while sharing PPPoE
#iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

sysctl -w net.ipv4.ip_forward=1

#start hostapd
hostapd /etc/hostapd/hostapd.conf 1> /dev/null
#killall dnsmasq

Run the script

reboot

Make the script executable:

chmod a+x /root/bin/hostapdinit

run the script with the correct devices:

/root/bin/hostapdinit wlan0 eth0

Source

linux/network/access_point_-_hostapd.1373380666.txt.gz · Last modified: 2013/07/09 16:37 by tkilla