-
Notifications
You must be signed in to change notification settings - Fork 0
Setup Guide
- Raspberry Pi Model: 3 B
- 16GB minimum SD
- latest version of Raspbian (Link)
- USB Mouse and Keyboard
- HDMI cable for display
- Ethernet cable (CAT5/6)
Run command sudo apt-get install dnsmasq hostapd
Run command sudo nano /etc/dhcpcd.conf
Add lines at bottom of file
`interface wlan0`
`static ip_address=172.24.1.1/24`
**Run command** `sudo nano /etc/network/interfaces`
**Add lines at bottom of file** (add/edit lines below after “allow-hotplug wlan0”)
`iface wlan0 inet static`
`address 172.24.1.1`
`netmask 255.255.255.0`
**Comment out the existing line to match below**
`# wpa-conf /etc/wpa_supplicant/wpa-supplicant.conf`
**Run command** `sudo service dhcpcd restart`
**Run command** `ifconfig`
Confirm wlan0 now has a static ip of 172.24.1.1
## Step 3 - Configure hostapd **Run command** `sudo nano /etc/hostapd/hostapd.conf`
Add lines below to the file
`interface=wlan0`
`driver=nl80211`
`ssid=”enter what you want SSID to be”`
`hw_mode=g`
`channel=1`
`macaddr_acl=0`
`auth_algs=1`
`ignore_broadcast_ssid=0`
`wpa=2`
`wpa_key_mgmt=WPA-PSK`
`wpa_passphrase=”what you want password to be”`
`wpa_pairwise=CCMP`
`rsn_pairwise=CCMP`
**Run command** `sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf`
You should now see the SSID being broardcasst as a hotspot, use Ctrl+C to stop this action
## Step 4 - Run hostapd config at boot **Run command** `sudo nano /etc/default/hostapd`
**Un-comment and change to match the following line** `DAEMON_CONF=”/etc/hostapd/hostapd.conf”`
## Step 5 - Configure dnsmasq **Run command** `sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig` **Run command** `sudo nano /etc/dnsmasq.conf`
**Add lines below to the file**
`interface=wlan0`
`bind-interfaces`
`server=8.8.8.8`
`domain-needed`
`bogus-priv`
`dhcp-range=172.24.1.50,172.24.1.150,12h`
## Step 6 - Setup ipv4 forwarding **Run command** `sudo nano /etc/sysctl.conf` **Un-comment and change to match the following line**
`net.ipv4.ip_forward=1 and save`
**Run command** `sudo sh –c “echo 1 > /proc/sys/net/ipv4/ip_forward”`
## Step 7 - NAT between eth0 and wlan0 **Run command** `sudo iptables –t nat –A POSTROUTING –o eth0 –j MASQUERADE`
**Run command** `sudo iptables –A FORWARD –i eth0 –o wlan0 –m state -- state RELATED,ESTABLISHED –j ACCEPT`
**Run command** `sudo iptables –A FORWARD -i wlan0 –o eth0 –j ACCEPT`
### Confirm configuration **Run command** `sudo iptables –t nat –S` (output should match below)
`-P PREROUTING ACCEPT`
`-P INPUT ACCEPT`
`-P OUTPUT ACCEPT`
`-P POSTROUTING ACCEPT`
`-A POSTROUTING –o eth0 –j MASQUERADE`
**Run command** `sudo iptables –S` (output should match below)
`-P INPUT ACCEPT`
`-P FORWARD ACCEPT`
`-P OUTPUT ACCEPT`
`-A FORWARD –i eth0 –o wlan0 –m state --state RELATED,ESTABLISHED –j ACCEPT`
`-A FORWARD –i wlan0 –o eth0 –j ACCEPT`
## Step 8 - Apply NAT rules and apply to DHCP at boot **Run command** `sudo sh –c “iptables-save > /etc/iptables.ipv4.nat”`
**Run command** `sudo nano /lib/dhcpcd/dhcpcd-hooks/70-ipv4-nat`
**Add lines below to the file**
`iptables-restore < /etc/iptables.ipv4.nat`
### Confirm configuration **Run command** `sudo service hostapd start`
**Run command** `sudo service dnsmasq start`
**Reboot if needed and connect to SSID**
Source: Hackaday.io