Steve Grunwell

Open-source contributor, speaker, and electronics tinkerer

A homemade pie with sparklers sticking out of the top

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!

Previous

Automatically Set WordPress Thumbnail Sizes When Switching Themes

Next

Steal this Idea: “Be Your Own Barista” Bars

6 Comments

  1. John

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

  2. Brendan

    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

    THANKS STEVE!
    It worked like a charm

  4. Great – still works like a charm!

  5. stu

    Yep, charms here too. Thanks.

  6. Rob

    Hi
    I just found your post. Although somewhat dated, I hope I reach you with this question: Did you also have to setup the Mac’s network connection, DHCP (or not) etc?
    I’ve been SSHing to a Pi from my Mac’s ethernet to get my feet wet. However, I can only get internet access (i.e. to do apt updates/upgrades) connected directly to the ethernet LAN port on my wireless router.
    Other articles I have looked for always have network setup for internet sharing…. but none of those instructions have resulted in internet access from the Mac.
    Yours is the first article I’ve found that doesn’t mention anything about network setup (or config settings on the Pi)
    I’ll try your approach this wknd.
    Cheers,
    Rob

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Be excellent to each other.