Running a Raspberry Pi Wi-Fi Bridge

by SuitableBat9 in Circuits > Raspberry Pi

87 Views, 1 Favorites, 0 Comments

Running a Raspberry Pi Wi-Fi Bridge

Raspberry-Pi-WiFi-Bridge.png

A Raspberry Pi Wi-Fi bridge is one of the best ways of providing internet access to a device that only supports an Ethernet connection.

In this tutorial, we will show you how to setup a Wi-Fi bridge using network manager on your Raspberry Pi. Network Manager is a useful tool that makes managing connections a straightforward process.

You will need to keep in mind that you will not see speeds as good as what you would with a direct connection to your router. As there is some overhead with the connection having to run through the Raspberry Pi.

This bridge allows you to easily share your Wi-Fi connection with any connected ethernet device. Thanks to Network Manager, this whole process is made relatively easy.

Supplies

Remember to do this tutorial you will need either a Wi-Fi dongle or a Raspberry Pi 3 with the inbuilt Wi-Fi module.


Wi-Fi ( Amazon | SunFounder )

Preparing Your Raspberry Pi

Before setting your Raspberry Pi to act as a Wi-Fi bridge, we will want to ensure that the operating system is up-to-date.

You can update the package list and upgrade any out-of-date packages by running the following commands.

sudo apt update
sudo apt upgrade

Finding Your Ethernet Device Name

Once you have a Wi-Fi connection set up on your Raspberry Pi, we will need to get the name of your ethernet adapter.

Typically, the Ethernet device is called “eth0” but this isn’t always the case. Luckily, we can double-check by using the “ifconfig” command.

ifconfig

You will get a list of devices like we have shown below using this command. Look for your ethernet connection, then continue. In our example, this Ethernet device has the name “eth0” as expected.

eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether d8:3a:dd:a2:06:0f txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 106

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 16 bytes 2038 (1.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 2038 (1.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.34 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::f0de:cd26:d200:e53f prefixlen 64 scopeid 0x20<link>
inet6 2406:2d40:4114:f200:9f3e:4293:b1f:8d94 prefixlen 64 scopeid 0x0<global>
inet6 fd0b:3f38:7421:cd40:aa94:eed9:534f:b056 prefixlen 64 scopeid 0x0<global>
ether d8:3a:dd:a2:06:10 txqueuelen 1000 (Ethernet)
RX packets 634 bytes 205247 (200.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 288 bytes 40214 (39.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Creating the Wi-Fi to Ethernet Bridge on Your Raspberry Pi

Once you know the name of your Raspberry Pi’s ethernet device you can continue with setting up a Wi-Fi bridge. Thanks to use using the Network Manager, creating the Wi-Fi bridge is as simple as using the following command within the terminal.

  1. <INTERFACE>: You must replace this with the device name for your ethernet connection. Typically, this will be “eth0“.
sudo nmcli c add con-name wifibridge type ethernet ifname <INTERFACE> ipv4.method shared ipv6.method ignore

Once you have created the new connection, you must turn it on by using the following command in the terminal.

After enabling this bridge, your Raspberry Pi’s Wi-Fi will immediately begin to be shared through the ethernet connection. If you have a device connected, you should now have access to the internet. The device will also have a local IP address handed to it by the Pi.

sudo nmcli con up wifibridge

You can check that the Wi-Fi bridge is active from your Pi by using the following command.

nmcli con show

This command will show you a list of connections on your Pi. You should see a connection labeled “wifibridge” and that it is using the “eth0” device.

NAME UUID TYPE DEVICE
wifibridge 0120ca82-63e9-403d-aa45-c31ed08bec53 ethernet eth0
preconfigured 6e07c33c-9764-4145-af3f-49875c8a9342 wifi wlan0
lo a54edcc4-0ffa-4090-a2b3-081905aee1c5 loopback lo
Wired connection 1 9d27eb3e-7657-3a54-ad8a-344cb4bb56e3 ethernet --