Last active
April 16, 2025 16:57
-
-
Save blue-hexagon/51af6fa5c3894e8c2b494d03c5238711 to your computer and use it in GitHub Desktop.
RPi Z USB-OTG Ethernet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# After flashing the image | |
# Open the new filesystem on the SD card | |
# And inside /boot/config.txt, add the following: | |
# dtoverlay=dwc2 | |
# | |
# And in /boot/cmdline.txt, add after `rootwait`: | |
# modules-load=dwc2,g_ether | |
# Then wire up the Pi to HDMI, power source and a keyboard and run the following commands: | |
sudo systemctl enable systemd-networkd | |
sudo systemctl start systemd-networkd | |
sudo mkdir -p /etc/systemd/network | |
# Replace gateway with your hosts IP address. | |
sudo tee /etc/systemd/network/usb0.network > /dev/null <<EOF | |
[Match] | |
Name=usb0 | |
[Network] | |
Address=192.168.0.111/24 | |
Gateway=192.168.0.3 | |
DNS=8.8.8.8 | |
[Route] | |
Destination=192.168.0.0/24 | |
Gateway=192.168.0.3 | |
[Route] | |
Destination=0.0.0.0/0 | |
Gateway=192.168.0.3 | |
EOF | |
sudo tee /etc/systemd/system/usb0-up.service > /dev/null <<EOF | |
[Unit] | |
Description=Force usb0 up at boot | |
Before=network-pre.target | |
Wants=network-pre.target | |
[Service] | |
Type=oneshot | |
ExecStart=/sbin/ip link set usb0 up | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
sudo systemctl enable usb0-up | |
sudo systemctl enable sshd # Modify the conf file in /etc/sshd/... if you wish to change settings for SSH | |
sudo shutdown -r now | |
# That's it! | |
# Plug the RPi Zero into your computers USB port | |
# and an ethernet adapter should show up with the device. | |
# Then: ssh <username>@192.168.0.111 | |
# | |
# NOTE: You might have to download and install | |
# a RNDIS driver (legacy driver) for the purpose. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment