Skip to content

Setup notes Wifi access point

Brice Copy edited this page Jun 15, 2015 · 1 revision

Wifi access point setup

The Raspbuggy acts as a Wifi access point, allowing any wifi enabled device to connect and program it. Setting up a Wifi access point (infrastructure mode) requires the installation and configuration of the following packages :

  • hostapd
  • isc-dhcp-server

Full instructions are available in the Adafruit learning database at https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software

sudo apt-get update
sudo apt-get install hostapd isc-dhcp-server

# Now disable domain-name options, enable authoritative - TODO : Create a sed script for that
sudo nano /etc/dhcp/dhcpd.conf

# Also append (without the comments)
###
#
# subnet 192.168.42.0 netmask 255.255.255.0 {
#	range 192.168.42.10 192.168.42.50;
#	option broadcast-address 192.168.42.255;
#	option routers 192.168.42.1;
#	default-lease-time 600;
#	max-lease-time 7200;
#	option domain-name "local";
#	option domain-name-servers 8.8.8.8, 8.8.4.4;
# }
###

# Now enable dhcp on wlan0
# change INTERFACES="" to INTERFACES="wlan0" 
###
sudo nano /etc/default/isc-dhcp-server
###

# Now set wlan0 as a static address
# After "allow-hotplug wlan0" - and also comment out any other wlan0 related lines
###
sudo nano /etc/network/interfaces
# iface wlan0 inet static
# address 192.168.42.1
# netmask 255.255.255.0
###

# Now configure the hostapd (wifi access point)
###
sudo nano /etc/hostapd/hostapd.conf
# interface=wlan0
# driver=rtl871xdrv  # Here, adjust which driver to use for your chipset
# ssid=Pi_AP   # Here, modify your access point name
# hw_mode=g
# channel=6
# macaddr_acl=0
# auth_algs=1
# ignore_broadcast_ssid=0
# wpa=2
# wpa_passphrase=Raspberry  # Here, modify the passphrase
# wpa_key_mgmt=WPA-PSK
# wpa_pairwise=TKIP
# rsn_pairwise=CCMP
###

# Now enable hostapd
# Replace #DAEMON_CONF="" and edit it so it says DAEMON_CONF="/etc/hostapd/hostapd.conf"
###
sudo nano /etc/default/hostapd
###

# Now setup NAT tunneling, to allow to tunnel data through to eth0 (for internet access for instance)
# Add net.ipv4.ip_forward=1
# on a line at the end of the file
###
sudo nano /etc/sysctl.conf
###

# Activate routing via iptables
###
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
###

# Ensure iptables is configured on restart
# Add up iptables-restore < /etc/iptables.ipv4.nat
# at the very end of the file
###
sudo nano /etc/network/interfaces
###

# Ensure hostapd and dhcp start upon boot
sudo update-rc.d hostapd enable 
sudo update-rc.d isc-dhcp-server enable

sudo reboot