Make it so that multiple devices connected to the same router get their own public IP

I am trying to make my router work in such a way that every device attached to it receives their own unique public IP address, so that any computer would be able to use a direct P2P connection. I would have thought this was impossible until I found out that every device connected to my schools WiFi receives their own public IP, starting with 199.80.254.70, and ending with 199.83.254.70, meaning over 3000 devices can receive their own unique public IP address. For my schools ISP on speedtest.net, it just shows "Palo Alto Unified School District", and judging by that, they are not registered with any major tier-2 ISP.

I am pretty sure this would be impossible with Xfinity or TWC, but I was wondering how my school does it, and if it would be possible for me to somehow do the same.


Q: How do they get that many publicly-routable IPs?

Your school could possibly have a static IP address range assigned to them by their Internet Service Provider (ISP), by virtue of the fact that a school district is a fairly large customer (orders of magnitude larger in terms of money than a single family home, to be sure). Note that you can't simply change a setting in your router to enable additional IP addresses; you must specifically have them assigned to you, by your ISP.

Since IPv4 space is limited, and is becoming more limited by the day -- see IPv4 Exhaustion -- end users are the first "victims" of having more limited access to IPv4 addresses, since (ISPs think that) most end users don't have many use cases for exposing "listening" services to the public Internet. In fact, many residential ISPs write into their Terms of Service (ToS) that you are forbidden from hosting any Web or Email servers on your home internet connection.

This ToS policy is at least consistent with the fact that you may be granted an extremely limited number of publicly-routable IPv4 addresses uniquely assigned to your household, since the only real use case that is "blocked" by having few or no unique IPs is hosting services.

Therefore, many home ISPs are limiting end-users to 1 or even 0 unique public IP addresses per household. "Wait, 0?!" you may ask. Well, yes. Thanks to Carrier-grade NAT, an ISP can assign multiple customers a single public IPv4 address. You then, in turn, have a Local Area Network (LAN) set up by your router which provides a local IP address, providing two layers of indirection between your home router equipment and the public Internet. So you'd have the LAN, the CGN, then finally the Internet.

One unfortunate downside of not having a unique IPv4 address to your name is that, if a website, such as SuperUser or Wikipedia, decides to block someone else who happens to have your same publicly-routable IPv4 address -- for example, due to that user's bad behavior, or spamming -- you can be affected, too, because the website is unable to distinguish between different hosts behind the CGN. This is also true of large LANs, which are sometimes manifested in college campuses sharing one large pipe among several dormitories.

You may or may not have a CGN on your home Internet connection, and this isn't all that relevant to the point of my answer. The point is, if millions of people in the world now live with the reality of being under a CGN and therefore don't have any unique publicly-routable IPv4 address to their name, the likelihood of you being able to get additional licenses for IPv4 addresses from a home ISP -- at least, without paying a pretty penny for them -- is fairly low. That's not to say it's impossible, just that it would take a phone call and possibly an addition to your monthly bill (this would vary greatly depending on where you live and your exact ISP).

My observation is that large customers such as businesses, retail dedicated server hosting companies, etc. are getting the lion's share of the remaining IPv4 addresses allocated to them. This makes sense: the likelihood of a school wanting to host a website (run by technically-inclined kids, for instance) is much greater, in the minds of those people in control of these limited IPv4 addresses, than, say, the need of a home user to set up an HTTP server on their home computer and expose it to the public Internet. Similarly for dedicated hosting providers: almost every dedicated server has a very specific need to host several services on the public Internet, so this is almost a hard requirement for most use cases, or you may as well not even have a server. So it isn't unheard of to be able to get an additional IPv4 address for, say, $1 per month from a dedicated hosting provider for a server.


Be wary of pitfalls!

EDIT: I wrote this section under the incorrect assumption that the OP meant "Peer to Peer file sharing" by "P2P". Instead he means peer to peer hosted PC games, an entirely different thing. Leaving this here for posterity's sake anyway.

I will add that "Peer to Peer" transfer of content which violates copyright could possibly endanger your sustained access to your Internet connection in a number of ways:

  • Your ISP may become aware that you are transferring content that infringes copyrights, and slow down your connection as a result;
  • Your ISP may notice that you are sending a disproportionately high amount of traffic compared to the average, and slow you down as a result;
  • Your ISP may send you threatening notices (as, for example, Comcast does) if they can specifically determine that the nature of the content infringes copyright or trademark laws, and eventually disconnect your service if you ignore these notices;
  • Your ISP may consider that the "listening" part of your peer-to-peer protocol counts as hosting a "service", and consider this a violation of their Terms of Service, and threaten to disconnect your service if you persist.

So, even if you did get access to a small pool of IPv4 publicly-routable internet addresses, whether statically or dynamically allocated, you would be potentially facing some legal hot water for your actions if your ISP is specifically designated as a "residential" or "home" internet solution. You would encounter fewer barriers if you upgraded to "business-class" service -- at least in the United States -- but you would still have to deal with the legal ramifications of transmitting content that infringes copyright laws, if that is what you plan on doing.


Sharing a Single IP

In case you don't want to pay lots more money to host your games, you can employ the following technique to share a single publicly-routable IP for quite a few games simultaneously:

Assuming (and this may not hold true for every game, unfortunately) that you can somehow change the port(s) that the game expects to use, and you only have one unique, publicly-routable IP address assigned to your router, you can do the following:

  1. For each separate "instance" of each game that needs to share "the same" port number, change all the port numbers in the game's configuration to be different ports. You can pick anything from port 1 to 65535, but I would highly recommend that you stick to the range 1024 to 64000 for technical reasons. You can of course try ports outside that range if you really want to, but YMMV.

  2. Once you have, e.g., Computer "A" configured to listen on ports 1234 and 5678, and Computer "B" listening on ports 2345 and 3456, go into your router or modem's Port Forwarding settings and tell it to forward these ports to the local IP addresses of your machines. I recommend that you assign static LAN IPs to each of the computers on your LAN for this purpose. Just pick any IP address within the subnet. So if it's 192.168.0.0/24 (a pretty common subnet by default), you could pick anything from 192.168.0.2 through 192.168.0.254, assuming your modem/router is on 192.168.0.1. The exact click-by-click steps to set this up will vary widely depending on your exact equipment make and model, and will be significantly more complicated if you have multiple layers of NAT (e.g. a modem+router NAT, and another router behind that).

  3. When having peer to peer matchups in your games, simply tell your opponent(s) the port numbers you chose for the game.

You can repeat these steps for many thousands of simultaneous game instances, so that should be enough (hopefully).


IPv6

Lastly, a word on IPv6. Unfortunately, native IPv6 is still not available to a great many people. It is our hope that we can deploy IPv6 on a wide enough scale that the importance of IPv4 can start to take a nose-dive, eventually becoming irrelevant, as a critical mass of people are able to connect to services (such as websites, email servers, DNS servers, etc.) using IPv6. IPv6 has so many more addresses than IPv4 that the current plan is to assign each residential customer a /64 class address space, which provides you with 18,446,744,073,709,551,616 publicly-routable IP addresses. If you have more computers and smart devices than that in your house, I don't know what to tell you. ;-))