2

I'm running a Raspberry Pi 2 with Raspbian as a central controller. I have an external modem that feeds the Pi an internet connection through USB, and now I'm trying to reverse tether the rooted Android (Lollipop 5.1) tablet. The modem I'm using does not have an ethernet port, only USB.

What I'm trying to accomplish is getting an internet connection from a USB modem to broadcast over a WiFi dongle (Realtek 8188) so that other devices can connect and use its internet. My issue is I can't manage to get Android to pull internet from the Pi.

I've searched Google and I managed to find articles and guides that looked like it worked for a lot of people. Here are some of the ones I've read and tried:

https://ajasmin.wordpress.com/2011/07/24/android-usb-tethering-with-a-linux-pc/

https://help.ubuntu.com/community/NetworkConnectionBridge

https://android.stackexchange.com/questions/2298/how-to-set-up-reverse-tethering-over-usb

http://www.ce3c.be/256-using-a-raspberry-pi-as-a-wifi-repeater/

I've tried to change a few things in those guides to fit to what I needed (usb0 instead of eth0), but I haven't had the best luck in getting it to work. I've also tried bridging usb0 and usb1 (the modem and the tablet).

The modem is currently giving a working internet connection (ping works on 8.8.8.8 as well as www.google.com). Where I'm at right now is I have a wireless network that other devices can detect. But when I try to connect to the Pi WiFi, the device cannot obtain an IP address and fails to connect.

So the core of my question, how can I bridge the connection from the USB modem to my USB connected Android using the Pi?

Configuration information:

/etc/network/interfaces:

auto lo
iface lo inet loopback

auto eth0

iface wlan0 inet manual

allow-hotplug usb0
iface usb0 inet static
address 192.168.1.100
gateway 100.78.63.83
netmask 255.255.255.0
up sysctl -w net.ipv4.up_forward=1
up route add default gw 100.78.63.83 dev usb0

up iptables-restore < /etc/iptables.ipv4.nat

/etc/hostapd/hostapd.conf:

interface=wlan0

ssid=mypie
channel=3
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

driver=rtl871xdrv
ieee80211n=1
hw_mode=g
device_name=RTL8192CU
manufacturer=Realtek

iptables:

*filter
:INPUT ACCEPT [2:152]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2:152]
-A FORWARD -i usb0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o usb0 -j ACCEPT
COMMIT
*nat
:PREROUTING ACCEPT [98:7644]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [4:304]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o usb0 -j MASQUERADE
COMMIT

ifconfig:

eth0      Link encap:Ethernet  HWaddr b8:27:eb:ec:45:5c
          inet addr:169.254.67.226  Bcast:169.254.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:788 errors:0 dropped:0 overruns:0 frame:0
          TX packets:411 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:71626 (69.9 KiB)  TX bytes:76680 (74.8 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1104 (1.0 KiB)  TX bytes:1104 (1.0 KiB)

usb0      Link encap:Ethernet  HWaddr 52:48:a3:73:34:64
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:74 errors:0 dropped:0 overruns:0 frame:0
          TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5721 (5.5 KiB)  TX bytes:14094 (13.7 KiB)

wlan0     Link encap:Ethernet  HWaddr 08:10:77:99:92:1f
          inet addr:169.254.177.179  Bcast:169.254.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:111 errors:0 dropped:37 overruns:0 frame:0
          TX packets:67 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:15648 (15.2 KiB)  TX bytes:18760 (18.3 KiB)

/etc/udhcpd.conf (cut out most of unused lines):

start           192.168.0.20    #default: 192.168.0.20
end             192.168.0.254   #default: 192.168.0.254

interface       wlan0           #default: eth0

max_leases      254             #default: 254

remaining       yes             #default: yes

auto_time       7200            #default: 7200 (2 hours)

decline_time    3600            #default: 3600 (1 hour)

opt     dns     198.224.155.135 8.8.8.8
option  subnet  255.255.255.0
opt     router  192.168.1.100
opt     wins    192.168.10.10
option  dns     129.219.13.81   # appened to above DNS servers for a total of 3
option  domain  local
option  lease   864000          # 10 days of seconds
2
  • Your halfway there (ish). Assuming that the USB connection works from the pi and you can access the internet from it, You still need to assign a static IP to your wlan0 (based upon your DHCP address pool, you'd use 192.168.0.1/255.255.255.0) Also, the pi handles forwarding packets between interfaces. So your correct 'router' in udhcp.conf needs to be the IP address of wlan0 NOT usb0 ('192.168.1.100' is wrong). You will also need to make sure that udhcpd starts at boot time. There might be other issues in your config. But those are the ones that jump off the page. Commented Jul 7, 2015 at 3:17
  • Also looks like your usb0 setup makes no sense. If your netmask is 255.255.255.0 then your IP address needs to match on the first 3 numbers. (So your usb0 IP address needs to start with 100.78.63) Can you post the working IP settings when the USB adapter is plugged into a PC/mac? Commented Jul 7, 2015 at 3:31

1 Answer 1

2

Yes it's possible to bridge your connection. Probably the most useful long-term solution would be to set your pi up as a wireless router using hostapd. There's a pretty good guide on that here.

Or you could connect the tablet to the pi via Ethernet and it up as a full on router.

Or you could go one further and make an Onion router ;-)

Note- You will probably not be able to connect the Android via USB. You'll want to use ethernet or wifi to connect the tablet to the pi.

1
  • Thank you for your reply! We're changing how we're going about getting the connection to work. We're still limited to USB from our modem to the Pi, and we're using the same WiFi dongle from the first guide you've linked above. We've managed to turn the dongle into an access point and other devices can detect it. When we attempt to connect to it, it's stuck obtaining an IP address and eventually fails to connect. Do you have any idea what the problem might be?
    – TheAdrian
    Commented Jul 5, 2015 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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