Ethernet-to-Wifi bridge (access point) on a Raspberry Pi 1B
This is a tutorial on how to use a Raspberry Pi to make an existing ethernet network visible to wifi clients. This is known as an access point, which bridges an ethernet network to a wifi network.
Note: The Raspberry Pi will act strictly as a bridge. DHCP will be handled by the existing DHCP server on the ethernet network.
This tutorial is using a Raspberry Pi 1 Model B and a RaLink RT5370-based USB-Wifi dongle.
(Search amazon.com for "rt5370".)
Note: plugging in the Wifi dongle may reboot the Pi. I recommend you insert the dongle before booting up your Pi.
Note: this tutorial was previously based on a RTL8188CUS-based USB-Wifi dongle (sold as an Edimax EW-7811Un on amazon.com), but I ran into stability and performance problems.
Grab the latest Raspbian Lite from https://www.raspberrypi.org/downloads/ and burn it to an SD card.
On my Linux box, that's
pv 2019-09-26-raspbian-buster-lite.img > /dev/mmcblk0.
- Boot the Pi
- Login as
- Localisation Options -> Change Locale (to en_US.UTF-8)
- Localisation Options -> Change Timezone (to America / Chicago)
- Localisation Options -> Keyboard Layout (to Generic 104, Other -> English US)
- Interfacing Options -> SSH (enable)
- Make note of the IP address (
- Login via ssh as
- Change root's password (run
- Append your
- Login via ssh as
deluser pi && rm -rf /home/pi
Create the bridge
apt-get update apt-get install bridge-utils
systemctl disable dhcpcd.service
Note: on systems which predated
systemd, this would have been
update-rc.d dhcpcd disable.
wlan0 together, and give the Pi a static IP address (in my case,
iface eth0 inet manual iface wlan0 inet manual iface br0 inet static bridge_ports eth0 wlan0 address 192.168.4.254 broadcast 192.168.4.255 netmask 255.255.255.0 gateway 192.168.4.1 auto br0
For some reason, adding
wlan0 to the bridge fails initially, but succeeds a short time later.
As a work-around, add this to
/etc/rc.local (before the
exit 0 line):
# Adding wlan0 to the bridge fails initially. # Keep trying until it succeeds. attempt=0 while [ $attempt -lt 30 ] do if brctl show br0 | grep -q wlan0 then if [ $attempt > 1 ] then echo "Successfully added wlan0 to br0." fi break else attempt=$(( $attempt + 1 )) echo "Adding wlan0 to br0 (attempt $attempt of 30)." brctl addif br0 wlan0 > /dev/null 2>&1 || true sleep 1 fi done
Reboot, then log back in via
apt-get install hostapd
Thanks to https://wiki.gentoo.org/wiki/Hostapd
# the interface used by the AP interface=wlan0 # g simply means 2.4GHz band hw_mode=g # limit the frequencies used to those allowed in the country ieee80211d=1 # the country code country_code=US # 802.11n support ieee80211n=1 # QoS support wmm_enabled=1 # 1=wpa, 2=wep, 3=both auth_algs=1 # WPA2 only wpa=2 wpa_key_mgmt=WPA-PSK rsn_pairwise=CCMP # work-around for "deauthenticated due to inactivity" errors: disassoc_low_ack=0 # edit these values as needed: channel=11 ssid=somename wpa_passphrase=somepassword
Edit the Wifi channel, SSID name, and WPA passphrase as needed.
Enable and start
systemctl unmask hostapd.service systemctl enable hostapd.service systemctl start hostapd.service
Disable unused services
systemctl disable avahi-daemon
This will save a bit of wear-and-tear on your SD card. Add this to
apt-get update apt-get dist-upgrade reboot
apt-get install openntpd