Share an Internet Connection with a Raspberry Pi Zero over USB

A few weeks ago, my friend and I were wandering through Micro Center when we found a stock of Raspberry Pi Zeros, the $5 computer that’s been difficult to acquire but has sparked a “no, seriously, how can I justify not buying a $5 computer?!” chorus of geeks across the globe.

Since picking up the Pi, it’s…well, sat on my desk. I’ve been looking for a fun project (and the time in which to do it), and finally decided to try the Raspberry Pi Zero out as an  OpenVPN server, as it turns out my NETGEAR router doesn’t support the necessary protocols for connecting from my iPhone. I even found this handy post detailing how to go about getting OpenVPN working, which is great.

Perhaps the coolest thing I’ve learned about the Raspberry Pi Zero this evening, though, was the ability to treat it as a USB ethernet gadget, which means I can both power and SSH into the Pi over a single USB connection; as someone who’s purchased his fair share of adapters in his lifetime, it was great to be able to fish a USB type A to micro USB cable out of my giant box o’ cables, plug it in, and connect directly to my tiny little computer.

The next challenge was getting an internet connection; having a tiny Linux computer is great, but if I can’t install any new software it doesn’t do me much good. I placed an order on Amazon for a highly-rated USB 3.0 to RJ-45 adapter and some USB to micro USB adapters (they sell micro USB to RJ-45 adapters as well, but I wanted maximum throughput and reusability, and most of the micro USB adapters didn’t support gigabit ethernet).

While I wait for my Amazon shipment, however, I discovered I can also share my Mac’s internet connection with the Raspberry Pi Zero, enabling me to run updates and otherwise configure the Pi. I found plenty of instructions for PCs doing this, but if you’re attempting to share a connection from your Mac it’s quite simple:

  1. Internet sharing settings for OSXOpen System Preferences, then go to “Sharing”
  2. Find “Internet Sharing”, and ensure that you’re sharing your connection to computers using “RNDIS/Ethernet Gadget”
  3. Check the box next to “Internet Sharing” on the left side of the window (see the screenshot); OSX will ask you to confirm your changes.
  4. Reboot the Pi

Now you should be able to access the internet from your Raspberry Pi Zero, leveraging the USB connection to your Mac. With one cable, I’m able to power, SSH into, and perform software updates on my Raspberry Pi Zero, without the need for additional peripherals. Neat!

3 comments on "Share an Internet Connection with a Raspberry Pi Zero over USB"

  1. John 9 months ago

    I tried to find a way to do it with Windows but couldn’t. Can you help? Thanks!

  2. Brendan 7 months ago

    If you want to do it on windows, go to Control Panel > Network and Internet > Network Connections, and you will see all your internet devices. from there, you should see your Pi Zero (USB Ethernet/RNDIS Gadget). If you click that, then Ctrl-Left Click your computers internet connection, you should be able to right click then bridge the two of them.

  3. sabino passepartout 3 months ago

    THANKS STEVE!
    It worked like a charm

Leave a Reply