If you’re like most people, your Internet service provider hands you a single Internet Protocol address and your router shares it amongst all the connected devices in your home.
This actually violates the end-to-end principle, which the Internet was designed around. However, there are only so many IP addresses to go around – we’re running out.
Public IP Addresses Are a Limited Resource
There are less than 4.2 billion available IPv4 IP addresses. In other words, there are more connected devices on the planet than there are unique, public IP addresses for them. The Internet is running out of IPv4 addresses, even though we’re rationing them.
Rather than your Internet service provider assigning a unique public IP address to each device in your home – you would need an additional IP address every time you bought a new computer, tablet, smartphone, game console, or anything else – your ISP generally assigns you a single IP address.
Public vs. Private IP Addresses
Your router is connected directly to the Internet, and it’s assigned your public IP address (which may change over time). Your router is then responsible for sharing your public IP address among the other computers and connected devices in your home.
Your router assigns local IP addresses to your connected devices. This allows them to communicate amongst each other behind your router in your home. However, these local IP addresses aren’t reachable from the Internet. In other words, your public IP address might be something like 184.108.40.206. Anyone on the Internet can try to connect to this address, and they’d reach your router. Your computer’s private IP address might be something like 192.168.1.100. When someone on the Internet tries to connect to this address, their computer will look for the address 192.168.1.100 on their local network.
If this is a bit confusing, try thinking about an office building. The office building’s address may be 500 Fake Street, Fake Town, USA. Anyone can send mail to this address from anywhere in the world – this address is equivalent to a public address. An office in the office building might be “Room 203.” Like local IP addresses, “Room 203” isn’t a globally unique address – it’s used in many office buildings. You can’t address mail directly to Room 203 if you live on the other side of the world. You have to address mail to the office building itself.
Network Address Translation (NAT) & Port Forwarding
When you connect to something on the Internet – a website, for example – your computer sends the packets through your router. Your router modifies packets and assigns a unique port to each outgoing connection on the router. When the website or other server sends data back to you, it sends the data back to that specific port, and your router knows it should send the data back to the same device that initiated the original connection. This is how routers handle Internet traffic for multiple computers at once using a single IP address and knows where all the traffic should go.
However, this can break down when dealing with unrequested incoming traffic. For example, if someone tries to connect to your router’s IP address on their own accord, your router has no idea where it should send that traffic. All your router can do is take the traffic and discard it. This essentially means that your router acts as a sort of firewall, discarding unrequested inbound traffic.
If you want to receive this incoming traffic, you can set up port forwarding on your router. For example, you could tell your router that you’re running a Minecraft server on port 25565 at a specific local IP address. When your router receives a connection on port 25565, it knows it should pass that traffic through to the local IP address you specified. This is why port forwarding is necessary for applications that function as servers and receive unrequested inbound traffic from outside your local network.
Two Possible Futures
As we mentioned above, we’re running out of IPv4 IP addresses in spite of the rationing. In the long term, every device will hopefully have its own IP address. In the short term, you may not even have a single public IP address of your own.
- IPv6 Addresses for Each Device: IPv4 has less than 4.2 billion addresses, but IPv6 can offer 2128 possible IP addresses. Wolfram Alpha can help us put this huge number in perspective: That’s 340282366920938463463374607431768211456 different IP addresses, or about 50100000000000000000000000000 unique IP addresses for every person on the planet. Once IPv6 becomes more widespread and replaces IPv4, we could assign each connected device a unique IP address on the Internet.
- Carrier-Grade NAT: In the short term, some ISPs are struggling to provide IPv4 addresses to their customers. Carrier-grade NAT is a proposed solution some ISPs are looking into. An ISP using carrier-grade NAT would keep its public IP addresses for itself. It would use NAT (like your home router does) to hand out local IP addresses to all its customers. Customers wouldn’t have a unique public IP address of their own on the Internet and wouldn’t be able to use server software that requires port forwarding or direct connections.
The Internet was never designed for so many connected devices, and home routers with NAT technologies are the only reason we can connect so many devices without migrating to IPv6.