I kinda get how it makes sense on a local network, because it’s kinda like a list of the devices that are connected to it and your trying to communicate with other machines connected together in that same list. But this feels like a really surface level understanding and I don’t know what I’m missing.
I understand that they’re a string of 4 digits from 1-255, such as 192.168.1.1 being really common for home networks. But I don’t know what the numbers each mean. I think 192 in this case is a reserved value for home use? Same with 10? And the last number is basically the number of the device on the network I think. But I don’t understand the numbers for x.168.1.x
What I really don’t understand is how public IPs work. You hear online about not leaking or sharing your public IP or it can be used to find (pretty close to) where you live. How? How are they assigned to the billions of connected devices in the world?
I’ve been watching videos about trying to set up a FOSS router because it’s really interesting, but IPs seem like dark magic to me
In: Technology
The IP address is actually two different things, it is the host address and the network address, it is why you need something called a ‘subnet mask’. The subnet mask tells routers and hosts where the network address ends and host address starts.
Lets play ‘a day in the life of a packet,’ that is a data packet that starts at your local computer and wants to get to some website, say [www.reddit.com](http://www.reddit.com).
1. Host does a DNS lookup to resolve [www.reddit.com](http://www.reddit.com) to an IP address
2. Host looks in their local routing table for a route to that network, more than likely it won’t have one so it uses its ‘route of last resort’, or more commonly called a default gateway.
3. The default gateway receives the packet and checks its routing table to see if it has a route to the destination network. At this point, more than likely, it will strip the originator IP address and replace it with its own, this is called a NAT, or network address translation. Strictly speaking, you don’t need to NAT, but more than likely you are. Essentially the router tacks on a port number or some other number so the address looks like this [publicIPofrouter:sequencenumber] and that allows the router to understand how to “NAT back” when it gets a response.
4. The next router gets the packet and looks at its routing table to see if it has a route to that network, if it doesn’t, it sends it to its route of last resort.
5 …
6 …
7 … Hooray, we have found a router that ‘owns’ the network address in question. The router will ARP out of the interface that shares the network address asking for the host at the specified host address to send the router its MAC address. When it responds, the router will deliver the packets to the host at its MAC address.
This is specific to IPV4, IPV6 is 64 bits and the network/host addresses are evenly split in 32 bit blocks, and they don’t use ARP, but that is a whole different animal.
Latest Answers