How often do IP addresses change?

Started by
8 comments, last by Hodgman 14 years, 7 months ago
I was considering checking only the user agent string to prevent session hijacking, but I was thinking that maybe that would be a bit insecure. If an attacker had the same user agent string as another user then he could easily compromise his session. So, I'm thinking of verifying the IP address. I do know that they change quite often though. My IP addresses changes about every hour and the first set of numbers changes every few hours. Do you think it would be better to just check the first set? For example, if a user's IP changed from 128.10.10.2 to 128.97.62.50 then it would still be valid. Or should I check for the first two sets of numbers? I'm not sure how to approach this. I want as much security as possible for user sessions but I also don't want users to be logged out when they're doing something important, just because their IP address changes and invalidates their session. My question: How often do IP addresses change, and how should I approach this problem?
Advertisement
A user's IP address is not a reliable identifier, period. Even if you did it by block (which if done, would be done by proper netmasking after you do a whois to see who owns the IP), people will login from different computers/networks.

Authentication is hard to do right. Take an established package, and use that.
Telastyn is right. If you're worried about session hijacking, find a reputable session authentication package and incorporate it into your project. Security is hard, and what's worse, it's very easy for a non-expert to think that his home-made system is secure when in fact it isn't.
Jetblade: an open-source 2D platforming game in the style of Metroid and Castlevania, with procedurally-generated levels
As far as I know web session can not be hijacked, if it can, its more likely a bug in the web server. The only possible ways to hijack session is to:
a) Use packet sniffer
b) Force the user to share his session data (methods like XSS).

About IP change, I don't know how it is going on other countries but at mine we can have either dynamic or static IP. For home users dynamic IP allocated every time you dial the net, and static IPs given for period of 3 days I think.

I would love to change the world, but they won’t give me the source code.

Ugh, a quick summary of IPv4 addressing, which while not complete is probably better than the guesswork shown so far.

IP Addresses are sold in blocks. "low" addresses (001-126.*.*.* iirc) were very large blocks. These were originally allocated mostly to universities and large businesses (3.*.*.* is General Electric for example). Smaller blocks (128.1.*.* to 191.254.*.* and then 192.1.1.* to 223.254.254.*) are later numbers, generally decreasing in size as demand historically increased.

The blocks generally do not change. Originally, a company (or ISP) would buy a range of IP addresses and divvy them out to computers/subscribers as they got them. These are your traditional static IPs. They're set to a network interface, and stay there until unset.

As the internet exploded, the number of addresses compared to computers has become a problem. Even the simple process of divvying a pool of addresses became a burden. Dynamic addressing was viewed as a partial solution to these. Even if a ISP has tons of customers, only a fraction of them are online at any given time. So a protocol was developed to essentially ask a server for an IP from a pool of available addresses, and then set the IP with the response.

There is also timeouts involved that will cause the computer to re-acquire an IP every so often (~8 hours is probably average. I've seen as long as a week or as little as 2 hours). Often, you'll get the same IP. If you reboot, you'll usually get a new one (though some dynamic IP servers will try to give the same computer the same IP if they can).


Something else to consider is Network Address Translation (hereafter, NAT). Even dynamic addressing wasn't enough to make enough addresses for everyone that wanted them. As such NAT has become more common. What it does is hide a bunch of computers behind a single internet visible IP. This is very common at businesses, and for home networks. The internet visible IP may be static or may be dynamic. It does tend to be more consistent, but can represent a vast number of physical users 'hidden' behind it.


These days, most game playing users will probably be behind a NAT on a infrequently changing dynamic IP. Some standard home router on a standard cable modem/DSL service that only changes IPs when the cablemodem is powered off or the ISP does maintenance. But they'll also often login from a friends' machine, or from a laptop on a random wifi network, or from work... all of which will provide a different source IP for the user.
Quote:Original post by Telastyn
Ugh, a quick summary of IPv4 addressing, which while not complete is probably better than the guesswork shown so far.

IP Addresses are sold in blocks. "low" addresses (001-126.*.*.* iirc) were very large blocks. These were originally allocated mostly to universities and large businesses (3.*.*.* is General Electric for example). Smaller blocks (128.1.*.* to 191.254.*.* and then 192.1.1.* to 223.254.254.*) are later numbers, generally decreasing in size as demand historically increased.

What you're talking about there is called classful addressing, and it hasn't been used in a VERY long time. Now days blocks of IPs can be sold from any range (excluding reserved ranges) in any length denomination provided it fits within a traditional subnet mask format (CIDR). That means one could purchase a 15.2.4.0/10 range for instance. A lot of previous "class A" and "class B" address ranges were purchased back (or aquired using other means) from the companies that held them and repurposed after CIDR was implemented.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Quite true. I did not emphasize the past tense of that arrangement enough in rereading.
Quote:Original post by s.kwee
and static IPs given for period of 3 days I think.

Static IPs are permanent, and will not change as long as you have a valid contract with your ISP. That's why they are called static :)
Quote:Original post by s.kwee
As far as I know web session can not be hijacked, if it can, its more likely a bug in the web server. The only possible ways to hijack session is to:
a) Use packet sniffer
b) Force the user to share his session data (methods like XSS).

About IP change, I don't know how it is going on other countries but at mine we can have either dynamic or static IP. For home users dynamic IP allocated every time you dial the net, and static IPs given for period of 3 days I think.


That would suck for google and ebay and whatnot if their IP's changed every few days.

static means unchanging or fixed in this context
--------------------------------------Not All Martyrs See Divinity, But At Least You Tried
Quote:Original post by s.kwee
As far as I know web session can not be hijacked, if it can, its more likely a bug in the web server. The only possible ways to hijack session is to:
a) Use packet sniffer
b) Force the user to share his session data (methods like XSS).

c) Guess the user's session ID (possibly trivial due to said bugs)
d) Trick the user into using a pre-arranged session ID - e.g. via links in spam emails (PHP websites allow the user to choose their own session ID by default...)

This topic is closed to new replies.

Advertisement