The Pi joins a Wi-Fi network with internet, for example a phone hotspot, and hands that internet to a router or PC over the network cable. I wrote the first version of this post in 2016 for Raspbian jessie. This is the rewrite for the current Raspberry Pi OS, from the empty SD card to the working bridge.
What you need
- A Raspberry Pi 1 to 4. Tested so far: Raspberry Pi 3B+ (ad).
- Pi 1 and 2: a USB Wi-Fi stick (ad), they have no Wi-Fi.
- A power supply with 5.1 V and at least 2.5 A (see the power supply section below).
- A microSD card (8 GB is enough) and a network cable.
1. Write the SD card
Raspberry Pi OS Lite 32-bit runs on all models from Pi 1 to Pi 4, so one card works for all. Download it from raspberrypi.com together with the .sha256 file.
lsblk sha256sum -c 2026-10-06-raspios-trixie-armhf-lite.img.xz.sha256 xzcat 2026-10-06-raspios-trixie-armhf-lite.img.xz | sudo dd of=/dev/sdX bs=4M conv=fsync status=progress
lsblkshows the card reader, replace/dev/sdXwith it. Everything on it is erased.sha256sum -cchecks the download.conv=fsyncmakesddwait until everything is on the card. It shows no progress during the last minute, that is not a hang.
2. First boot settings
The image sets itself up on the first boot with cloud-init, from the file user-data on the partition bootfs. Replace that file with:
#cloud-config hostname: pi-bridge manage_etc_hosts: true timezone: Europe/Vienna users: - name: pi groups: users,adm,sudo,netdev,video,plugdev,input,gpio shell: /bin/bash lock_passwd: true sudo: ALL=(ALL) NOPASSWD:ALL ssh_authorized_keys: - ssh-ed25519 AAAA... you@laptop enable_ssh: true ssh_pwauth: false runcmd: - [ systemctl, enable, --now, ssh ]
manage_etc_hosts: writes the hostname into/etc/hosts.timezone: your time zone, for the log times.groups:sudofor admin rights,netdevfornmcli, the rest are the usual Pi groups.ssh_authorized_keys: your public key, from~/.ssh/id_ed25519.pub.lock_passwd: trueandssh_pwauth: false: no password, login only with the key.enable_ssh: trueandruncmd: SSH is off by default, this switches it on.
I also put an empty file named ssh on bootfs, the older way to switch SSH on.
3. Connect to the Pi
Connect the Pi directly to your PC, not to your home network. In step 4 the Pi becomes a DHCP server on the cable, and a second DHCP server in the home network would hand out wrong addresses.
The first boot takes 2 to 3 minutes. There is no DHCP on the cable yet, but IPv6 link-local addresses work without it:
ping -6 -c 3 ff02::1%eth0 ssh pi@fe80::xxxx:xxxx:xxxx:xxxx%eth0
ff02::1is “all devices on this link”. The Pi answers with its address.%eth0is the network port of your PC (ip linkshows the name).
4. Set up the bridge
Wi-Fi country:
sudo raspi-config nonint do_wifi_country AT sudo rfkill unblock wifi
ATis the two-letter code of your country (DE, CH, US, …). It sets the allowed channels and transmit power. Without it the Wi-Fi stays off.rfkill unblock wifiswitches the radio on.
Uplink to the hotspot:
sudo nmcli connection add type wifi ifname wlan0 con-name uplink ssid "MyHotspot" \
wifi-sec.key-mgmt wpa-psk wifi-sec.psk "password" \
connection.autoconnect yes ipv6.method disabled
sudo nmcli connection up uplink
wifi-sec.key-mgmt wpa-psk: WPA2/WPA3 with a password, what phones use.connection.autoconnect yes: reconnects after a reboot and when the hotspot comes back.ipv6.method disabled: IPv4 only, the bridge does not need IPv6.
Downlink on the cable:
sudo nmcli connection add type ethernet ifname eth0 con-name downlink \
ipv4.method shared ipv6.method disabled connection.autoconnect yes \
connection.autoconnect-priority 10
sudo nmcli connection up downlink
sudo nmcli connection delete "Wired connection 1"
ipv4.method shareddoes everything the 2016 version did by hand: fixed address10.42.0.1, DHCP and DNS server (dnsmasq), IP forwarding and the NAT rule. Forwarding is set again on every boot.autoconnect-priority 10: wins against the image’s default profile oneth0.Wired connection 1is that default profile, a DHCP client, not needed any more.
The device on the cable now gets an address from 10.42.0.0/24. The Pi is reachable at ssh pi@10.42.0.1.
5. Close the Wi-Fi side
Everybody in the hotspot network could reach the Pi itself, SSH included. /etc/nftables.conf:
#!/usr/sbin/nft -f
table inet bridge_guard
delete table inet bridge_guard
table inet bridge_guard {
chain input {
type filter hook input priority 0; policy accept;
iifname "wlan0" ct state established,related accept
iifname "wlan0" drop
}
}
sudo systemctl enable --now nftables
chain input: only traffic to the Pi itself. Forwarded traffic is not affected.established,related accept: answers to connections the Pi opened.iifname "wlan0" drop: everything else from the Wi-Fi.- The first two lines make the file safe to load again (no “table exists” error).
6. Switch off what is not needed
Less power and no updates over mobile data. Add to /boot/firmware/config.txt and change the existing lines to these values:
dtparam=audio=off camera_auto_detect=0 display_auto_detect=0 #dtoverlay=vc4-kms-v3d dtoverlay=disable-bt [pi3] arm_freq=900 [pi4] arm_freq=1200 [all]
audio,camera_auto_detect,display_auto_detect: off, nothing is connected.#dtoverlay=vc4-kms-v3d: no graphics driver.disable-bt: Bluetooth off.arm_freq: lower CPU clock for Pi 3 (default 1400) and Pi 4 (default 1500 or 1800). Less peak current. The CPU idles while forwarding, the hotspot is the limit.
sudo systemctl disable --now bluetooth hciuart avahi-daemon avahi-daemon.socket sudo systemctl disable --now apt-daily.timer apt-daily-upgrade.timer man-db.timer sudo reboot
avahi-daemonannounces the Pi aspi-bridge.local, also into the hotspot network. On the cable side10.42.0.1is enough.apt-daily*download updates every day. Update by hand when you are on a normal connection.
The power supply
On my first try the Pi disappeared from the cable as soon as the Wi-Fi was up. The red LED was off: undervoltage. On a Pi 3 the Ethernet chip sits on the internal USB bus, which resets first when the voltage drops. The Pi kept running without network.
vcgencmd get_throttled
throttled=0x0: all good.- Last digit 5 (
0x50005): undervoltage right now. - Only the 5 at the front (
0x50000): undervoltage happened since the boot.
Fix: a supply with 5.1 V and at least 2.5 A and a short cable. With my weak supply the slimmed down Pi from step 6 ran stable, with one dip during boot.
Phone hotspot
- Android: switch off “Turn off hotspot automatically”, otherwise the hotspot goes off without clients. The Pi reconnects by itself when it comes back (30 s on the Pi 3B+).
- Pi 3B (without plus) only does 2.4 GHz. iPhone: enable “Maximize Compatibility”.
- Watch your data volume.
Links marked (ad) are Amazon affiliate links. If you buy through them, I get a small commission, the price stays the same for you. As an Amazon Associate I earn from qualifying purchases (Als Amazon-Partner verdiene ich an qualifizierten Verkäufen).

Pingback: Raspberry Pi ‘wifi to ethernet’ bridge | 0ddn1x: tricks with *nix
Hi,
thanks for your tutorial – i followed it but i cant get a ping back. when restarting the networking i always get this:
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
any thoughts (also upc austria)
best
Hi Daniel,
im getting the same some times, but its still working. I could not figure out why, and actually was too lazy since it worked… 🙂
what exactly do you mean with no ping back? Do you try to ping from the outside? what does a traceroute to google gets you?
Best,
Thomas
Hi Thomas,
Firstly thank you so much for taking the time to provide this. Been trying to do this for a while but many other listing on the net are not as clear (for a noob) and fail for me.
All the instructions work as describe except the last command to activate ipv4 forwarding
“sudo echo 1 > /proc/sys/net/ipv4/ip_forward”
i get the following response fro the system
“bash: /proc/sys/net/ipv4/ip_forward: Permission denied”
using Pi3 with latest Jessie and updates and internal WiFi.
Many thanks
Rob
Hi Rob,
thanks for your comment!
I have to say that I did this commands all with root account and thought that putting ‘sudo’ in front of every command will do the trick for everybody.
But I was playing a bit around and this command is indeed wrong.
When you enter “sudo echo 1 > /proc/sys/net/ipv4/ip_forward”, only the part “echo 1” will be executed as sudo. In order to the thing run, change to root with issuing “sudo su” or “sudo bash -c ‘echo 1 > /proc/sys/net/ipv4/ip_forward'”. The last command will execute a new temporary bash with root rights and pass the command “echo 1 > /proc/sys/net/ipv4/ip_forward” to it. So all gets executed as root.
I hope this helps and i will update the page accordingly.
Best,
Thomas
Hello Thomas, Thank you for posting this great how-to for raspberry. I need exactly the same with UPC provider 🙂 It works but my speed is around 300kbps. I use raspberry zero with USB to etherned module, which gives me around 1,5mbps (thats ok for me). My raspberry downloads also 1,5mbps so I should get around 1,5mbps.
My zero connects with wifi to UPC and my router connects by wire to raspi zero usb ethernet. Devices connected to wifi to my router are getting slow speed. What should be the problem? Thank you
Hey Michael,
The problem is that the internal bus connection and the raspberry speed is not enough. The raspberry makes a horrible router :). Problem actually is that USB and Ethernet is brought out with the same chip.
This is just to hard for me, i have a router, i have a pi3 and i have a pc which i need to get Internet over ethernet, so i get internet from pi3’s wlan and share it over the ethernet port to my pc, how do i do that? and i don’t think i need a dhcp server for that just share the connection that is it. Hope someone can help me
Thank you
Hi Jakob,
Actually in your case, wouldn’t it be the best just to buy a inexpensive USB WiFi adapter? You can get them on Amazon for less than 20€ nowadays. If you really need the pi and you have a desktop manager installed, then you can simply bridge the connection via GUI.
Best,
Thomas
Thomas,
Thanks for the excellent write up, works great!
Just a couple of thing that might help.
Instead of the echo 1>/proc/sys/net/ipv4/ip_forward it was easier for me to just edit the sysctl.conf file and uncomment the net.ipv4.ip_forward=1 line
Secondly, to get everything working right, I needed to add in the option domain-name-servers line to the dhcpd.conf entry.
Thanks again!!
Hi Brian,
thx for the feedback, you are right, this can be an issue if you not have the option domain-name-servers set.
Best,
Thomas
Thanks !!!
Hi Thomas,
thanx man! This works great.
I use this to connect to the Ziggo wifi hotspots in the Netherlands.
Great backup at this moment (I am between providers).
I seem to have hit a snag. After following all of the instructions numerous times I can’t seem to get my computers to grab the DNS server of 8.8.8.8 from my RPI’s config file.
Upon setting my computers DNS servers to 8.8.8.8 I still can’t connect to the internet but at least my ethernet connection goes from unable to connect to connected to the internet.
Any Ideas?
If it helps. I am using xfinitywifi hotspots as my wifi connection point. They use 172.20.20.1 as the gateway with an IP address for my Pi’s wifi of 172.20.20.20
Thanks!
Hi Jared,
what does the tracert command show to you? does you PC use the route to the raspi?
Also check the rules of iptables, it may still block some of your requests.
Best,
Thomas
Great, thanks from Pi4 & TP-Link Archer T3U Plus 1300