Sunday, 17 May 2020

Using a Raspberry Pi as an Access Point

Most of the simple solutions I found for using a Raspberry Pi to act as an Access Point used NAT and hosted a DHCP server for the WiFi clients.
But.. What if you want to bridge the ethernet and wifi interfaces and let your existing router handle DHCP and routing?

Well here's my solution taken from a few sources.

Update stuff.
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade && sudo reboot now

Set the wifi locale
sudo raspi-config

Install hostapd for the access point
sudo apt-get install hostapd bridge-utils
sudo systemctl stop hostapd

Create a config file for the access point
#sudo nano /etc/hostapd/hostapd.conf
interface=wlan0
bridge=br0
driver=nl80211
ssid=ras
hw_mode=g
channel=1
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=changeme
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Have a test
sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf

Tell hostapd which config file to user
#sudo nano /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"

Enable the service
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd

Stop dhcp from allocating eth0 and wlan0 IP addresses
#sudo nano /etc/dhcpcd.conf
denyinterfaces eth0 wlan0

Add the bridge between the interfaces and let it have a dhcp address
#sudo nano /etc/network/interfaces
auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0

Add a bridge
sudo brctl addbr br0

Reboot -
sudo reboot

You should have br0 on dhcp now

Extras

Add these lines to the /boot/config.txt to disable the onboard hardware
dtoverlay=disable-wifi
dtoverlay=disable-bt


Refs
https://github.com/billz/raspap-webgui/blob/master/includes/hostapd.php
https://www.raspberrypi.org/forums/viewtopic.php?t=193770 http://www.d3noob.org/2018/12/raspberry-pi-setup-as-bridged-wifi.html?m=1 https://davidtavarez.github.io/2018/re4son_kernel_raspberry_pi/
https://elinux.org/RPI-Wireless-Hotspot
https://github.com/raspberrypi/linux/issues/2619
https://github.com/igorpecovnik/hostapd/issues/1
https://github.com/gnab/rtl8812au/issues/6
https://github.com/aircrack-ng/rtl8812au/issues/408

5G config

ssid=raspi
wpa_passphrase=changeme

bridge=br0
country_code=US

interface=wlan0
driver=nl80211

wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP

macaddr_acl=0

logger_syslog=0
logger_syslog_level=4
logger_stdout=-1
logger_stdout_level=0

hw_mode=a
wmm_enabled=1

# N
ieee80211n=1
require_ht=1
ht_capab=[MAX-AMSDU-3839][HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]

# AC
ieee80211ac=1
require_vht=1
ieee80211d=0
ieee80211h=0
vht_capab=[MAX-AMSDU-3839][SHORT-GI-80]
vht_oper_chwidth=1
channel=36
vht_oper_centr_freq_seg0_idx=42


No comments:

Post a Comment