5

I would like to share my 4GLTE within my home network by tethering from my phone through USB. The reason is because I have other devices that need to communicate with each other without the need for Internet.

The following setup works without a problem: Android USB Tethering >Windows PC>Router WAN port

Now, I would like to do the same thing on the raspberry pi so it's as follows:

Android USB Tethering>Raspberry pi USB port---Raspverry pi eth0>Router WAN

The problem seems I don't know how I can share or simply allow traffic from USB to eth0 to pass through.

I followed a lot of tutorials and none of them worked.

The best I found that I understood involved installing bridging utils and setting up the br0 interface but that doesn't work either. I'm thinking the RPI3 has to dish out IPs.

Also, the router [Linksys 4200] does have a USB port and is running DD-WRT but I hear the USB support is for USB modems only. It doesn't work.

  • So from the Pi are you able to browse the web over your 4g connection? – Mohammad Ali Jan 2 '17 at 22:49
  • Yes I can access the internet. – chx101 Jan 2 '17 at 23:37
2

Ok. I was able to get it to work.

Things to note:

  • With current version of Raspbian (JESSE/LITE), the use of /etc/network/interfaces is obsolete. But keep it as it is used by if-up and if-down scripts.

My Setup

  • Gave Raspberry Pi's eth0 a static IP address, connected to router's WAN port.
  • Gave router a static IP address on the same network with the Raspberry Pi as the gateway.
  • Installed dnsmasq [sudo apt-get install dnsmasq] on the Raspberry Pi.
  • Configured packet forwarding [net.ipv4.ip_forward = 1] in /etc/sysctl.conf
  • Configured routing using iptables
    • sudo iptables -t nat -A POSTROUTING -o usb0 -s 192.168.2.0/24 -j MASQUERADE. usb0 is the source interface. One can add a post-up script in /etc/network/interfaces to automate this.

Configuring the static IP address static in /etc/dhcpcd.conf

interface eth0
static ip_address=192.168.0.10/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
| improve this answer | |
  • Also don't forget to enable IP forwarding. – chx101 Jan 3 '17 at 19:39
  • Doesn't bridging do essentially that? – SDsolar Jan 10 '17 at 2:04
  • I've been having trouble with the latest Raspbian version (Pixel). I asked in the forums and it turns out you have to use dhcpd.conf for that. – chx101 Jan 10 '17 at 2:18
  • did you disable DHCP server on the Router and used one on the Raspberry Pi instead? – Rho Phi Nov 24 '18 at 18:19
  • Gave router a static IP address on the same network with the Raspberry Pi as the gateway. Did you do this in the (http?) configuration of the router? Should I expect all routers to accept a setting for what to use as gateway? – Rho Phi Nov 24 '18 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.