7

Is it possible to access a computer connected to the internet through an Android phone? (the internet goes through the phone by tethering)

I want to use ssh to connect to the computer (from a different computer in the same network), but I am not able to access the computer.

Is it possible to port forward, use some kind of transparent proxy or to use DMZ?

My phone is rooted and I have Cyanogenmod installed and I can use iptables.

EDIT: The changed title completely changed the question!

My setup is the following: I have an android phone connected to a computer through the usb cable tethering internet from the phone, I wanted to ssh into the computer behind the android phone from another computer in the same network as the android phone. This was not possible, because the android phone creates a separate network for the connected computer, effectively shielding it from any incoming signals.

It turned out to be quite simple to fix by just using iptables.

2
  • 1
    Possible duplicate: android.stackexchange.com/questions/1315/…
    – ale
    Aug 1, 2012 at 19:46
  • Not quite, I am still having problems saving my iptables config, but I read that I'll have to compile iptables again to make it work, and I don't think it's worth it.
    – Qurben
    Aug 2, 2012 at 21:54

4 Answers 4

12

It turned to out to be quite simple, when tethering the phone behaves like a router (wifi on eth0 and the tethered computer on usb0). I guess that in some way connecting a switch to the phone would allow multiple computers to be connected by cable to a single computer (a ridiculous setup, but still fun :D). I had to use iptables to route the traffic from port 22 of the device to port 22 of the connected device and accept traffic on port 22.

I used ssh (DigiSSHD app) to ssh into my phone, logged in as root and added the following two rules for iptables. (where the connected device is 192.168.42.185)

# iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 22 -j DNAT --to 192.168.42.185:22
# iptables -A FORWARD -p tcp -d 192.168.42.185 --dport 22 -j ACCEPT

Using the same technique one could run a webserver on a computer wirelessly connected to the network using an android phone. Just by changing the port to port 80:

# iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.42.185:80
# iptables -A FORWARD -p tcp -d 192.168.42.185 --dport 80 -j ACCEPT

Please note that iptables is partially supported on android, as far as I know is only the iptables binary available and not iptables-save & iptables-restore, you would need to compile these for your device. I do still have trouble saving my configuration, and the settings tend to reset very often, so I still have to look into it sometimes.

This article was very helpful: http://www.fclose.com/b/linux/816/port-forwarding-using-iptables/

2
  • 3
    It's great that you found a solution for your problem and posted it here. Thanks! But, you would really do us a favor if you'd include the essential parts of the answer here, and provide the link for reference. Aug 2, 2012 at 21:54
  • 1
    You really should try to mark your own answer as the correct one as well, it will look very pretty with the green checkmark next to it ;)
    – MoonSire
    Nov 13, 2013 at 5:50
0

If it is just about accessing the PC from your Android device, there are multiple approaches available. For example, to access it via SSH one could use ConnectBot (or ConnectBot ssh-agent). For graphical access, there are multiple VNC clients available (e.g. android-vnc-viewer or RealVNC's VNC Viewer). And finally, there are apps like TeamViewer for graphical access.

Possibilities and approaches there are plenty...

1
  • @Qurben I also highly recommend TeamViewer, which is a very good remote administration tool between computers, and between android os phone and computer.
    – thuyein
    Aug 2, 2012 at 10:40
0

Maybe LogMeIn for Android would do the trick?

1
  • Not what I was looking for, in my setup the phone is just a router. I wanted to use a different computer to connect to a computer behind an Android shared network.
    – Qurben
    Aug 2, 2012 at 22:16
-2

There are certain apps which could be used for this purpose. For Android "Team Viewer is everything. You can use simple numerical code by installing the client software. By means of this you will be given chances to transfer files between computer and mobile. The app works for 3G as well as 4G

1
  • 2
    Might help to have read the accepted self-answer, as well as the body of the question - the question was less about remote access, rather than using his phone as a router, and connecting to systems through it. This answer dosen't really answer the actual question. In addition, at least two other answers have mentioned teamviewer - what does your answer add that theirs dosen't?
    – Journeyman Geek
    Oct 31, 2013 at 10:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .