Fekky Reviant

starting with a doubt then ending with a choice …..

Reverse USB Tethering with Galaxy Young Android GingerBread

tujuan :
bisa internetan lewat hp tapi pake koneksi yang ada di PC/leptop

required :
- samsung galaxy young
- OS Android GingerBread
- adb [ dapet dari android sdk ][ dl dulu sdk na uda gt update, doi ada di platform-tools ]

1. device di root [ biar bisa run root-group app ] ( liat di ref )
2. copas kode a [ utk di pc ] dan b [ utk di device ]
3. copas ke device dan run dengan adb, sblmna colok device ke usb, trus jangan aktifin usb tetherna


root@ubuntu:/tmp# ./adb push b /sdcard/
25 KB/s (1413 bytes in 0.054s)
root@ubuntu:/tmp# ./adb shell
$ su
# cd sdcard
# sh b start
Starting Replicant USB Networking
root@ubuntu:/tmp#


4. jalankan pc mode, untuk network-managerna didiskonek dl sblm menjalankan script
root@ubuntu:/tmp# ./a start
Starting Replicant USB Networking
root@ubuntu:/tmp#

5. tes ping, klo jalan, berarti device smartphone siap utk internetan lewat pc yg ada inetna

 ping 192.168.4.202
PING 192.168.4.202 (192.168.4.202) 56(84) bytes of data.
64 bytes from 192.168.4.202: icmp_req=1 ttl=64 time=0.483 ms
64 bytes from 192.168.4.202: icmp_req=2 ttl=64 time=0.483 ms
^C
--- 192.168.4.202 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.483/0.483/0.483/0.000 ms

attach
——-
kode a :

#!/bin/sh

# Replicant USB Networking
# ========================                             
# 
# Copyright (C) 2011 Paul Kocialkowski, GPLv3+
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

IPTABLES_CLEAN_RULES=true

USB_IFACE="usb0"
INTERNET_IFACE="eth0"

USB_IFACE_IP="192.168.4.200"

# Clean iptables rules

iptables_rules_clean () {
	if [ $IPTABLES_CLEAN_RULES = false ]
	then
		return
	fi

	iptables --flush
	iptables --table nat --flush
	iptables --delete-chain
	iptables --table nat --delete-chain
}

# Inject iptables forwarding rules

iptables_forward_rules_apply () {
	iptables --table nat --append POSTROUTING --out-interface $INTERNET_IFACE -j MASQUERADE
	iptables --append FORWARD --in-interface $USB_IFACE -j ACCEPT
	echo 1 > /proc/sys/net/ipv4/ip_forward 
}

# Configure network link

usb_networking_configure () {
	ifconfig $USB_IFACE up
	ifconfig $USB_IFACE $USB_IFACE_IP
}

usb_networking_disable () {
	ifconfig $USB_IFACE down
	echo 0 > /proc/sys/net/ipv4/ip_forward 
}

case $1 in
	"start")
		echo "Starting Replicant USB Networking"
		iptables_rules_clean
		usb_networking_configure
		iptables_forward_rules_apply
	;;
	"stop")
		echo "Stopping Replicant USB Networking"
		usb_networking_disable
		iptables_rules_clean
	;;
	*)
		echo "Usage: sh $0 {start|stop}"
	;;
esac

kode b :

#!/system/bin/sh

# Replicant USB Networking
# ========================                             
# 
# Copyright (C) 2011 Paul Kocialkowski, GPLv3+
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Enable USB Networking

USB_IFACE="usb0"

USB_IFACE_IP="192.168.4.202"
GATEWAY_IP="192.168.4.200"
DNS1_IP="8.8.8.8"

usb_networking_enable () {
	echo 1 > /sys/class/usb_composite/rndis/enable
	ifconfig usb0 up
}

usb_networking_configure () {
	ifconfig $USB_IFACE $USB_IFACE_IP
	route add default gw $GATEWAY_IP dev $USB_IFACE
	setprop net.dns1 $DNS1_IP

	# setprop net.dns1 $( cat /system/etc/resolv.conf | sed -e "s|.*#.*||" -e "s|^.*nameserver \(.*\)$|\1|g" | grep -v "^$" | head -n 1 )
}

usb_networking_disable () {
	echo 0 > /sys/class/usb_composite/rndis/enable
	ifconfig usb0 down
}

case $1 in
	"start")
		echo "Starting Replicant USB Networking"
		#usb_networking_enable fix kebawah ja 
		usb_networking_configure
             usb_networking_enable
	;;
	"stop")
		echo "Stopping Replicant USB Networking"
		usb_networking_disable
	;;
	*)
		echo "Usage: sh $0 {start|stop}"
	;;
esac

ref :

http://basri-page.blogspot.com/2011/11/tutorial-how-to-root-samsung-galaxy.html

http://trac.osuosl.org/trac/replicant/wiki/ReplicantUSBNetworking

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.