USB Internet

From postmarketOS
Revision as of 08:18, 23 September 2017 by Ollieparanoid (talk | contribs) (Add link to wifi)
Jump to: navigation, search

You can enable internet through the USB cable when WiFi doesn't work yet on your device. For this to work you set your host machine as gateway for your phone and let your host machine do network address translation for the phone.

On your phone:

$ sudo route add default gw
$ echo "nameserver" >> /etc/resolv.conf
Substitute for your own internal DNS server if you want.

On the host machine:

$ echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/null
$ sudo iptables -P FORWARD ACCEPT
$ sudo iptables -A POSTROUTING -t nat -j MASQUERADE -s

This will enable IPv4 forwarding on your host machine which basically lets it function as a router. The postrouting command will make the kernel on the host translate the packets between the phone network and your normal network on the host machine.

You can now verify the internet connection on your phone my pinging something