I have a SIM800C GSM module that I want to use to make a server. I am really confused about knowing the public IP address. In order to make people to connect to any server is that they need the correct public IP address and the correct port, and of course the correct protocol (TCP, HTTP and so on..).
There is already a command to get the local IP address (AT+CIFSR
); in case I make a server and I want to let my friends connect to it, I need the public IP address. How do I get it?
I searched on the internet but found nothing.
AT+CIFSR
(as well as the standard command AT+CGPADDR
) returns your IP as soon as you activate the PDP context. Unfortunately, if it is public or not depends on your operator. In fact, due to the need to face the IPv4 address exhaustion they often perform a Network Address Translation (NAT) that will actually provide a local IP to your device.
As a consequence, your device won't be reachable for communications that are not device-initiated, and you won't able to create a public server at all.
So, that's not a public IP opposed to a local IP: there's just the IP you obtain from the network. If doesn't perform NAT, then the IP you obtain with AT+CIFSR
will be the public one.
Usually the NATted IP limitation is faced with a design trick
If the design solution is not feasible, there's another option involving the purchase of special (and more expensive...) SIMs specific for M2M and IOT applications: