Build a Raspberry Pi Based DIY Router and Wi-Fi AP
Step-by-step guide to setting up OpenWrt on a Raspberry Pi, installing LuCI, and configuring custom USB Wi-Fi adapters for a powerful DIY router.
Build a Raspberry Pi Based DIY Router and Wi-Fi AP
Setting up OpenWrt on a Raspberry Pi allows for a flexible, configurable DIY router or wireless access point. This guide covers installing OpenWrt, configuring LuCI, and adding USB Wi-Fi adapters.
Requirements
- Raspberry Pi: Pi 4 or newer recommended for better performance.
- MicroSD Card: At least 8GB.
- USB Wi-Fi Adapter: Must be compatible with OpenWrt (e.g., Ralink RT5572, MediaTek MT7612U).
- Ethernet Cable: Required for initial setup.
- Power Supply: 5V/3A recommended.
Installing OpenWrt
- Download OpenWrt: Visit the OpenWrt Firmware Selector and download the correct image for your Raspberry Pi model (e.g.,
bcm27xx/bcm2711
for Pi 4). - Flash the Image to a MicroSD Card:
- Windows: Use Rufus or Win32 Disk Imager.
- Mac: Use balenaEtcher.
- Linux: Run:
1 2
sudo dd if=openwrt-image.img of=/dev/sdX bs=2M conv=fsync sync
- Boot OpenWrt: Insert the MicroSD card, connect the Raspberry Pi to your network via Ethernet, and power it on.
Accessing LuCI
- Connect a computer to the Raspberry Pi via Ethernet.
- Open a browser and go to
http://192.168.1.1
. - Login with:
- Username:
root
- No default password (set one immediately).
- Username:
Configuring OpenWrt
Setting Up Network Interfaces
- In LuCI, navigate to Network > Interfaces.
- Configure the LAN interface:
- Set a static IP if needed.
- Assign DHCP settings if acting as a router.
- Save and apply changes.
Enabling Wi-Fi
- Go to Network > Wireless.
- If the internal Wi-Fi adapter is listed, enable it. Otherwise, follow the next section to set up a USB adapter.
Adding a USB Wi-Fi Adapter
- Check for Adapter Recognition:
- SSH into OpenWrt or use the system log in LuCI.
- Run
lsusb
to confirm detection.
- Install Necessary Drivers (via LuCI):
- Go to System > Software.
- Click Update lists.
- Search for and install drivers based on chipset:
- Ralink RT5572: Install
kmod-rt2800-usb
. - MediaTek MT7612U: Install
kmod-mt76x2u
.
- Ralink RT5572: Install
- Configure Wi-Fi:
- Go to Network > Wireless.
- Click Add to configure a new Wi-Fi network.
- Set SSID, encryption (WPA2/WPA3 recommended), and password.
- Assign the network to LAN or another firewall zone.
- Save and apply changes.
Final Steps
- Set up a firewall under Network > Firewall.
- Enable remote SSH/Web access under System > Administration.
- If using this setup as a router, configure DHCP and DNS under Network > DHCP and DNS.
Your Raspberry Pi is now a fully functional OpenWrt-powered router.
This post is licensed under CC BY 4.0 by the author.