1

This question already has an answer here:

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.

marked as duplicate by Andy Yan, Firelord Mar 15 at 3:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from unix.stackexchange.com Mar 14 at 18:13

This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.

  • I would suspect at least part of the answer would require knowledge of the protocols and ports that the Carrier's router would forward. And that might differ by carrier. – KevinO Mar 14 at 18:06
1

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.

  • This is also known as Carrier Grade Nat, right? – DavidPostill Mar 14 at 18:23
  • @DavidPostill You are right. – Robert Mar 14 at 18:28
0

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 :)

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