Can any computer connect to a SSH server running on an android phone connected to a wireless mobile network?

by Tim   Last Updated March 14, 2019 19:11 PM

I run a ssh server on an Android phone using SimpleSSHD.

When the phone is connected to a wifi network, I can connect to the SSH server from a computer in the same wifi network.

When the phone is connected to a carrier's wireless mobile network, I found an IP address on the android phone in "Settings-> About Phone -> Status". How can I find out if the IP address is a public IP address for the phone's network interface, or shared by many devices in the same LAN? Can any computer connected to the Internet connect to the SSH server using the phone's IP address? It seems that I can't, and I was wondering why?

$ ssh -p 2222 11.22.333.444
ssh: connect to host 11.22.333.444 port 2222: Connection timed out

Thanks.

Tags : ssh ip-address


Answers 2


For running a SSH server on a Smartphone connected via mobile data to the Internet you need a public IP address on the mobile network interface.

You can simple check if your IP is a public one: Enable mobile data and disable Wifi on your phone and check the IP address you have (Phone status in Android settings). If the IP address starts with 10.x.x.x or 192.168.x.x it is obviously a private IP address. If not open your web browser on the phone and go to https://www.whatismyip.com. Compare the IP address shown there with the one one in your phone settings. If they match your IP is a public one.

Unless you have a special mobile data plan, the majority of mobile network operators (MSO) will not assign your device a public IP address. Instead you are getting a private IP address that needs to pass a NAT gateway running in the MNO's network. The main reason for this situation is that the IPv4 addresses are rare - most MNOs don't have enough IPv4 addresses to assign every mobile device a public IPv4 address.

Some MNO offer special data plans with a public IP address - usually only for business customers and with higher prices.

The whole situation is similar to a Smartphone connected to a Wifi in a network with a NAT router that is connected via DSL/cable to the Internet. But in difference the NAT router is not accessible so that nobody can open up ports (port forwarding) to make a service accessible running on a system in the network behind the NAT router.

Robert
Robert
March 14, 2019 18:21 PM

Can any computer connected to the Internet connect to the SSH server using the phone's IP address?

depends on how your ssh server is configured, along with TCP wrappers. By default, that is typically yes. However you can restrict who and from where can successfully connect via SSH by editing /etc/hosts.allow and changing

SSHD : ALL : ALLOW

to something more restrictive. There is also /etc/hosts.deny you can play with, along with editting /etc/ssh/sshd_config. Realize SSH is the protocol and is completely independent of the computer system... if my dell laptop follows the SSH protocol and a coke machine follows the same version of the SSH protocol, then a valid communication link can be established between the two... over TCP/IP. When this will not work is when that communication is blocked via some other means. Not to mention firewall settings...

How can I find out if the IP address is a public IP address for the phone's network interface.

use a browser on the phone and go to a website that will report back to you the [public] ip address it sees your phone as. If that reported address matches what is in Phone_Settings, then that would be a yes. But I can tell you what ip address your phone settings is saying is not a public ip address, for the same reason my home computer through the comcast modem gives my home computer 10.0.0.1. Simply web search what is my public ip to find any of a hundred sites that will tell you your public IP.

unix&linux > AndroidEnthusiasts :)

ron
ron
March 14, 2019 18:50 PM

Related Questions


Locating ARP cache on an android device

Updated April 19, 2017 04:11 AM

Can't find "iplink" program on rooted phone

Updated April 14, 2015 02:34 AM

Android NIC MAC address changed automatically

Updated May 17, 2015 22:04 PM


Cannot turn on Wifi. MAC address unavailable

Updated August 08, 2015 14:05 PM