Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[gentoo-user] Reverse Tethering - How to?

104 views
Skip to first unread message

Helmut Jarausch

unread,
Sep 17, 2014, 5:30:02 AM9/17/14
to
Hi,

how do I need to configure my Gentoo box to allow for reverse tethering
from my (rooted) Android phone?

Many thanks for a hint,
Helmut

J. Roeleveld

unread,
Sep 17, 2014, 5:50:02 AM9/17/14
to
What do you mean with "reverse tethering"?
That your mobile uses the network connection of your Gentoo box, or your
Gentoo box the network connection of your mobile?

Generally, the device sharing the connection needs to play WIFI Access Point.

--
Joost

Helmut Jarausch

unread,
Sep 17, 2014, 5:50:02 AM9/17/14
to
On 09/17/2014 11:43:28 AM, J. Roeleveld wrote:
>
> On Wednesday, September 17, 2014 11:24:36 AM Helmut Jarausch wrote:
> > Hi,
> >
> > how do I need to configure my Gentoo box to allow for reverse
> tethering
> > from my (rooted) Android phone?
> >
> > Many thanks for a hint,
> > Helmut
>
> What do you mean with "reverse tethering"?
> That your mobile uses the network connection of your Gentoo box, or
> your
> Gentoo box the network connection of your mobile?

My mobile should be able to use the (wired) network connection of my
Gentoo box.

>
> Generally, the device sharing the connection needs to play WIFI
> Access Point.
>

How to do that on Gentoo?

Thanks,
Helmut

J. Roeleveld

unread,
Sep 17, 2014, 6:00:02 AM9/17/14
to

On Wednesday, September 17, 2014 11:46:12 AM Helmut Jarausch wrote:
> On 09/17/2014 11:43:28 AM, J. Roeleveld wrote:
> > On Wednesday, September 17, 2014 11:24:36 AM Helmut Jarausch wrote:
> > > Hi,
> > >
> > > how do I need to configure my Gentoo box to allow for reverse
> >
> > tethering
> >
> > > from my (rooted) Android phone?
> > >
> > > Many thanks for a hint,
> > > Helmut
> >
> > What do you mean with "reverse tethering"?
> > That your mobile uses the network connection of your Gentoo box, or
> > your
> > Gentoo box the network connection of your mobile?
>
> My mobile should be able to use the (wired) network connection of my
> Gentoo box.

Ok, I assumed that was the case, but wanted to be sure.

> > Generally, the device sharing the connection needs to play WIFI
> > Access Point.
>
> How to do that on Gentoo?

If your Gentoo box has a wired connection and a wireless one.
The wired is currently used and the wireless is not.
Then you need to get your wireless card to function as an access point.
(Google for "Gentoo Linux Howto WIFI Access Point" or similar) and you should
find some information on how to do this.

--
Joost

Helmut Jarausch

unread,
Sep 17, 2014, 6:00:02 AM9/17/14
to
I should have made it more clear.
My GenToo box doesn't have a wireless card.
I'd like to connect my mobile to the USB port of my Gentoo box and get
access
to the (wired) network.

Thanks,
Helmut

J. Roeleveld

unread,
Sep 17, 2014, 6:20:02 AM9/17/14
to
There I can not help.
I am not aware of Android supporting that option.
Linux might be able to, if the USB connection acts like a NIC. But the phone
needs to then use the USB line for it's own internet link.

You might want to check on Android forums to see if anyone there has done it.

--
Joost

Stroller

unread,
Sep 17, 2014, 7:10:02 AM9/17/14
to

On Wed, 17 September 2014, at 10:53 am, Helmut Jarausch <jara...@igpm.rwth-aachen.de> wrote:
> …
>>> My mobile should be able to use the (wired) network connection of my Gentoo box.
>
> My GenToo box doesn't have a wireless card.
> I'd like to connect my mobile to the USB port of my Gentoo box and get access
> to the (wired) network.

I'm sure this must be possible.

Isn't it a standard thing to connect laptop and phone by USB and share the phone's 3G connection with the laptop?

This document seems to describe that setup: http://wiki.gentoo.org/wiki/Android_USB_Tethering

In this case the USB is being used as an ethernet connection - you're simply asking for the routing to occur in the opposite direction.

Loads of hits on Google for "tether android usb".

Stroller.

Mick

unread,
Sep 17, 2014, 7:40:02 AM9/17/14
to
Unless anyone suggests differently, I have tried something similar, using a
different device with IrDa, years ago. As far as the Linux PC is concerned it
needs to be able to forward packets from the Android to the ethernet NIC.
That's a case of setting up packet forwarding as if the Linux box were a
NATing router. Going from memory and assuming that your Android shows up as
usb0, when you run ifocnfig -a, you can try something like this:

ifconfig usb0 172.16.1.1 netmask 255.255.255.0
echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -F
iptables -t nat -A POSTROUTING -j MASQUERADE

Then on the Android you will need to have enabled the USB tethering or some
such and use ifconfig or equivalent to set up an IP address within the above
IP subnet and your PC's 172.16.1.1 address as the gateway. I think that the
Android may use rndis0 as a network interface but I'm not sure and don't have
access to an android device to check.

I seem to recall tightening up the iptables rules after I got it to work, so
that only the particular incoming device would be forwarded to the Internet,
but details presently escape me.

HTH.
--
Regards,
Mick
signature.asc

J. Roeleveld

unread,
Sep 17, 2014, 7:40:02 AM9/17/14
to
Stroller,

Helmut is trying to do the opposite.
He wants the mobile phone to use the internet connection of his desktop.

--
Joost

James

unread,
Sep 17, 2014, 8:40:03 AM9/17/14
to
Helmut Jarausch <jarausch <at> igpm.rwth-aachen.de> writes:

> > > > > how do I need to configure my Gentoo box to allow for reverse
> > > > tethering from my (rooted) Android phone?

PPP over usb is the most probable route. PPP is basically
TCP/IP (usually over a serial link/prototol_carrier).
This might help: "How to set up Android ppp over usb with adb"

http://www.xinotes.net/notes/note/1500/

You still ahve to set up NAT ont he linux box, probable with
iptalbes. MIcks post looks reasonable, but there may (will)
be addtional issues; just flesh them out, one at a time.

All of this over a serial (RS232_C) link between the phone
and the PC is old stuff and may best to get working first,
then migrate it over USB.


Also find a good usb_sniffer so you can ensure the bits are bidirectional
across the usb ports.

Last. There is a "GentRoid" project and I'm quite certain that (gentoo)
embeded dude, will be a fantastic resource, if all else fails.

Also one of the main devs for Selinux (Russell Coker) is a great
help as he has wrote of the early Selinux and put it on an Android phone.
It takes him a while to respond, but that info might aid your google
searches for solutions too. Use Russell as a last resort.

PPP/USB is what you are talking about. USB chips confiturations
inside a specific Android phone, might be limited (locked to keep
cpu cycles down) so you might also have to find an app that allows
you to "change settings" on the usb port on your Android phone. You
may have to "root" your Android phone to get this working.....


Last, you might have to "tweak" your gentoo linux kernel (usb, ppp,
iptables) etc etc. It'd be great when you get it working to put
something up on wiki.gentoo.org.


good hunting!
James

PS: my challenge word, via gmane posting, today is "posers"
I guess gmane knows today is an *ebuild hackfest day* for me....

Mick

unread,
Sep 17, 2014, 9:40:04 AM9/17/14
to
PPP would be necessary if authentication, compression, et al. is required, but
I think that in this case none of this is necessary, at least as far as the
Linux PC is concerned. The incoming usb0 interface (or whatever the Android
is recognised as) will be seen as an ethernet interface by the PC and good ol'
NAT will forward it out via the PC's default NIC. I could be wrong, but
without access to Helmut's phone I can't speak with any certainty.

--
Regards,
Mick
signature.asc

J. Roeleveld

unread,
Sep 18, 2014, 9:00:02 AM9/18/14
to

On Thursday, September 18, 2014 12:41:52 PM Stroller wrote:
> On Wed, 17 September 2014, at 12:31 pm, J. Roeleveld <jo...@antarean.org>
wrote:
> >> ...
> >> In this case the USB is being used as an ethernet connection - you're
> >> simply asking for the routing to occur in the opposite direction.
> >
> > Helmut is trying to do the opposite.
> > He wants the mobile phone to use the internet connection of his desktop.
>
> That's what I wrote - that he's "simply asking for the routing to occur in
> the opposite direction".
>
> My Android appears to allow networking over its USB connection in both
> directions - I attach two screenshots.
>
> The first attached screenshot is of the "Wireless and networks" menu, which
> is accessed directly from "Settings".
>
> As you can see there is a "Tethering & portable hotspot" submenu (second
> attached screenshot), but at the bottom there is also a tickbox "USB
> Internet - Sharing Windows PC internet via USB cable".
>
> If you look also at the second attached screenshot, "Tethering & portable
> hotspot", you will see that "USB tethering - USB connected, tick to tether"
> is a separate menu item.
>
> When I initially read your email and glanced at my phone, the "Sharing
> Windows PC internet via USB cable" item was greyed out. The words became
> solid when I plugged the USB cable in. I have not tested it further, but I
> have to assume that these two menu options perform reciprocal functions.

Which phone is that?

On my Galaxy S4, that option does not exist. Not even when connected via USB.

--
Joost

Stroller

unread,
Sep 18, 2014, 10:10:01 AM9/18/14
to

On Thu, 18 September 2014, at 1:57 pm, J. Roeleveld <jo...@antarean.org> wrote:
>> ...
>> My Android appears to allow networking over its USB connection in both
>> directions - I attach two screenshots.
>> ...
>
> Which phone is that?
>
> On my Galaxy S4, that option does not exist. Not even when connected via USB.

THL W200, a Chinese cheapie.

I would guess that its version of Android (4.2.1) is pretty vanilla.

I would also guess that there are apps to enable reverse tethering if it's commonly disabled or unavailable - if you can run TCP/IP over the USB cable one way, then it's only a network setting or two to run it the other way.

Stroller.

Peter Humphrey

unread,
Sep 18, 2014, 10:10:03 AM9/18/14
to
On Thursday 18 September 2014 14:57:13 J. Roeleveld wrote:

> On my Galaxy S4, that option does not exist. Not even when connected via
> USB.

It's present on my Nexus 5, but it's under Settings > More... (in the Wireless
& Networks section of Settings) > Tethering & portable hotspot.

--
Regards
Peter

thegeezer

unread,
Sep 25, 2014, 5:50:01 PM9/25/14
to
not sure if you can do this even on a rooted phone.
the trouble is that usb tethering starts a dhcp server running on the
usb side, and also keeps it's own default gateway to 3G or wherever.
you'd need to be able to setup routing on the rooted phone.
for just web pages, you might try to setup squidproxy on the gentoo box,
and then configure the phone to use the proxy server.
or you might be better off with a usb wifi dongle for the gentoo box and
setting up hostapd

Guillaume Poulin

unread,
Sep 26, 2014, 6:30:03 AM9/26/14
to
I had the same issue. I wrote a small script for that. If my memory is
good, it was working pretty good apart for the google play (don't
remember the reason thou).

```
#!/bin/bash

ifconfig usb0 192.168.42.135 up
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

adb start-server
adb shell su -c '/system/xbin/busybox ifconfig usb0 192.168.42.130 up'
adb shell su -c '/system/xbin/busybox route add -net default gw
192.168.42.135 usb0'
adb shell su -c 'setprop net.dns1 8.8.8.8'
adb shell su -c 'setprop net.dns2 8.8.8.4'
```
0 new messages