Question Why do ip address changes time to time?

Ganesh Ujwal123

Distinguished
Jan 5, 2015
56
0
18,540
Is there any reason for it? It's general question.

My friend told because of efficiency. But I didn't quite understand .

I am referring to dynamic ip address.
 
you mean your LAN IP address or your ISP provided IP address?

if you talk about the latter: it's for 3 reasons:
  • a shortage of IPv4 addresses. since not everyone is always online at the same time your ISP assigns a certain range of addresses that get assigned to devices requesting one. that way you can save some addresses as ISP which cost some money.
  • many ISPs charge extra for a static IP address. so it's a way to make money
  • in theory a static IP makes you more vulnerable to outside attacks. not necessarily by people who know what they're doing but rather people who don't.

the assigning process is usually handled the same way as your local network does: DHCP. so you have an address range from let's say 2-254, they get assigned first come first serve for a fixed amount of time. after that time a device requests another lease and gets the lowest available value. if multiple devices request one at the same time it's depending on the individual latency and a number of other factors which one is considered "first" and "last" by the DHCP server.
 
So you need to understand how IP address are given out, ie DHCP. "The Dynamic Host Configuration Protocol (DHCP) is a network management protocol used on Internet Protocol networks whereby a DHCP server dynamically assigns an IP address and other network configuration parameters to each device on a network so they can communicate with other IP networks.":
https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol

The information given out by a DHCP server, which includes the IP address is valid for a limited time set by the DHCP server administrator. After that time period, the DHCP server will 'release' the information and it has to be re-requested. Now, generally as soon as a device loses its reservation (or when the reservation time is about to end), the device will immediately send a request. Because of the speed of this cancellation and renewal, most of the times the IP address will be the same. And most DHCP servers use caching, so a lot of times the same address is re-issued even after a period of hours as long as the MAC address doesn't change.

Knowing this, there is always a chance that an IP address that loses its reservation will not be reissued to a client because it is assigned to someone else before the client renews it. It is rare because of the near instantaneous cancellation and renewal requests, but it can happen.

Now, I mentioned MAC address before. The MAC address on every ethernet device is what uniquely identifies that client to the DHCP server. The DHCP server uses that MAC address to know what device has what IP address. If for some reason that MAC address changes, like when someone purchases a new router (which has a different MAC address than the old one), the IP address given out by the DHCP server can change. This is why routers have a 'MAC clone' feature that will allow you to set the MAC address being reported to the DHCP server in order to preserve the current IP address.

The third way I've found that DHCP IP address change is when an isp has an infrastructure change such as changing head-end equipment or rearranging networks. Then they may change DHCP pools, or completely re-route traffic so that your device is not connecting inside their network where it once was. In that case, when the reservation ends and your device sends its request, you will get a new IP, even if you were connected continuously.

I have some permanent networks that are based on DHCP IP addresses (IPsec site-to-site vpn tunnels). This is usually not done using DHCP addresses because of the fact that DHCP IP addresses can change. However, in my experience the only times I've had to reconfigure these networks for an IP change has been in the above scenarios, and that's been like 3 times in the last 7 years. If your device is on 24x7 and your isp isn't growing/shrinking/upgradeing/etc, the likelihood of your IP changing is very slim.

Hope this tells you everything you wanted to know!
 

kanewolf

Titan
Moderator
So Your dynamic ip comes as my ip after several days?
It could. Some ISPs are less dynamic. My IP only changes after weeks even though it has expired several times.
Another reason your public IP can change is that the ISP has to do maintenance and changes the hardware you connection traverses. It is easier to just change your IP to force your traffic to change paths.
 

kanewolf

Titan
Moderator
What do you mean ip address expired? So you won't get internet until expiry ip changes?
A DHCP IP address is called a "lease" because it has an expiration. Your router will automatically ask your ISP to renew the address before it expires. Your ISP can give you the same IP again or give you a different address. This is why the DDNS protocol exists. It allows a constant URL to be associated with the dynamic IP. If you have DDNS configured on your router, the the router will update the DDNS provider each time your public IP changes.
 
This is one of those things do you really want to learn the details how DHCP works or do you just want to know that from time to time your IP address can change.

DHCP is designed to re use addresses that someone is not using.

Generally your IP address with not change if you leave your router powered on. If you lose power or it just reboots you may or may not get the same ip address assigned. Sometime if the ISP equipment is reset for some reason it will force a change.
 
In many cases on mobile you do not get a actual public IP assigned to you. They assign private IP and then use carrier NAT.

Still even the shared IP does not change very often.

Mobile is actually one of the most complex forms of networking there is. When you can actually drive across a country and the IP address NOT change as you move from city to city and cell tower to cell tower that is actually impressive. It is basically a form of VPN even though it is actually a very different technology.
 
In mobile it is a big different and it depends if you have the actual public IP assigned to your phone or you are sharing one.

It is much more common to share the IP. The sharing is done via NAT. The length of time you share this IP before you are assigned a different one is based on how long it has been since you last sent traffic. This is a concept called sticky IP NAT. Again you getting into a very advanced concept that mobile providers use to load balance their traffic. Pretty much if you don't use it for a couple minutes it can change
 

kanewolf

Titan
Moderator
If lease time is up, then my private ip also chanGe with public ip? This question is not related to mobile ISP , I am asking about home LAN .
That is not what you said above
I am asking question about ip multiple changes in mobile ISP (not wifi) but you are saying ip will same at several places. I am confused.
Choose what you want to ask about...
 
If you have private IP address then there is NAT involved. This greatly depends on the ISP and how they implement it. You are sharing the public IP and depending on how many other people you share it with they may change based on the load. In general they try to not change the public IP but if you do not send any traffic for a period of time they may assign you to a different pool the next time.
 
No let say you open netflix and play movies for 2 days straight. Your IP address will likely not change because it would force you to log back into netflix and the ISP does not want to cause this. It even works like this on cell phones. BUT if you were to close the application and do nothing for even a couple a minutes you run the risk your IP changes. In general even if you do not use it for a period of time it will not change but it all depends on how many other people you are sharing with. They try to avoid having lots of people share the same IP if they don't have to so they will move people around to better load balance the traffic.
 

beers

Distinguished
BANNED
Oct 4, 2012
261
53
18,790
Think of what a pain in the ass it would be if everyone had a static address. The administrative overhead would be huge and you wouldn't have an opportunity to re-use addresses for other devices that were offline, even if you ran out and needed one.

DHCP is leveraged on the ISP to both better use the existing space for 'actually online devices', as well as the seamlessness they can use by just saying 'we'll allocate you one out of this set of addresses'. Then, it's all automatic.

If your client doesn't renew its lease (offline or similar) or the DHCP server loses its list of client bindings, then you could get another address. A lot of them stay the same due to common consumer routers being online all the time and similar. Plus they can simply ship out a generic device that will allocate its own address (by using what the upstream DHCP server provides it) and join the network. With statics you'd have to have every device manually configured.
 

Ganesh Ujwal123

Distinguished
Jan 5, 2015
56
0
18,540
No let say you open netflix and play movies for 2 days straight. Your IP address will likely not change because it would force you to log back into netflix and the ISP does not want to cause this.

If my ip address doesn't change then my netflix account stay login even if I log off?

My another question: If they allocate unique private ip for everyone why can't they allocate static ip as publlic ip?