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.
Design work-around
Usually the NATted IP limitation is faced with a design trick
- A wake-up SMS is sent to the device hosting the server. The SMS can either be a basic one (just text containing data relevant to the application) or a special SMS type (Wap Push notifications).
- As soon it receives the SMS, the device starts the server and sends some data to the remote peer
- This will result in a device initiated communication, so from the network side the NAT will be opened and the device will be temporarily public.
- After a certain inactivity time (operator dependent) the NAT will be closed again
"Commercial" solution
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:
- SIMs which will always obtain a public IP
- SIMs which will always obtain a public fixed IP