Skip to content

Instantly share code, notes, and snippets.

@dulacp
Last active August 29, 2020 05:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dulacp/c9a1c1cf28207b563ddb27bc93290040 to your computer and use it in GitHub Desktop.
Save dulacp/c9a1c1cf28207b563ddb27bc93290040 to your computer and use it in GitHub Desktop.
Configure a Raspberry Pi 3 (Debian Jessie) as a isolated Wi-Fi Access Point

Raspberry as a standolone Wi-Fi Access Point

A reminder on how to configure a Raspberry Pi 3 (Debian Jessie) as a Wi-Fi Access Point

Find the Raspberry Pi ethernet ip-address

Instructions for the macOS platform, little trick to find the raspberry pi ip-address while connected through ethernet.

Connect the Raspberry Pi with an ethernet cable

$ ifconfig

Then look for the bridge100 interface, and get the inet ipaddress (for me 192.168.2.1). You can use nmap to scan for all ips and guess the raspberry pi one.

$ brew install nmap
$ nmap -n -sP 192.168.2.1/24

Install the dependencies

$ ssh pi@<ip-address>
pi@raspberrypi:~ $ sudo apt-get install hostapd dnsmasq

/etc/dhcpcd.conf

Configure a static ip profile for the wlan0 interface. In Debian Jessie, it's done in the /etc/dhcpcd.conf configuration file.

pi@raspberrypi:~ $ cat <<EOT >> /etc/dhcpcd.conf

# define static profile
interface wlan0
static ip_address=192.168.1.23/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
EOT

/etc/dnsmasq.conf

Configure the Dnsmasq service on the wlan0 interface

pi@raspberrypi:~ $ sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
pi@raspberrypi:~ $ sudo touch /etc/dnsmasq.conf
pi@raspberrypi:~ $ sudo tee <<EOT /etc/dnsmasq.conf >/dev/null
interface=wlan0
domain-needed
bogus-priv
dhcp-range=192.168.1.24,192.168.1.250,12h
EOT

/etc/hostapd.conf

pi@raspberrypi:~ $ sudo tee <<EOT /etc/hostadp/hostadp.conf >/dev/null
# Interface Settings
interface=wlan0
driver=nl80211

# Wifi AP Settings
ssid=BlackHat
wpa_passphrase=DontTryMe
hw_mode=g
channel=6
ieee80211n=1

# Encryption Settings
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

# Accept all MAC addresses
macaddr_acl=0

# Require clients to know the network name
#ignore_broadcast_ssid=0

# Enable WMM (QoS)
wmm_enabled=0

EOT

Forward ipv4 and ipv6

pi@raspberrypi:~ $ sudo touch /etc/sysctl.d/50-hostapd.conf
pi@raspberrypi:~ $ sudo tee <<EOT /etc/sysctl.d/50-hostapd.conf >/dev/null
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
EOT

Restart the services

For an unknown reason (yet), restarting the services is not enough, you should reboot your Raspberry Pi in order to make it work with our new configuration.

pi@raspberrypi:~ $ sudo reboot

Then once it's up and running, you need to check if all services are loaded and running too.

pi@raspberrypi:~ $ sudo systemctl status dhcpcd.service
pi@raspberrypi:~ $ sudo systemctl status dnsmasq.service
pi@raspberrypi:~ $ sudo systemctl status hostapd.service
@mchubby
Copy link

mchubby commented Nov 15, 2019

Hi,
Maybe you need to apply the sysctl settings (sysctl -p filename), see https://superuser.com/a/625852

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment