I connected a raspberry pi 0 to a raspberry pi 4b+ via USB and i would like to know how can i share the internet connection. The pi4 is connected to the internet via the ethernet port. P.S.: I did all the configuration needed for the pi0 (loaded dwc2, gether and the rest), also both pi run lattest version of raspbian

2 Answers 2


This is how I achieved it:

on the pi4

to /etc/dhcpcd.conf [before the first line that starts with interface or to the end of the file, if no such lines exists]

denyinterfaces eth0 usb0

to the end of the file, add

interface br0

create the following files in /etc/systemd/network - note, the names of the files are unimportant, the important thing is the extension (.netdev/.network) and the content









enable systemd-networkd

systemctl enable systemd-networkd

Thats it for the pi4

on the pi 0

add the following the end of /etc/dhcpcd.conf

interface usb0

Though, I've done the following (as fallback in case DHCP fails)

profile static_usb0
static ip_address=
static routers=
static domain_name_servers=

interface usb0
fallback static_usb0

Obviously, you'd need to use your own local ip address, router and dns address as required

  • i tryed this 2 times , one time i couldnt connect my pi4 to the internet, and the other one i got the pi 0 connected to the internet, but the pi 4 could connect again
    – F G B
    May 31, 2021 at 15:57
  • Not sure what part you did wrong then - works great for me Jun 1, 2021 at 6:49

I tried the Solution from @Jaromanda X but unfortunately it didn't work for me. This instruction helped me very much: Cannot get internet from pizero connected to pi3 via USB (eth0 to usb0)

This is what I did:

enter image description here

on the pi 3/4

  1. The RaspberryPi needs a static IP-adress. You can either configure it in your Router (what I did) or you can set a static IP-adress in /etc/dhcpcd.conf like this:
# [/etc/dhcpcd.conf]

interface eth0
static_routers=  # The IP-address of your router
static domain_name_servers=
static ip_address=192.168.178.XX/24  # replace XX through any IP-address you want
  1. You need a network interface for your USB-connection which you can also add in /etc/dhcpcd.conf:
# [/etc/dhcpcd.conf]

# Subnet for usb0 (where the piZero is plugged)
interface usb0
static ip_address=
  1. enable IP-forwarding by uncommenting/adding the following in /etc/sysctl.conf:
# [/etc/sysctl.conf]

  1. Configure the firewall of the RaspberryPi by executing the following commands in the terminal:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE  
sudo iptables -A FORWARD -i eth0 -o usb0 -m state --state RELATED,ESTABLISHED -j ACCEPT  
sudo iptables -A FORWARD -i usb0 -o eth0 -j ACCEPT

Consider that these changes are only temporary. I put these commands into /etc/rc.local so that they are executed at every start of the pi. (I don't know if this is the best and recommended way to make the firewall settings persistent but it works)

on the pi zero

Setup the USB-inteface in /etc/dhcpcd.conf like this:

interface usb0
static ip_address=
static routers=
static domain_name_servers=  # (Google DNS)

I also enabled dwc2 but I'm not sure if it's required.

Now you should be able to ping other devices in the internet or in your local network (e.g. 192.168.178.xx) from your RaspberryPi zero.

Consider that you are not able to access the RaspberryPi Zero from your local network because it is in the subnet (10.0.11.xx). To solve this I added a static route in my FritzBox (Home Network --> Network --> Network Settings --> IPv4-routes)

fritzbox configuration of static route

I used this to setup the clusterhat manually. It was very difficult to create a setup like this because there are barely tutorials on the internet according to the clusterhat respectively to connecting a RaspberryPi zero without WLAN to another RaspberryPi via USB.

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Mar 15, 2023 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.