Access Internet on android phone by connecting it to laptop?

1

1

My latop is connected to a wired modem for internet. I want to access internet on my android phone.

Can i do it by connecting my Android to laptop via usb cable and then enabling tethering.

Edit:

Operating System: Ubuntu 12.04

Mohit

Posted 2013-08-01T12:26:44.287

Reputation: 209

Use this without root https://github.com/Genymobile/gnirehtet

– Biswapriyo – 2017-11-01T15:22:36.413

1I forgot to mention: its ubuntu 12.04 – Mohit – 2013-08-01T12:43:14.003

@CharlieRB can you remove 'This question may have an answer here' banner as it is apparent that question has been edited to update the OS. – Mohit – 2013-08-02T04:05:30.970

I removed my vote and comment related to being a duplicate. If my answer was correct, please select it as being the answer. Thank you. – CharlieRB – 2013-08-02T11:56:39.763

Answers

1

You will need do a reverse tether. As far as I know, the phone must be rooted for this to be done.

Here are instructions at XDA Developers - HOWTO: Ubuntu USB reverse tethering

CharlieRB

Posted 2013-08-01T12:26:44.287

Reputation: 21 303

If you are reading this in 2016, this no longer works for android v5 and above – Gabriel Fair – 2016-09-09T19:16:27.010

1

Here's the closest to a "one-click" solution that I got to.

Prerequisites

  • Rooted Android device

  • Root access on the PC

  • ADB installed on the PC (apt-get install android-tools-adb on Debian-based distros)

  • USB Debugging enabled on Android

Procedure

  1. Connect Android device to the PC via USB
  2. Enable USB tethering on the Android device (Settings)
  3. Run the following script:

    #!/bin/bash
    
    WAN="wlan1"       # interface providing internet connection on the PC
    LAN="usb0"        # usb interface on the PC
    AND="rndis0"      # usb interface on Android
    
    LAN_IP="10.0.0.1"
    AND_IP="10.0.0.10"
    NETMASK="255.255.255.0"
    
    DNS1="8.8.8.8"
    DNS2="8.8.4.4"
    
    sudo su -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
    sudo iptables -F -t nat
    sudo iptables -F FORWARD
    sudo iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE
    sudo iptables -A FORWARD -i $WAN -o $LAN -m state --state RELATED,ESTABLISHED -j ACCEPT
    sudo iptables -A FORWARD -i $LAN -o $WAN -j ACCEPT
    
    sudo ifconfig $LAN $LAN_IP netmask $NETMASK up
    
    adb shell su -c busybox ifconfig $AND $AND_IP netmask $NETMASK up
    adb shell su -c busybox route add default gw $LAN_IP
    adb shell su -c ndc resolver setifdns $AND "" $DNS1 $DNS2
    adb shell su -c ndc resolver setdefaultif $AND
    
    adb shell ping -c4 $DNS1
    adb shell ping -c4 google.com
    
  4. Done!

Notes

  • You probably need to adjust the interface names LAN, WAN and AND.

  • I found that some apps would either not recognize the network connection or only work partially. I was able to fool them using Fake Wifi Connection module for the Xposed Framework

koniu

Posted 2013-08-01T12:26:44.287

Reputation: 566