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)

name_servers=192.168.188.1

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 169.254.0.0/16 -o wlan0 -j MASQUERADE

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

sudo route add default gw 169.254.9.176 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.

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments