Reverse USB tethering Script - Sony Xperia P, U, Sola, Go

Hello every body,
This is my first post here
I had rooted my Xperia S two days ago and since then I am exploring my root capabilities.
I wrote a script to hook my Xperia S to my LAN Via USB.
Here is what I did.
1-connect Xperia S to PC in Regular USB Tethering mode.
2-bridge the network adapter form the phone with PC LAN Adapter and set IPv4 Settings Manually.
3-Run the following script on the phone.
Code:
ifconfig rndis0 192.168.1.99
ip route add 0.0.0.0/0 via 192.168.1.1 dev rndis0
ip route add 0.0.0.0/0 via 192.168.1.1 dev rndis0 metric 213
ip route del 192.168.1.0/24
ip route add 192.168.1.0/24 via default dev rndis0 proto kernel scope link src 192.168.1.99 metric 213
ip route add 192.168.1.1 via default dev rndis0 scope link
setprop net.nds1 8.8.8.8
setprop net.nds2 8.8.4.4
here I tried to mimic the same routing table form regular WIFI connection.
And it WORKS!!
but with a strange behavior.
After these steps I try to ping PC (form phone) and it is Unreachable, and the gateway is the same.
But after I reverse the operation and ping the phone from PC and from the gateway, the network operates normally , and phone pings through the gateway to the internet. also , I can receive streams from my PC and Access my mobile's FTP server , stock browser works.
But the Market cannot download apps , Maps cannot load.
I wonder why This is happening?
If you have an answer , I would be delighted to know it.
Thank You.

Maps cannot load.
Click to expand...
Click to collapse
It did load after some time , it needed patience , although it popped up "Data Connection not Available".
After these steps I try to ping PC (form phone) and it is Unreachable, and the gateway is the same.
But after I reverse the operation and ping the phone from PC and from the gateway, the network operates normally , and phone pings through the gateway to the internet.
Click to expand...
Click to collapse
Since it worked after it was pinged and learned MAC addresses.
I think there is a problem in layer 2, for some reason it cannot send ARP requests.

Success
After Upgrading to Windows 8 , The same script works as it should.
My Xperia S can now ping all network devices directly.
It seems that there was some thing wrong with My previous Win7.
But still there are some applications that can't deal with USB internet.
Google Play can navigate and search but can't download apps.
I think this topic was moved to inappropriate sub-forum (> Sony Xperia P, U, Sola, Go > Xperia P, U, Sola, Go General ) , it is related to Xperia S Please move it there.
Thank You.

Related

Tethering Issue... among others.

Tethering worked for me just once, through wifi. Now, everytime my laptop, or any device connects to my O1 it doesn't detect the internet even if I am able to browse on the phone through my 3G connection.
I can ping the phone's ip address and access shared folders on my laptop through ex file manager so I know the connection is there. Somehow, though, the Internet isn't going through.
My other concern is how this thing manages the sd card. Ever since I bought this, as long as there are no apps installed to the sd, my phone works perfectly fine. Once I move any app to it, though, weird things start happening... like the phone reboots randomly, or freezes, or the sd card unmounts and remounts without loading the apps on it, forcing me to do a manual un/remount or reboot.
I tested this by moving all apps back to internal. 2 days passed with no reboots. Then I moved just one app to the sd and let it sit. No more than 30 mins, the startup sound alerted my attention.
Except flashing custom roms, which I refuse to do until stock works fine, I've already done most of the suggestions I could find floating here on xda and other forums... rooting,unrooting, clearing cache, factory reset, reformatting sd card and so forth... so I was wondering what else I could do to fix these problems.
Phone has been up now for almost a week without rebooting after I took the app out of the card and back to internal. But I don't see the sense of having external memory if the phone goes crazy with apps on it.
Otherwise, it's a perfectly decent phone.
Sent from my LG-P500 using Tapatalk
do you have Data enabled in mobile network settings?
Omnichron said:
do you have Data enabled in mobile network settings?
Click to expand...
Click to collapse
Of course. I can browse on the phone.
Sent from my LG-P500 using Tapatalk
it could be a firewall issue or protocol setting on the laptop nic.
if you have ipv6(NIC Properties) installed remove it and try the connection again.
Omnichron said:
it could be a firewall issue or protocol setting on the laptop nic.
Click to expand...
Click to collapse
If it was, then theoretically, mobile phones should be able to use my data connection, right? I've had my friends connect with their mobiles and tablets... they get the ip address but not the juice.
Sent from my LG-P500 using Tapatalk
try updating or downgrading wifi tether
http://code.google.com/p/android-wifi-tether/downloads/list
Will try it out. Thanks!
Sent from my LG-P500 using Tapatalk
And that worked like a charm without changing any setting on my laptop. although, i noticed that it asked for su on android.tether. What makes this one special?
Sent from my LG-P500 using Tapatalk
I would like to up this post and ask about the initial concern again. Wifi Tether works like a beauty, but I noticed it's an ad-hoc network. Not all devices see my "router".
So back to the original concern of using the built-in Wifi Tethering of this O1... why can't I get any internet on the devices that are able to connect to it? Again, the I.P. address is correct, but there is no Internet connection.
Well, no info here... so. The usual network troubleshooting drill, like...
Code:
ipconfig /all
route print
(on Windows boxes)
Code:
ip address show
ip route print
(on your phone, either via terminal emulator or via adb shell).
doktornotor said:
Well, no info here... so. The usual network troubleshooting drill, like...
Click to expand...
Click to collapse
If by info you mean what kind of phone, it's a rooted stock P500 v10b.
I already mentioned in previous posts that the ip addresses report fine. Again, all devices can connect to the built-in tether, they get correct ip addresses but just no internet. It worked just once when it was new. Never again after that, even after the first factory reset.
But here's what terminal says.
Code:
$ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN
link/ether 9e:4d:23:e2:28:ec brd ff:ff:ff:ff:ff:ff
3: rmnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 76:e2:a8:76:3e:3a brd ff:ff:ff:ff:ff:ff
inet 10.115.27.234/30 brd 10.115.27.235 scope global rmnet0
inet6 fe80::74e2:a8ff:fe76:3e3a/64 scope link
valid_lft forever preferred_lft forever
4: rmnet1: <BROADCAST,MULTICAST> mtu 2000 qdisc noop state DOWN qlen 1000
link/ether a6:b7:7a:3e:5f:00 brd ff:ff:ff:ff:ff:ff
5: rmnet2: <BROADCAST,MULTICAST> mtu 2000 qdisc noop state DOWN qlen 1000
link/ether e6:52:c0:53:21:df brd ff:ff:ff:ff:ff:ff
6: usb0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 96:02:b8:f4:38:65 brd ff:ff:ff:ff:ff:ff
7: sit0: <NOARP> mtu 1480 qdisc noop state DOWN
link/sit 0.0.0.0 brd 0.0.0.0
8: ip6tnl0: <NOARP> mtu 1460 qdisc noop state DOWN
link/tunnel6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
23: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 5c:da:d4:79:39:37 brd ff:ff:ff:ff:ff:ff
inet6 fe80::5eda:d4ff:fe79:3937/64 scope link
valid_lft forever preferred_lft forever
24: wl0.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 5c:da:d4:79:39:37 brd ff:ff:ff:ff:ff:ff
inet 192.168.43.1/24 brd 192.168.43.255 scope global wl0.1
inet6 fe80::5eda:d4ff:fe79:3937/64 scope link
valid_lft forever preferred_lft forever
$ip route
202.126.40.5 dev rmnet0
222.127.143.5 dev rmnet0
10.115.27.232/30 dev rmnet0 src 10.115.27.234
192.168.43.0/24 dev wl0.1 src 192.168.43.1
default via 10.115.27.233 dev rmnet0
$
Well, what do you mean by "no internet".
E.g., what does the following produce (on Windows)?
Code:
> tracert www.google.com
> tracert 209.85.143.99
doktornotor said:
Well, what do you mean by "no internet".
Click to expand...
Click to collapse
Doesn't that usually mean that I can't go online the normal way?
On windows, tracert www.google.com doesn't do anything. Surprisingly, it worked for the I.P. address. Browsing using I.P. addresses works, as well.
That being said, I think there's a problem with the way the built-in tethering handles DNS server numbers, which is why none of the devices that connect to it is able to connect through to the internet.
Any ideas on why this is happening? Or how to fix?
androidmeda said:
Doesn't that usually mean that I can't go online the normal way?
On windows, tracert www.google.com doesn't do anything. Surprisingly, it worked for the I.P. address. Browsing using I.P. addresses works, as well.
Click to expand...
Click to collapse
Go online the normal way does not really mean much either, so - no. Internet != web browsing.
Meanwhile, since your DNS is apparently not working properly, stick 8.8.8.8 and 8.8.4.4 (Google public DNS) to the TCP/IP settings on the clients and it will work.
"built-in tethering handles DNS server numbers" - those are IP addresses. If you can ping/traceroute using DNS names (like www.google.com) from the phone, then obviously your clients are not getting the proper DNS servers assigned from the phone via DHCP server.
For further debugging, you need to post which DNS servers are being used on the phone and whether those match the ones assigned to the WiFi clients (or if any are assigned at all). Again, ipconfig /all or whatever similar according to the clients OS.
Using built-in tethering, I checked the DNS server assigned to a windows client, it's the same as the ip address it got from the phone. No browse using urls. Pings are ok, tracert only works if I use the ip address as shown on the ping, and I can browse to a website if I use the ip instead.
Using Wireless Tether, the DNS server is the same as the assigned ip address, but I'm able to browse and tracert using urls.
The only reason I'm trying to get built-in to work is because not all devices can detect Wireless Tether's adhoc network. Even a fellow Optimus One can't see it. (On a side note, I can't detect wireless adhoc networks, either.)
I don't know how to check the DNS assigned to the phone. But looking at ip route, it's probably the first two numbers.
Code:
#ip route
202.126.40.5 dev rmnet0
222.127.143.5 dev rmnet0
10.31.40.196/30 dev rmnet0 src 10.31.40.198
10.10.1.0/24 dev wlan0 src 10.10.1.254
default via 10.31.40.197 dev rmnet0
#
Up until the time Wireless Tether will be able to start as a true access point, I will be wondering what's going on with the built-in.
If assigning a DNS server to a client would work, that still doesn't address the fact that you can't manually assign DNSs on all devices.
Sent from my LG-P500 using Tapatalk
androidmeda said:
Using built-in tethering, I checked the DNS server assigned to a windows client, it's the same as the ip address it got from the phone.
Click to expand...
Click to collapse
I do not understand. Their DNS is set to their local IP address? Well, that obviously cannot work unless you install a DNS server on the computer.
androidmeda said:
Using Wireless Tether, the DNS server is the same as the assigned ip address, but I'm able to browse and tracert using urls.
Click to expand...
Click to collapse
Errr, what? Please post the settings, the above plain does not make sense to me, do not understand what you saying there.
androidmeda said:
I don't know how to check the DNS assigned to the phone.
Click to expand...
Click to collapse
Here:
Code:
$ cat /system/etc/resolv.conf
doktornotor said:
I do not understand. Their DNS is set to their local IP address? Well, that obviously cannot work unless you install a DNS server on the computer.
Click to expand...
Click to collapse
I'm sorry, I meant to say it's the same as the default gateway. Here's how ipconfig /all looks like on my laptop on Wireless Tether. I can browse and do anything online.
Code:
Wireless LAN adapter Wireless Network Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Broadcom 802.11g Network Adapter
Physical Address. . . . . . . . . : 00-1F-E1-4C-56-E2
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 10.10.1.100(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Sunday, May 29, 2011 10:13:47 PM
Lease Expires . . . . . . . . . . : Monday, May 30, 2011 9:59:53 AM
Default Gateway . . . . . . . . . : 10.10.1.254
DNS Servers . . . . . . . . . . . : 10.10.1.254
NetBIOS over Tcpip. . . . . . . . : Enabled
And here's how it looked like on built-in tether. No browse.
Code:
Wireless LAN adapter Wireless Network Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Broadcom 802.11g Network Adapter
Physical Address. . . . . . . . . : 00-1F-E1-4C-56-E2
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 192.168.43.25(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Sunday, May 29, 2011 10:32:56 PM
Lease Expires . . . . . . . . . . : Sunday, May 29, 2011 11:32:55 PM
Default Gateway . . . . . . . . . : 192.168.43.1
DHCP Server . . . . . . . . . . . : 192.168.43.1
DNS Servers . . . . . . . . . . . : 192.168.43.1
NetBIOS over Tcpip. . . . . . . . : Enabled
I tried putting google's public dns on the wireless network connection's tcp/ip v4 properties, but it still came up with no browse, no ping, tracert ok on ip address.
By the way, cat /system/etc/resolv.conf doesn't exist on the phone according to terminal emulator. I checked with root explorer as well to confirm.
Unless there is a running DNS server/proxy on the default GW, it will not work. Check with nslookup or whatever similar tool.
/system/etc/resolv.conf does not exist? I do not understand how are you able to browse anything from your phone then. It specifies the DNS servers the phone is using.
I tried putting google's public dns on the wireless network connection's tcp/ip v4 properties, but it still came up with no browse, no ping, tracert ok on ip address.
Click to expand...
Click to collapse
Getting totally lost here. Why on wireless? By "built-in" tether you mean you connect the phone via USB cable? Well, that does not use wireless at all, so setting any DNS there will not do any good.
Oh well, to sum this up - if you devices cannot see an ad-hoc wifi network, those are broken, not the phone. Messing with USB cable and internet connection sharing on your PC is just a waste of time, IMHO.
doktornotor said:
/system/etc/resolv.conf does not exist? I do not understand how are you able to browse anything from your phone then. It specifies the DNS servers the phone is using.
Click to expand...
Click to collapse
I don't understand it either.
Getting totally lost here. Why on wireless? By "built-in" tether you mean you connect the phone via USB cable? Well, that does not use wireless at all, so setting any DNS there will not do any good.
Click to expand...
Click to collapse
Froyo has its own wireless tethering, right? That's what I'm trying to get working.. and that's what I'm working on. By the way, USB tethering doesn't work AT ALL.
Oh well, to sum this up - if you devices cannot see an ad-hoc wifi network, those are broken, not the phone. Messing with USB cable and internet connection sharing on your PC is just a waste of time, IMHO.
Click to expand...
Click to collapse
Total of three brand new Optimus Ones, all unable to see different adhoc networks that work on other wireless-capable devices (this laptop and an iProduct)? I'm just not seeing how the adhoc networks are broken.
It might be a waste of time for you, but this is the way I use the internet at home: my laptop tethered to my phone. I'll probably just wait for Wireless Tether to upgrade to access-point capacity.
Thanks for helping me out with this!

[Q] Wireless tether for root users - DNS redirect

I'm running a Piratebox web server on my phone - Does anyone know if there's a way to adjust DNS and re-direct everyone to my phones web server when they are tethering from my phone?
+1 to this question.
I am currently trying to find a way to get some android devices, which are working as AdHoc clients), and I want an app running on them to connect to a "server" address instead of using a specific, fixed IP address. I meant to do this programatically, by creating a socket to an InetAddress resolution of the "server" address. I assume InetAddress will use the DNS defined on the wireless interface to make this translation, but its Java, and that assumption really depends on the low level impl. of InetAddress.
So yeah, DNS redirect from the DNS server running on the AdHoc host, which by association also runs Wireless Tether for root users. How can we do it?
I have tried some redirections from the hosts file (zone file), location in "system/etc/hosts". My device, like many others, comes preloaded with a bunch of IP-hostname redirections, but these only seem to work locally, e.g.:
gugle.com redirects to 127.0.0.1 (in the hosts: "gugle.com 127.0.0.1")
If I input this address on the AdHoc host, gugle.com will redirect to my http port 80 landing (I have a web server running on the device to test this).
If I input this address on an AdHoc client, it doesnt return anything. I'm guessing the DNS server running on the host does not use the zone file from the OS.
So the question remains - where can we define a redirection from the DNS server that runs on the Wireless Tethering for root users device.

[Q] VPN - Connecting to servers by name

I have installed OpenVPN as per instructions I found on these forums and am using VPNC to connect, which I can do successfully. VPNC reports that I don't have Advanced Routing enabled, which is likely true, but I am not worried about that at the moment. I can ping and RDP to servers by IP but not by name. A friend of mine has a different phone and the same issue. Our VPN is a Cisco setup.
I am using a Sony Ericsson Xperia X10 with Gingerbread and the phone is rooted.
The question is how can I configure things so that I can reference things on the network by name and not have to use only IP addresses?
Thank you.
Ok, FQDN and IP work. Just not going with just the name of the server alone.
Added --domain <domain name> to the option flags. Didn't change things.
thanks for info

[Q] Samsung Galaxy S2 not resolving particular host names to IP

Hi, guys, here's my problem.
My Galaxy S2 using my own WiFi is unable to retrieve some content from web. This content is:
apps icons in Android Market,
Picasa images,
Accuweather forecasts
and some others.
Other devices using the same WiFi has no problems with it. S2 switched to other ISP than my WiFI also has no problems with it.
While trying to narrow possible causes I've picked an example image, which is problematic to my S2+WiFI combination:
https://lh3.ggpht.com/NpoJbnyQbI1kEIlrWhP_t7lj9lN519RkPB3mxQS2z6pTFjh01R3ISeyYnj4AccBSsQ=w788 (an icon of an app from Adroid Maret, remove space from url).
It won't open on my phone using WiFi, so I checked host availability. I've run on my phone following command:
Code:
[email protected]:/ $ ping lh3.ggpht.com
ping: unknown host lh3.ggpht.com
But on my PC using the very same WiFi:
Code:
C:\Users\Grzegorz>ping lh3.ggpht.com
Badanie photos-ugc.l.google.com [173.194.70.132] z 32 bajtami danych:
Odpowiedź z 173.194.70.132: bajtów=32 czas=27ms TTL=47
Odpowiedź z 173.194.70.132: bajtów=32 czas=25ms TTL=47
I'm stuck, what should I do now?
Have you any ad blockers or DNS stuff running ???
jje
Nope, it's clean Android 4.0.3.
Echo request for lh3.ggpht.com on your phone does not work. On your PC you get a response from 173.194.70.132. Just to make sure your problem is related to DNS (and not to some lower service): did you try to ping the IP address 173.194.70.132 from your phone? Do you get a response?
Yes, the host is reachable from phone using IP dot address, only name resolving does not work.
Ok, looks definitely like some DNS problem. As you already confirmed that your hosts file is fine the only thing I can imagine is your phone using some 'wrong' DNS server for address lookup.
To make (almost) sure you use a set of different DNS servers you could disconnect your phone from the wifi and enable a 3G data connection. Make absolutely sure you are not connected to your wifi. Now again run 'ping lh3.ggpht.com'; do you get a response?
Yes, that is the case.
Another weird thing is that phone on 3G resolves lh3.ggpht.com as 173.194.35.139, while PC on WiFi as 209.85.148.132. My 'hosts' file contains only localhost reference.
When I switch to WiFi while pinging that host, pings keep successful, unless I restart terminal session — after that I get 'unknown host' message.
Is there DNS configuration in Android somewhere?
OK, it seems I fixed it.
My WiFi works in a bigger subnet and hides all connected WiFi devices as as single computer.
I've installed on my Phone app called Set DNS from former Android Market, which allowed me to change both primary and secondary DNS. Initally both addresses were pointing to WiFi router itself which seems to work fine for my PC. I've changed it to DNSes of that bigger subnet I'm connected to. And it did the trick. Hopefully it won't mess settings for other WiFis I use to connect.
Thanks for showing me right direction!

Android OS + BIND9 dns on local server

Hi All,
I don't know if it is the proper thread for this, but I've installed a local webserver (CentOS) with BIND9 dns (named) and what is annoying me that my android devices don't resolve the server address. They can only connect through the IP of the server.
Windows pc and iOS devices do resolve the server name.
Devices connect to the server through a wireless AP that is also a DHCP. DNS address is distributed through the AP's DHCP.
Any ideas? Or any workaround for this? The main goal is to reach the local server by its name, so if you guys know an app other than a DNS server I would be grateful for some help.
Thanks a lot
Greg
did you use static ip address and custom dns in advance settings on your android handset? if yes your android should lookup for dns server. anyway maybe, i could be wrong, port 53 is being used for other apps or closed in iptables on your android hanset.
cheers hope it could help
vertrag said:
did you use static ip address and custom dns in advance settings on your android handset? if yes your android should lookup for dns server. anyway maybe, i could be wrong, port 53 is being used for other apps or closed in iptables on your android hanset.
cheers hope it could help
Click to expand...
Click to collapse
Thanks for the quick reply.
The ROM I use is one of Ficeto's base ROM. I9100XXLPQ with supercore kernel. The thing is, in advanced wifi configurations I don't have the possibility to set DNS. DNS information is not even displayed. I only see the IP and I don't have the possiblity to edit it neither. It is something that should be available in all roms or is it just my current rom?
I have no idea if there is something that uses the port 53, but when I connect to my DSL router I can browse the internet. So I assume the DNS in this case should work correctly.
Thanks a lot
Greg
Someone, move this question to Q&A thread..
yes if ur able to browse di internet normally then the dns query look up is fine.. what i nean by port 53 is the port that dns server and client use to communicate each other. take a look of my screenshot im able to change the dns..
Sorry for having posted in the wrong thread.
Well I don't have the same settings available in my current ROM. But I installed a third party app from Play to set the DNS and even if it is displayed correctly in the 3rd party app settings, it doesn't resolve the server's address.
I guess there is nothing else left but to use a packet sniffer (wireshark) to see whats going on between the android's browser and the server.
Will get back with the results.
Thanks
Greg
Greg767 said:
Sorry for having posted in the wrong thread.
Well I don't have the same settings available in my current ROM. But I installed a third party app from Play to set the DNS and even if it is displayed correctly in the 3rd party app settings, it doesn't resolve the server's address.
I guess there is nothing else left but to use a packet sniffer (wireshark) to see whats going on between the android's browser and the server.
Will get back with the results.
Thanks
Greg
Click to expand...
Click to collapse
Did you check the value of property net.dns1? If not just enter
Code:
getprop | grep net.dns
in an ADB shell. The value of the property net.dns1 should be set to the IP address of your DNS server.
If this is not the case just enter
Code:
setprop net.dns1 <your DNS server IP address>
for testing and try to ping one of your internal servers by name. It should work now.
Hi all,
Problem is solved. On a local network you must define the gateway in the DHCP so that the android device sends both IPv6 and IPv4 queries to the DNS server. If it is not defined it sends only IPv6 queries and doesn't fall back to IPv4 when that fails.
Thanks for your help
Greg

Categories

Resources