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

  1. apt install bridge-utils iptables-persistent
  2. Disable the dhcpcd service.
    • systemctl disable dhcpcd.service && systemctl stop dhcpcd.service
  3. 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

  1. 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.

  1. Configure the interface for which the DHCP server should hand out leases on.
    • /etc/default/isc-dhcp-server.conf
  2. Reboot and the DHCP server should now be running.
  3. 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
  4. Enable forwarding in /etc/sysctl.conf
    • net.ipv4.ip_forward=1
    • sysctl -p
  5. Plug the RaspberryPi into a router, switch, or PC.
  6. Go to wifi.xfinity.com and click the “already have an account” link to login or create an account.
  7. 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.

raspberrypi Related
    Comments