How to make my Ubuntu an internet gateway for my Android phone

Posted by yacine on Super User See other posts from Super User or by yacine
Published on 2012-12-16T13:19:32Z Indexed on 2012/12/16 17:07 UTC
Read the original article Hit count: 134

Filed under:
|
|
|
|

I want to use the internet of my school on my Android, the problem is they have a Squid proxy, and many applications on my phone don't use the proxy at all.

The obvious solution is to install a transparent proxy on my Android to force all applications to connect through it. The problem is that I need to root the phone to make it work, and I don't want to do it because it's not really my phone and rooting is a little risky-

Another solution, which is safer, is to make my computer run as a gateway, so I put my Ubuntu IP in the gateway parameter of the phone.

I'm running a small proxy on my ubuntu (cntlm), so I redirect the Android traffic to it. I did it with "iptables" as follows:

iptables -t nat -A PREROUTING -s 10.0.1.118 -p tcp -j REDIRECT --to-ports 8888
iptables -t nat -A PREROUTING -s 10.0.1.118 -p udp -j REDIRECT --to-ports 8888

10.0.1.118 is the IP of the phone, 8888 is the port of cntlm (proxy on my PC).

Now, on the phone: When I enter www.google.com on the navigator I get nothing (web site not found, error message of Firefox).

But, when I enter http://74.125.143.101 (IP of Google) I get an error message from the school proxy (so it worked in some way – my PC redirected the traffic of the phone to the Squid proxy).

The error message is :

The requested URL could not be retrieved
while trying to process the request
get / http/1.1
host 74.125.143.101
user-Agent ...
...

I think the problem is in the "GET" header,it should be GET 74.125.143.101 HTTP/1.1. But I don't understand what's happening, and I'm a certified CCNA.

© Super User or respective owner

Related posts about linux

Related posts about proxy