/[scripts]/trunk/android-tether.sh
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/android-tether.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 139 - (show annotations)
Tue Sep 14 19:42:05 2010 UTC (13 years, 7 months ago) by dpavlin
File MIME type: application/x-sh
File size: 684 byte(s)
experiment to tether Android with laptop for Internet access

1 #!/bin/sh -x
2
3 # as described at
4 # http://www.forceclose.com/questions/2669/connect-android-to-internet-using-usb-tether-through-laptops-newtwork
5
6 sudo id
7
8 android=`adb shell ip addr list usb0 | grep 'inet ' | sed 's/^ *//g'`
9
10 a_ip=`echo $android | cut -d" " -f2 | cut -d/ -f1`
11 c_ip=`echo $a_ip | cut -d. -f-3`.1
12 netmask=`echo $android | cut -d" " -f4`
13
14 echo "Android $a_ip netmask $netmask -> $c_ip"
15
16 sudo ifconfig usb0 $c_ip netmask $netmask up
17 sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
18 sudo iptables -t nat -A POSTROUTING -s $a_ip -o br0 -j MASQUERADE
19
20 adb shell ip route add default via $c_ip
21 adb shell setprop net.dns1 8.8.8.8
22
23 adb shell ping -c 1 $c_ip
24 ping -c 1 $a_ip

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26