Today, it is tempting to assume that all devices support Wi-Fi, but not all devices are able to connect to the Internet wirelessly. This is where a Raspberry Pi can come in handy: transforming it into a Wi-Fi bridge.
If you want to reuse an old Ethernet desktop computer only and need a quick and easy way to convert a Wi-Fi signal to an Ethernet connection, you can use a Raspberry Pi.
Turn your Raspberry Pi into a Wi-Fi bridge
In this tutorial, you will learn how to turn your Raspberry Pi into a Wi-Fi bridge that connects to your wireless network and converts this signal into a wired connection. You can then connect any device to the Raspberry Pi via an Ethernet cable, and that device will instantly have access to your network.
Before going any further, it should be noted that a device connected to Wi-Fi via your Raspberry Pi will probably not benefit from the same speeds as a device connected directly to your network. However, if it’s not possible to physically connect your Ethernet device only to your router, a Raspberry Pi is a quick, easy, and relatively inexpensive way to get that device online.
What you will need
To complete this tutorial, you will need:
- Raspberry Pi model with Wi-Fi module (Raspberry Pi zero, 3 and 4) running Raspberry Pi OS
- Power cable compatible with your Raspberry Pi
- External keyboard and way to fix it to your Raspberry Pi
- HDMI or micro HDMI cable, depending on your Raspberry Pi model
- External monitor
- Ethernet cable
Update your Pi
If you have not already done so, connect your external keyboard, monitor and any other device to your Raspberry Pi, then connect your Pi to a power source.
Before you start, make sure your Raspberry Pi is up to date. Open a new terminal by clicking on the “Terminal” icon in the Raspbian toolbar, then execute the following commands:
sudo apt update && sudo apt -y upgrade
Configure your network services: install dnsmasq
Then install dnsmasq
, which provides Domain Name System (DNS) caching and a Dynamic Host Configuration Protocol (DHCP) server. Use this package to process DNS queries, which will allow your Raspberry Pi to act as a mini router for an Ethernet device only.
To install dnsmasq, run the following command:
Configure your Ethernet connection
Then configure the eth0 interface to use a static IP address by modifying the “dhcpcd.conf” file. To open this configuration file, run the following command:
sudo nano /etc/dhcpcd.conf
The “dhcpcd.conf” file will now open in the Nano text editor. In this file, add the following:
interface eth0 static ip_address=192.168.220.1/24 static routers=192.168.220.0
Save your changes by pressing Ctrl + O. To close the configuration file, press Ctrl + X.
These modifications can be active by restarting the dhcpcd service:
sudo service dhcpcd restart
Replacement of the dnsmasq configuration file
The dnsmasq package provides a default configuration file, but you must replace it with your own custom settings that tell dnsmasq how to handle DHCP and DNS traffic.
Before making any changes, rename and move the original dnsmasq.conf file:
sudo nano /etc/dnsmasq.conf /etc/dnsmasq.conf.original
Open the replacement configuration file to modify it:
sudo nano /etc/dnsmasq.conf
You should now look at the dnsmasq.conf file in the Nano text editor. In Nano, add the following:
interface=eth0 listen-address=192.168.220.1 bind-interfaces server=8.8.8.8 domain-needed bogus-priv dhcp-range=192.168.220.50,192.168.220.150,12h

Save your changes by pressing Ctrl + O. To close the configuration file, press Ctrl + X.
Enable IP forwarding
Then activate the IP transfer so that your Raspberry Pi can accept network packets from the Ethernet connection and transmit them to your router.
To activate ipv4p IP transfer, modify the configuration file “sysctl.conf”:
sudo nano /etc/sysctl.conf
The “sysctl.conf” file will now launch in the Nano text editor. In this file, find the following line:
Delete the # so that this line becomes:

Save your changes by pressing Ctrl + O. To close the configuration file, press Ctrl + X.
Now put into effect your new configuration file “sysctl.conf”:
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
Start transferring traffic from Ethernet to Wi-Fi
Now that you have properly enabled IP forwarding, you can configure your firewall to forward traffic from the Ethernet interface (eth0) to the Wi-Fi connection. With this redirection in place, any device that connects to the Raspberry Pi via Ethernet will have access to the Wi-Fi connection (wlan0) of the Pi.
Add some rules that indicate how your Raspberry Pi how to transfer all the data packets it receives:
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE sudo iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
Save these new rules:
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
These rules will be emptied each time you restart your Raspberry Pi, so make sure they are 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 output line:
iptables-restore < /etc/iptables.ipv4.nat
Save your changes by pressing Ctrl + O. To close the configuration file, press Ctrl + X.ter. “
Test your Wi-Fi bridge
The last step is to start the dnsmasq service:
sudo service dnsmasq start
You can now test your Wi-Fi gateway! Connect any Ethernet device only to your Raspberry Pi via an Ethernet cable. Your Raspberry Pi will now provide an Internet connection to this Ethernet device only.
Conclusion
You have learned to share the Wi-Fi of your Raspberry Pi with any wired device by converting its Wi-Fi connection to an Ethernet connection. You can also use your Raspberry Pi as a Wi-Fi hotspot for captive portal or as a personal web server. Let us know if this is helpful to you.
Read on for other Raspberry Pi projects you can do yourself.
Related:
Is this article useful?
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version=’2.0′;
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,’script’,
‘https://connect.facebook.net/en_US/fbevents.js’);
fbq(‘init’, ‘400239050508508’);
fbq(‘track’, ‘PageView’);