Skip to content

Instantly share code, notes, and snippets.

@siard-y
Forked from umardx/Pi3_as_WiFi_AP_Bridge.md
Last active February 5, 2023 14:34
Show Gist options
  • Save siard-y/17af85cb4871294dad574a566f5d42ba to your computer and use it in GitHub Desktop.
Save siard-y/17af85cb4871294dad574a566f5d42ba to your computer and use it in GitHub Desktop.
Using a Raspberry Pi 3 as a Wifi access point and bridge

Using a Raspberry Pi 3 as a Wifi access point and bridge

This turns your Raspberry Pi into an access point for wireless devices. This guide will make your Raspberry Pi 3B share its cabled Ethernet connection wirelessly as an access point with a new SSID.

Forked and edited from this guide: https://www.raspberrypi.org/documentation/configuration/wireless/access-point-bridged.md

Works on Raspberry Pi 3 model B.

1.

First step is to set wifi location to your location with sudo raspi-config under I4:

Localisation options -> Change WLAN Country

2.

Install necessary packages:

$ sudo apt-get install -y bridge-utils hostapd

3.

Uncomment #net.ipv4.ip_forward=1 in /etc/sysctl.conf. This enables ip_forward in the kernel, which is necessary to make a bridge.

sudo nano /etc/sysctl.conf

#net.ipv4.ip_forward=1 -> net.ipv4.ip_forward=1

4.

Configure the network settings to create a bridge with eth0 in /etc/network/interfaces:

sudo nano /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual

auto br0
iface br0 inet dhcp
  bridge_ports eth0

5.

Configure access point by editing the file /etc/hostapd/hostapd.conf:

sudo nano /etc/hostapd/hostapd.conf

country_code=XX
interface=wlan0
driver=nl80211
hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
ssid=<SSID_HERE>
wpa_passphrase=<PASSWORD_HERE>
bridge=br0

Where the XX value of country_code is your ISO 3166-1 alpha-2 (2-character) country code. (Think US, GB, DE etc.).

Change desired SSID and password of your soon-to-be AP after ssid=<SSID_HERE> and wpa_passphrase=<PASSWORD_HERE>, without the < >.

6.

Tell hostapd to use the config set above. Edit /etc/default/hostapd and set:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

7.

Get hostapd to work. Enter these commands consecutively:

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd

8.

Unblock wifi:

rfkill unblock all

9.

Reboot:

sudo reboot

That should do it :)

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