2

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
  • 219
  • 5
  • 14

2 Answers2

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
  • 22,566
  • 5
  • 56
  • 105
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
  • 616
  • 4
  • 8