Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Adafruit Logo
0

Turning your Raspberry Pi Zero into a USB Gadget

Image for user adafruit2
published December 24, 2015, last edited May 29, 2025
last major update April 22, 2024
Save Link Note Download
171
Beginner
Skill guide

Ethernet Tweaks

Using mDNS/Bonjour Naming

If you don't want to have to remember your Pi's IP address, you don't have to! Jessie Lite includes and automatically enablesavahi which lets you use names like raspberrypi.local

If for some reason its not activated, we have a full tutorial that will help you get set up.

Don't forget, Windows doesn't have native Bonjour support, so download & install Bonjour Print Services!
(check the tutorial above for a link on where/how to install, you only have to do it once)

So, after you get ping'ing working...try

ping raspberrypi.local
ping raspberrypi.local
raspberry_pi_avahi.png

Or for ssh, it's also perfectly fine:

raspberry_pi_localssh.png

Sharing Network Access to Your Pi

On OS X, open theNetwork tab of SystemPreferences.

raspberry_pi_osx_network_system_pref.png

Select the existing CDC orRNDIS USB connection to your Raspberry Pi by selecting Manually from theConfigure IPv4 menu. Use192.168.2.1 for theIP Address, and255.255.255.0 for theSubnet Mask. ClickApply to save your changes.

raspberry_pi_cdc_network_osx.png

Then, open theSharing tab in System Preferences.

raspberry_pi_share_osx_system_pref.png

Turn onInternet Sharing to share your existing internet connection from Wi-Fi or ethernet with theCDC orRNDIS Raspberry Pi connection.

raspberry_pi_cdc-network-osx-enable.png

Edit your /etc/network/interfaces file on your Pi to match the one below.

# interfaces(5) file used by ifup(8) and ifdown(8)# Please note that this file is written to be used with dhcpcd# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'# Include files from /etc/network/interfaces.d:source-directory /etc/network/interfaces.dauto lo usb0iface lo inet loopbackiface eth0 inet manualallow-hotplug wlan0iface wlan0 inet manual    wpa-conf /etc/wpa_supplicant/wpa_supplicant.confallow-hotplug wlan1iface wlan1 inet manual    wpa-conf /etc/wpa_supplicant/wpa_supplicant.confallow-hotplug usb0iface usb0 inet manual
# interfaces(5) file used by ifup(8) and ifdown(8)# Please note that this file is written to be used with dhcpcd# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'# Include files from /etc/network/interfaces.d:source-directory /etc/network/interfaces.dauto lo usb0iface lo inet loopbackiface eth0 inet manualallow-hotplug wlan0iface wlan0 inet manual    wpa-conf /etc/wpa_supplicant/wpa_supplicant.confallow-hotplug wlan1iface wlan1 inet manual    wpa-conf /etc/wpa_supplicant/wpa_supplicant.confallow-hotplug usb0iface usb0 inet manual

The important lines are:

auto lo usb0
auto lo usb0

and also:

allow-hotplug usb0iface usb0 inet manual
allow-hotplug usb0iface usb0 inet manual

Restart your Pi usingsudo reboot, and SSH back in to it using ssh[email protected]. You can then attempt toping google.com.

$ ping -c 5 google.comPING google.com (216.58.219.238): 56 data bytes64 bytes from 216.58.219.238: icmp_seq=0 ttl=55 time=20.975 ms64 bytes from 216.58.219.238: icmp_seq=1 ttl=55 time=20.904 ms64 bytes from 216.58.219.238: icmp_seq=2 ttl=55 time=20.646 ms64 bytes from 216.58.219.238: icmp_seq=3 ttl=55 time=20.401 ms64 bytes from 216.58.219.238: icmp_seq=4 ttl=55 time=20.379 ms--- google.com ping statistics ---5 packets transmitted, 5 packets received, 0.0% packet lossround-trip min/avg/max/stddev = 20.379/20.661/20.975/0.247 ms
$ ping -c 5 google.comPING google.com (216.58.219.238): 56 data bytes64 bytes from 216.58.219.238: icmp_seq=0 ttl=55 time=20.975 ms64 bytes from 216.58.219.238: icmp_seq=1 ttl=55 time=20.904 ms64 bytes from 216.58.219.238: icmp_seq=2 ttl=55 time=20.646 ms64 bytes from 216.58.219.238: icmp_seq=3 ttl=55 time=20.401 ms64 bytes from 216.58.219.238: icmp_seq=4 ttl=55 time=20.379 ms--- google.com ping statistics ---5 packets transmitted, 5 packets received, 0.0% packet lossround-trip min/avg/max/stddev = 20.379/20.661/20.975/0.247 ms

If using Windows, openNetwork and Sharing Center and click onChange Adapter Settings

raspberry_pi_Screenshot_2016-11-22_18.06.14.jpg

Right-Click on your internet connection and selectProperties.

raspberry_pi_Screenshot_2016-11-22_18.08.55.jpg

Select theSharing tab. Click the checkbox if it is not already checked. Then click onSelect a private network connection and selectPiZero from the dropdown. 

raspberry_pi_Screenshot_2016-11-22_18.21.51.jpg
raspberry_pi_Screenshot_2016-11-22_18.24.59.jpg

Restart your Pi usingsudo reboot, and SSH back in to it using ssh[email protected]. You can then attempt toping google.com.

$ ping -c 5 google.comPING google.com (216.58.219.238): 56 data bytes64 bytes from 216.58.219.238: icmp_seq=0 ttl=55 time=20.975 ms64 bytes from 216.58.219.238: icmp_seq=1 ttl=55 time=20.904 ms64 bytes from 216.58.219.238: icmp_seq=2 ttl=55 time=20.646 ms64 bytes from 216.58.219.238: icmp_seq=3 ttl=55 time=20.401 ms64 bytes from 216.58.219.238: icmp_seq=4 ttl=55 time=20.379 ms--- google.com ping statistics ---5 packets transmitted, 5 packets received, 0.0% packet lossround-trip min/avg/max/stddev = 20.379/20.661/20.975/0.247 ms
$ ping -c 5 google.comPING google.com (216.58.219.238): 56 data bytes64 bytes from 216.58.219.238: icmp_seq=0 ttl=55 time=20.975 ms64 bytes from 216.58.219.238: icmp_seq=1 ttl=55 time=20.904 ms64 bytes from 216.58.219.238: icmp_seq=2 ttl=55 time=20.646 ms64 bytes from 216.58.219.238: icmp_seq=3 ttl=55 time=20.401 ms64 bytes from 216.58.219.238: icmp_seq=4 ttl=55 time=20.379 ms--- google.com ping statistics ---5 packets transmitted, 5 packets received, 0.0% packet lossround-trip min/avg/max/stddev = 20.379/20.661/20.975/0.247 ms

Page last edited April 22, 2024

Text editor powered bytinymce.

Related Guides
Search

Search

Categories

[8]ページ先頭

©2009-2025 Movatter.jp