I’ve been diving into the public and private IP addresses, as I could understand public IP addresses are assigned by Internet Service Providers, but I couldn’t understand how and by whom are private IP addresses assigned. I couldn’t understand as well what’s the purpose of private IP addresses.
Any help is appreciated. Thank you for helping me out.
In: Other
Computer networks are implemented in a layered architecture where each layer is responsible for a small part of the overall communications problem. The IP Address layer (Layer 3) connects networks of machines, both locally, and over a wide area.
Private IP Addresses are a reserved area of the overall address space that are either machine local (127.x,y.z) or private to an organization (for example 10.x.y.z, or 192.168.y.z). These are in contrast to IP addresses that can be routed over the public internet including classless internet domain routing address blocks, multicast address blocks, and other reserved reserved address spaces.
So public IPs and private IPs are really just different numbers, but are important because depending on those numbers they will be treated differently by internet and internal routers, gateways, and firewalls.
Here’s a very simplified analogy:
Private IP addresses are like apartment numbers. No one can find your apartment with just your apartment number unless they are in the building. The building owner can number the apartments any way they want.
Public IP addresses are like your street address. You get your public IP address assigned by your Internet service provider.
You just do whatever you want. Everyone on earth is free to use 10.x.x.x or 192.168.x.x for anything in their own network. (or the 172 class B one no one likes)
So there is like a million people all using [192.168.168.1](https://192.168.168.1) as their router, or [10.10.10.10](https://10.10.10.10) as their computer. You can do whatever you want, hand assign them, have a dhcp server hand them out on your network. whatever. They won’t cross the real internet so inside your own network anything is fine.
Everyone can use them and everyone uses the same ones and it’s fine.
Your internet service provider (isp) assigns you a ip address. Your router uses that IP address to talk to the outside world. But your internal network will have multiple devices and every one of those devices will also need a ip address. So your routers assigns them a IP. Your router does all the conversions from internal to external and opposite.
Imagine you work in a large office building.
Your public IP address is the street address of your building. Anyone in the world can send a package to that address because it uniquely identifies one place. The addressing scheme is owned by the post office because it has to make sense in a global scope.
Your private IP address is your office number within the building. It is meaningless to someone outside but useful within the building. The building owners are free to assign office numbers however they want.
Within the building, you can address a package to Bob in office 1234 and the mail room will get it to him. But outside the building, if you try to just mail a package to “office 1234” it will never arrive because there are many “office 1234″s in buildings around the world. Instead, an outside sender would address a package to the building and then the mail room would route it internally.
Along with everything everyone else said, its important to know: there are not enough IP addresses (IPv4 specifically). There are only around 4.29 billion possible variations of an IP address, which is not nearly enough for the amount of people and devices in the world.
Private IPs are one solution to this problem. One building/company/group/etc will be assigned one public facing IP address, and everyone inside that network (known as Local Area Network (LAN)) will have their own private IP addresses assigned by the router. This usually starts with 192 or 172 or 10.
So everyone inside that building will have their own private IP, but when they connect to the internet they will all share the same public IP. If you’ve ever had a sibling get banned from a Minecraft server and it makes everyone else in the house banned too, this is why.
So how does the internet know how to serve webpages and info to your specific machine despite you sharing the same IP with others? Simply, the router keeps track of whos making the request out to the web page, so when it gets a response, it will remember that you made the request and direct it back to you.
If the the connection initiates on the outside (for example, if you’re hosting a Minecraft server and want people to connect to it), then you need to set up portforwarding on your router. This tells the router “hey, any connection to my public IP over the port [###] should get directed to my private IP specifically”. The router wouldn’t know where to direct that traffic otherwise.
Hope this makes sense. Also, if you’re curious, you can check your private IP by typing ipconfig in your command prompt, and you can check your public IP by going to whatismyip.com
Whenever a device joins a Wi-Fi network, that device is automatically given a private IP address by the Wi-Fi router (private IPs are not limited to wifi networks, but that’s mostly what the average consumer is using).
Your phones, tablets, smart TV, Ps5, everything in your house on your wifi network is given a private IP by your wifi router.
Your modem (or ISP gateway device, whatever you got from your provider) is assigned a single public IP by your Internet provider so that your residence can connect to the Internet.
So it’s almost like your Public IP is your house street address, and the private IPs are the names of the people inside.
Here’s a good ELI5 type answer.
Imagine a public address as your street address or an office’s main telephone number. It is unique. There is only one 2345 Main Street, Anytown, USA address. Or only one 234-567-8901 phone number.
But inside that street address, you have rooms. Kitchen. Bathroom. Bedroom. Or at that office you have extensions. x101, x202, etc.
Any home can have a kitchen, a bathroom, a bedroom. Any office can have x101 or x202.
Latest Answers