RaspberryPi WiFi Bridge
Aug 18, 2020
This tutorial will guide you through the steps of setting up a WiFi bridge on a RaspberryPi. The point of this is to forward traffic from an open WiFi network to the ethernet port in order to have “free” internet access in case your main ISP goes down. In my case I’ll be using a nearby xfinitywifi
network and plugging it straight into my existing routers WAN port. If my internet ever goes out I can use this as a backup with little effort.
Requirements
- RaspberryPi (I’m using the 3B)
- Debian 10 (Buster)
- It will be much easier if you do this with a working internet connection.
-
Separate WiFi adapter for better signal strength (the Pi has builtin WiFi if you don’t want an external adapter)
eth0
is the internal ethernet port.wlan0
is the internal wireless adapter which I won’t be using for this guide.wlan1
is my external USB wireless adapter (Alfa).
Tutorial
apt install bridge-utils iptables-persistent
- Disable the dhcpcd service.
systemctl disable dhcpcd.service && systemctl stop dhcpcd.service
- Configure the interfaces file.
/etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
allow-hotplug wlan1
iface wlan1 inet dhcp
wireless-essid xfinitywifi
auto br0
iface br0 inet static
address 10.10.0.1
netmask 255.255.255.0
bridge-ports eth0
bridge-stp off
bridge-fd 0
bridge-waitport 0
If you need to change your MAC address to match one you previously used for Xfinity you can set it in the interfaces file like so: hwaddress ether 00:11:22:33:44:55
- Install and configure DHCP server
apt install isc-dhcp-server
/etc/dhcp/dhcpd.conf
- Uncomment
authoritative;
Add the subnet configuration to the bottom:
subnet 10.10.0.0 netmask 255.255.255.0 {
range 10.10.0.100 10.10.0.200;
option routers 10.10.0.1;
option domain-name-servers 75.75.75.75,1.1.1.1;
}
Change the 75.75.75.75
DNS server to something else (or remove it) if you are not planning to use this with Xfinity.
- Configure the interface for which the DHCP server should hand out leases on.
/etc/default/isc-dhcp-server.conf
- Reboot and the DHCP server should now be running.
- Configure the firewall.
iptables -A FORWARD -o wlan+ -j ACCEPT
iptables -t nat -A POSTROUTING -o wlan+ -j MASQUERADE
iptables-save > /etc/iptables/rules.v4
- Enable forwarding in
/etc/sysctl.conf
net.ipv4.ip_forward=1
sysctl -p
- Plug the RaspberryPi into a router, switch, or PC.
- Go to wifi.xfinity.com and click the “already have an account” link to login or create an account.
- You should now have internet access.
One other thing I plan to do is setup the internal WiFi to connect to my iPhone’s hotspot, so when I turn that on it will use the tether for internet access instead of Xfinity.