How to enable USB OTG mode on a Pi Zero

Accessing the Internet through usb0

For accessing the internet through usb0 additional settings must be made.

On the Pi Zero, add  a list of nameservers into /etc/resolvconf.conf (which is usually the IP of your internet router)


Next, enable IPv4 forwarding by adding the line

net.ipv4.ip_forward = 1

into /etc/sysctl.conf

After reboot, issue the command:

sudo iptables -t nat -A POSTROUTING -s -o wlan0 -j MASQUERADE

on your host PC, and change the default gateway on the Pi Zero with:

sudo route add default gw usb0

Here, use the IP address which is displayed for usb0 on the host PC. Now you should be able to reach the internet from your Pi Zero.

Notify of
Inline Feedbacks
View all comments