Here is the scenario:

I have a raspberry pi that is connected to the internet via Mobile hotspot.The hotspot uses mobile data from my Android.Everytime I turn off my mobile data, the ip changes.So I need to search the ip again.

I have tried dhcp but it doesn't work as expected.

What I want to do is: Use same the same ip for raspberry pi

3 Answers 3


Normally mobile phones have a dynamic IP address issued every time they connect to the network due to the mobile carrier have a NAT firewall as part of the connection.

One way around this is to use a dynamic IP service such as dynu.com (others do exist) and refresh the data each time it changes.

The better way is to talk to your carrier or a third party specialist such as Nucleus (again others can provide this) for a fixed IP Sim. These are often used in fuel and remote camera management (quiet well from past experience) but can be more expensive than normal SIMs to run and are often data only.

I have not seen a 5G offering (I am in the UK) or an offering for a static IPv6 address yet BUT due to location I was restricted to carriers that did not offer either IPv6 or 5G services!

The third way - not always possible in applications is to set up the network where the Pi pushes data out to, and reads instructions from, a static site.

Out of the three - I would go with the dynamic IP addressing unless the device changes IP very frequently as low TTL entries on DNS can cause update issues.

  • Interesting... a fixed IP SIM card - no idea such a thing was even offered. Dynamic IP would be less useful if the IP address changed frequently (as in several times a day as I've seen it do).
    – Seamus
    Jun 9, 2020 at 4:28

I don't see a usable possibility to have a static ip address with a mobile internet connection. The mobile device must give the RasPi a default route with its gateway. The gateway isn't static so you really should use DHCP.

With Raspbian or Raspberry Pi OS accepting network settings from a DHCP server (your Android cell phone) is working out of the box with its default dhcpcd.service. So you should either use Raspberry Pi OS or revert your network settings to default if you already use Raspbian/RaspiOS.


The same way you would with any other connection.

Whether it would work depends on the device to which it is connected.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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