Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
1  
Possible duplicate: android.stackexchange.com/questions/1315/… –  Al E. Aug 1 '12 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 '12 at 21:54
add comment

4 Answers

up vote 3 down vote accepted

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/

share|improve this answer
2  
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. –  Oliver Salzburg Aug 2 '12 at 21:54
    
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 '13 at 5:50
add comment

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...

share|improve this answer
    
@Qurben I also highly recommend TeamViewer, which is a very good remote administration tool between computers, and between android os phone and computer. –  Titan Zack Aug 2 '12 at 10:40
add comment

Maybe LogMeIn for Android would do the trick?

share|improve this answer
    
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 '12 at 22:16
add comment

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

share|improve this answer
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 '13 at 10:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.