Standalone access point with RPi (ethernet to wifi)

Run raspi-config and run Memory Split and set 16 Mb for GPU:
sudo raspi-config
Make sure your system is up to date
sudo apt-get update && sudo apt-get upgrade -y
Install all pre-requsites
sudo aptitude install rfkill hostapd hostap-utils iw dnsmasq -y
Open network configuration file
sudo nano /etc/network/interfaces
Set static address for wifi. Whole configuration now looks like
auto lo

iface lo inet loopback
iface eth0 inet dhcp

iface wlan0 inet static
address 192.168.29.1
netmask 255.255.255.0
Restart wifi interface
sudo ifdown wlan0
sleep 2
sudo ifup wlan0
Check if wlan0 interface has assigned its new ip address
pi@raspberrypi ~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:8c:75:50
          inet addr:192.168.0.111  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1470 errors:0 dropped:0 overruns:0 frame:0
          TX packets:879 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1067661 (1.0 MiB)  TX bytes:120858 (118.0 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr c0:4a:00:2b:00:4e
          inet addr:192.168.29.1  Bcast:192.168.29.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
Create a new Host Access Point Daemon configuration file
sudo nano /etc/hostapd/hostapd.conf
Paste the content:
ctrl_interface=/var/run/hostapd
macaddr_acl=0 auth_algs=1
driver=nl80211
interface=wlan0
hw_mode=g
ieee80211n=1
channel=7
ssid=pi
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Edit network name, password and chanel to suit your needs

Erase existing dnsmasq configuration
sudo truncate --size 0 /etc/dnsmasq.conf
Open dnsmasq configuration:
sudo nano /etc/dnsmasq.conf
Let the DHCP server assign addreses from 192.168.29.10 to 192.168.29.100
Copy these three lines to dnsmasq.conf. This will be all it is!
domain-needed
interface=wlan0
dhcp-range=192.168.29.10,192.168.29.100,255.255.255.0,12h
Create new startup service
sudo nano /etc/init.d/pipoint
Configure what this service will turn on ip forwarding, enable network address translation and start the access point
#!/bin/sh
# Configure Wifi Access Point.
#
### BEGIN INIT INFO
# Provides: WifiAP
# Required-Start: $remote_fs $syslog $time
# Required-Stop: $remote_fs $syslog $time
# Should-Start: $network $named slapd autofs ypbind nscd nslcd
# Should-Stop: $network $named slapd autofs ypbind nscd nslcd
# Default-Start: 2
# Default-Stop:
# Short-Description: Wifi Access Point configuration
# Description: Sets forwarding, starts hostap, enables NAT in iptables
### END INIT INFO

# turn on forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# enable NAT (network address translation)
iptables -t nat -A POSTROUTING -j MASQUERADE

# start the access point
hostapd -B /etc/hostapd/hostapd.conf
Set the startup service executable
sudo chmod 755 /etc/init.d/pipoint
Refresh startup cache
sudo update-rc.d pipoint start 99 2
Reboot the device
sudo reboot
Reference:
https://www.pi-point.co.uk/documentation/

No comments: