You are not logged in.

#1 2014-07-09 10:22:48

fedeloco
Member
From: Barcelona
Registered: 2013-02-18
Posts: 10

[Solved]Using Phone Wifi connection for laptop via USB (Android 4.4.3)

Good day,
sometimes I find it handy to use my phone as a modem for my laptop via USB. I used this little script under android 2.*
Now under 4.4.3 it does not work anymore. The system does not report any error, but there is no connection at all.
This script was nice cause it worked for any connection on the phone, be it cellular data or wifi.
Any ideas why that does not work anymore?

# Android <-> Linux Tethering Script for Rooted Phones
# This script tethers the internet from the phone to your PC
# See http://ajasmin.wordpress.com/2011/07/24/android-usb-tethering-with-a-linux-pc/
# Requires a rooted phone with netfilter and pppd

# Path to ADB
export ADB=/home/fedeloco/data/adt/sdk/platform-tools/adb
if [ $USER != "root" ]; then
	echo "Please run this script as root"
	exit
fi

echo "Enabling NAT on the phone..."
$ADB shell "echo 1 > /proc/sys/net/ipv4/ip_forward"
$ADB shell "iptables -t nat -F"
$ADB shell "iptables -t nat -A POSTROUTING -j MASQUERADE"

echo "Connecting to the phone via 'adb ppp'..."
# This uses Google Public DNS servers which should work most of the time
$ADB ppp "shell:pppd nodetach noauth noipdefault ms-dns 8.8.8.8 ms-dns 8.8.4.4 /dev/tty" nodetach noauth noipdefault defaultroute usepeerdns notty 10.0.0.1:10.0.0.2

echo "Done."

Logs:

Jul 09 12:16:12 aldebaran systemd[1]: Stopped Network Manager.
Jul 09 12:17:32 aldebaran pppd[7771]: pppd 2.4.6 started by root, uid 0
Jul 09 12:17:32 aldebaran pppd[7771]: Using interface ppp0
Jul 09 12:17:32 aldebaran pppd[7771]: Connect: ppp0 <--> /dev/pts/3
Jul 09 12:17:32 aldebaran pppd[7771]: Serial line is looped back.
Jul 09 12:17:32 aldebaran pppd[7771]: Connection terminated.
Jul 09 12:17:32 aldebaran pppd[7771]: Exit.

ip addr does not give any new interface.
Any ideas?

Apologies if this is not posted to the correct section, feel free to move it where applicable.

Last edited by fedeloco (2014-08-02 16:25:54)

Offline

#2 2014-07-09 13:46:04

xero
Member
From: ~/
Registered: 2014-04-02
Posts: 86
Website

Re: [Solved]Using Phone Wifi connection for laptop via USB (Android 4.4.3)

i've had similar issues with usb tethering in all flavors of linux. using your phone as mobile hotstop is a simple fix.


▬▬ι═══════ﺤ
http://git.io/.files

Offline

#3 2014-08-02 08:58:19

fedeloco
Member
From: Barcelona
Registered: 2013-02-18
Posts: 10

Re: [Solved]Using Phone Wifi connection for laptop via USB (Android 4.4.3)

xero
That's not what I want to do. I want to use my phone's wifi connection to share with my laptop. The hotspot mode uses the cellular data and sends it via the phone's wifi.
Anyone?

Offline

#4 2014-08-02 15:25:06

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,354

Re: [Solved]Using Phone Wifi connection for laptop via USB (Android 4.4.3)

I hope that you can get this working.  I do this all the time on my ancient HTC running 2.4.  I am within days of upgrading to something new. 

The minor difference in my setup is that I set up the NAT on from a script that runs in Android.  Any computer I attach can then just use it.
The major difference is the use of ppp.  Why do you do it that way?  My phone has a mode for USB tethering.  In that mode, attach it to a computer and you can a shiny new USB based "wired" NIC.
Also, do you have root access under 4.4.3?
If you use the adb shell by hand from a  terminal to log into Android, what do those commands report?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2014-08-02 16:22:02

fedeloco
Member
From: Barcelona
Registered: 2013-02-18
Posts: 10

Re: [Solved]Using Phone Wifi connection for laptop via USB (Android 4.4.3)

Thanks ewaller.
I've been thinking too hard... Just works out of the box.
Just connected the USB cable, enabled USB tethering on the phone, and let NetworkManager on the computer do the job...
ip addr shows an ethernet connection:

enp0s29u1u2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 02:03:51:59:66:36 brd ff:ff:ff:ff:ff:ff
    inet 192.168.42.4/24 brd 192.168.42.255 scope global dynamic enp0s29u1u2

Last edited by fedeloco (2014-08-02 16:25:00)

Offline

Board footer

Powered by FluxBB