Question about ip's

I’m making a voting site where the user is restricted to one vote. I’m wanting to use req.ip, but because i’m testing on local host it’s always ‘ffff:127.0.0.1’. will this be different once it’s deployed? will 2 different computers on the same internet have a different ip? will a computer that doesn’t have a static ip have a different ip every time they restart their computer and hence be able to vote on every restart? I’ve only really dealt with internal ip’s (very minimally) so i’m just not to sure how the external one works.

There’s a lot to unpack here.

will 2 different computers on the same internet have a different ip?

Generally, Yes. But not in all cases.

will a computer that doesn’t have a static ip have a different ip every time they restart their computer and hence be able to vote on every restart?

Usually, there’s a router in front of the customer. So even if user rebooted their computer, they’ll still have the same public IP provided by their ISP (but the user’s computer may get a different private/local IP address)

If customer rebooted their router, then there’s no guarantee that the ISP will assign the same IP address to customer. But usually, ISPs even those that provide dynamic IPs, usually assign the same dynamic IP address to customer even if customer reboots their router. There’s what you call a DHCP lease period. Usually a week, sometimes more, sometimes less.

There are also ISPs where they assign the same public IP address to many of their customers. So all their customers are behind their network.

If multiple users are inside a company network, when they connect to the outside world/internet, they’ll be presenting the same IP address.

Also, don’t forget a voter may connect to a VPN service and therefore will present you a different IP address on their next visit to your site.

and for more advanced users, the source IP address can be faked and therefore present to your app a new/different IP address everytime they visit you.

1 Like

Thanks for the awesome reply! I plan on also having polls that only let users vote if they have authenticated their phone through twitter, I just wanted something else (like an ip adress) that I could stop users from voting multiple times, I might just make everyone sign in if they want to vote though, considering all the problems you brought up.