From https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/overview
and from http://www.daveconroy.com/using-your-raspberry-pi-as-a-wireless-router-and-web-server/
Install hostapd and dhcp
sudo apt-get update sudo apt-get install -y hostapd isc-dhcp-server
Modify file:
sudo nano /etc/dhcp/dhcpd.conf
change:
option domain-name "example.org"; option domain-name-servers ns1.example.org, ns2.example.org;
to:
#option domain-name "example.org"; #option domain-name-servers ns1.example.org, ns2.example.org;
and change:
# If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative;
to:
# If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. authoritative;
in the bottom add the following:
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; }
Save and exit editor.
Modify file:
sudo nano /etc/default/isc-dhcp-server
change:
INTERFACES=""
to:
INTERFACES="wlan0"
Save and exit editor
Modify file
sudo nano /etc/network/interfaces
after this line:
allow-hotplug wlan0
insert the following:
iface wlan0 inet static address 192.168.42.1 netmask 255.255.255.0
change the following:
iface wlan0 intet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp
to:
#iface wlan0 intet manual #wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf #iface default inet dhcp
Save and exit editor
sudo ifconfig wlan0 192.168.42.1
(create new file):
sudo nano /etc/hostapd/hostapd.conf
insert the following for a wpa-psk secured network (change ssid and passhprase as required):
interface=wlan0 driver=rtl871xdrv ssid=My_AP hw_mode=g channel=6 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=Raspberry wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP
(also change driver is not a rt1871xdrv)
If using an open, unsecure network insert the following:
interface=wlan0 ssid=My_AP hw_mode=g channel=6 auth_algs=1 wmm_enabled=0
Save and exit editor
Modify file:
sudo nano /etc/default/hostapd
change:
#DAEMON_CONF=""
to:
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Save and exit editor
- in order to support the wifi adapter
get new hostapd:
wget http://adafruit-download.s3.amazonaws.com/adafruit_hostapd_14128.zip
unpak zipped file:
unzip adafruit_hostapd_14128.zip
backup the original hostapd:
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.ORIG
replace with the new hostapd:
sudo mv hostapd /usr/sbin
change rights:
sudo chmod 755 /usr/sbin/hostapd
Modify file:
sudo nano /etc/sysctl.conf
aee in the bottom of the file:
net.ipv4.ip_forward=1
Save and exit editor.
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
Create network translation between eht0 and wlan0
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"
Modify file:
sudo nano /etc/network/interfaces
add to the bottom of the file
up iptables-restore < /etc/iptables.ipv4.nat
Save and exit editor.
register daemon files:
sudo update-rc.d hostapd enable sudo update-rc.d isc-dhcp-server enable
Depending on the distro it may be required to remove the WPA_supplicant file
sudo mv /usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service ~/
Reboot and connect to the access point