Chances are that if you found this page through a Google search, you're probably looking for information on how addressing and routing actually works, without getting too deep into the complicated, underlying logic and binary math that serves as the foundationg for modern networking. At some point, I was looking for just this kind of information and ended up spending untold hours poring through texts trying to put it all together. So my goal with this article, is to save you as much time as possible. However, because it's so fundamental to routing, avoiding math entirely won't be possible.
So, for example, let's take a common IPv4 address, 192.168.1.1; each of the numbers between the dots actually represent the sum of eight of the total of 32 binary bits that make up an ip address. The maximum count that 8 bits can add up to is 256 (28), but every one of those numbers range from 0 to 254 since the count starts with 0 in computing and 255 is reserved as the broeadcast address for the entire network. This allows for a potential of around 4.3 billion addresses under the IPv4 system.
When using IP addressing, you'll definitely run into the subnet mask. We use a subnet mask to organize local networks into different subnetworks. In most cases, we actually don't split networks and just use a default mask of 255.255.255.0. Each number between the dots designates how many addresses you can have within each subnet. A 255 means that this will be an unchanged number in the network. So with the subnet 255.255.255.0, the last zero designates the numbers that can be assigned to individual devices on the local network.
The last detail here is the default gateway. The gateway is usually your router; the device that translates your local network calls to the larger internet. Your router will also usually carry the first number in your local network. Using our example, this address is 192.168.1.1.
So let's put all of this together. My computer address of 192.168.1.2, with the 255.255.255.0 subnet mask, means that I belong to a network that beings with 192.168.1.1 (the router), and any devices can be assigned addresses between 192.168.1.1-254 can be accessed directly.
Depending on how many addresses you want to use for your devices on your local network, you might use a different subnet mask. Using a mask of 255.255.0.0 will open up addresses from 192.168.0.0 to 192.168.254.254. This is consistent with the 0s with in the subnet mask that allow the entire set of bits to be used for the device addresses.
Sometimes IP addresses and subnet masks are written together using a special notation. So an address of 192.168.1.0 with a mask of 255.255.255.0 can be written as 192.168.1.0/24. The number after the slash represents the number of set of bits that designate the subnet. So 24 means, basically, "the first 24 bits of the address are the subnet address.
So the same address of 192.168.1.0 with a subnet of 255.255.0.0 can be written as 192.168.1.0/16.
Same address with a 255.0.0.0 can be written as 192.168.1.0/8.
While IP addresses can get a lot more complicated, but for the sake of clarity in this overview we'll leave that for another time.
Breaking up your subnet can get pretty complicated, since you don't always know ahead of time how large your subnets should be or how many you need. You can always check out this handy IP calculator to help you out. You can generally use any parameters you recognize and the form should adjust your network and subnet mask based on them.
Something you may have noticed is how so many different networks might use the same local IP ranges. Once your signal reaches past your router, for the purposes of the internet, it will use the external IP address usually provided by your ISP. This means it's not important for your local network or computer to have a universally unique IP. They just need a unique IP address within their local network.
By default, there are several address ranges that are generally assigned to local networks. These are commonly 192.168.0.1-192.168.254.254 like we've been using here, but you might also encounter 10.0.0.1-10.254.254.254 or 172.16.0.1-172.31.254.254.
Chances are you've probably seen some of these addresses if you've ever looked up your computer's IP at work or at home, and it's not uncommon to see both networks use the same address ranges. In fact, we touched on this in one of our previous articles where we mentioned that if you're working from home over VPN and both of those local networks are on the same IP range you might actually encounter issues and conflicts.
We're really just scratching the surface here, and there's is a lot of information out there on this topic. However, in your day to day, it's very easy to get by with just recognizing some basic concepts. Like I mentioned earlier, using an address and mask of 192.168.0.0/255.255.255.0 is already pretty commonly set by default and will be adequate for most networks. Using very large subnet masks like 255.255.0.0 is usually not recommended anyway because of how much more complicated it is to manage and support them. If you use VPN, make sure you don't have any conflicts between the networks your connecting to and connecting from. Once you got the basics down, it's gets easier and easier to build on that information. Keep learning!
Until next time!
Follow ServerSuit's Linux server management and web hosting on Twitter @serversuit and Facebook.
This article was originally published September 22, 2016