If you want to repurpose an old, Ethernet-only desktop computer and need a quick and easy way to convert a Wi-Fi signal into an Ethernet connection, you can use a Raspberry Pi.

Turn your Raspberry Pi into a Wi-Fi bridge

In this tutorial you’ll learn how to transform your Raspberry Pi into a Wi-Fi bridge that connects to your network wirelessly and converts this signal into a wired connection. You can then attach any device to the Raspberry Pi via an Ethernet cable, and that device will instantly have access to your network. Before going further, it’s worth noting that a device that’s connected to Wi-Fi via your Raspberry Pi is unlikely to enjoy the same speeds as a device that’s connected to your network directly. However, if it’s not possible to physically connect your Ethernet-only device to your router, then a Raspberry Pi is a quick, easy and relatively inexpensive way to get that device online.

What you’ll need

To complete this tutorial, you’ll need:

Raspberry Pi model with Wi-Fi module (Raspberry Pi zero, 3 and 4) running Raspberry Pi OSPower cable that’s compatible with your Raspberry PiExternal keyboard and a way to attach it to your Raspberry PiHDMI or micro HDMI cable, depending on your model of Raspberry PiExternal monitorEthernet cable

Update your Pi

If you haven’t already, attach your external keyboard, monitor, and any other peripherals to your Raspberry Pi, then attach your Pi to a power source. Before you begin, check that your Raspberry Pi is up to date. Open a new Terminal by clicking the “Terminal” icon in Raspbian’s toolbar, then run the following commands:

Set up your network services: installing dnsmasq

Next, install dnsmasq, which provides Domain Name System (DNS) caching and a Dynamic Host Configuration Protocol (DHCP) server. Use this package to process DNS requests, which will allow your Raspberry Pi to act as a mini-router for an Ethernet-only device. To install dnsmasq, run the following command:

Configure your ethernet connection

Next, set up the eth0 interface to use a static IP address by modifying the “dhcpcd.conf” file. To open this configuration file, run the following command: The “dhcpcd.conf” file will now open in the Nano text editor. In this file, add the following: Save your changes by pressing Ctrl + O. To close the configuration file, press Ctrl + X. These changes can be live by restarting the dhcpcd service:

Replacing the dnsmasq configuration file

The dnsmasq package provides a default configuration file, but you need to replace this with your own custom settings that tell dnsmasq how to handle DHCP and DNS traffic. Before making any changes, rename and relocate the original dnsmasq.conf file: Open the replacement configuration file for editing: You should now be looking at the dnsmasq.conf file in the Nano text editor. In Nano, add the following: Save your changes, by pressing Ctrl + O. To close the configuration file, press Ctrl + X.

Enable IP forwarding

Next, enable IP forwarding so that your Raspberry Pi can accept network packets from the Ethernet connection and forward them to your router. To enable ipv4p IP forwarding, edit the “sysctl.conf” configuration file: The “sysctl.conf” file will now launch in the Nano text editor. In this file, find the following line: Remove the # so that this line becomes: Save your changes by pressing Ctrl + O. To close the configuration file, press Ctrl + X. Now, bring your new “sysctl.conf” configuration file into effect:

Start forwarding traffic from Ethernet to Wi-Fi

Now that you have successfully enabled IP forwarding, you can configure your firewall to forward traffic from the Ethernet interface (eth0) to the Wi-Fi connection. With this forwarding in place, any device that connects to the Raspberry Pi over Ethernet will gain access to the Pi’s Wi-Fi (wlan0) connection. Add some rules that tell how your Raspberry Pi how to forward all the data packets that it receives: Save these new rules: These rules will get flushed every time your Raspberry Pi reboots, so make sure they’re reloaded at startup. Define what happens at startup by editing the “rc.local” file: The rc.local file will now open in the Nano text editor. In the editor, find the following: Add the following directly above the “exit” line: Save your changes by pressing Ctrl + O. To close the configuration file, press Ctrl + X.ter.”

Test your Wi-Fi bridge

The final step is starting the dnsmasq service: You can now put your Wi-Fi bridge to the test! Attach any Ethernet-only device to your Raspberry Pi via an Ethernet cable. Your Raspberry Pi will now provide an Internet connection to this Ethernet-only device.

Conclusion

You have learned how to share your Raspberry Pi’s Wi-Fi with any wired device by converting its Wi-Fi connection into an Ethernet connection. You can also use your Raspberry Pi as a Captive Portal Wi-Fi hotspot or as a personal web server. Let us know if this is useful to you. Read on for other Raspberry Pi projects you can do on your own.