Do you know how to read your IP address? Intro to IPs and Subnetting

Sergio Pietri
5 min readMay 10, 2020

--

You’ve most likely heard about IP addresses, looked for yours in an online service or tried the ‘ipconfig’ command in the Windows terminal at some point in your life. But let me tell you a little more about that set of numbers!

IP addresses are used in the Network Layer of the OSI model and they’re meant to locate each device connected to the Internet.

To put it in context picture that the IP is the street the data will take to the house but in order to identify the house (device) it will deliver the package to, it will need the MAC address (that’s a unique ID each device has in it’s network card, a fingerprint).

As you may already know there are currently two types of IP numbers: IPv4 and IPv6. What this means is the version of the protocol that is being used (the IPv5 version was never actually deployed since v6 took over). The notation for each of them is the following:

  • IPv4: 127.127.127.127
  • IPv6: 2021:0d12:85b3:0000:0000:8a2e:0370:7334

The reason the later one exists is simply because we have already ran out of IPv4 addresses! IoT has really taken over the world and the amount of connected devices far exceeds what computer scientists had in mind back when they set up the protocol.

Since IPv6 is just undergoing initial stages of deployment right now it will be a while until you see it standarized in every device you use, so let’s focus on version 4 in the meantime.

What do the IP Address numbers mean?

IPv4 addresses are 32 bits long and they’re split into 4 “groups”, so each group has a length of 8 bits (better known as an octet). This means that each of those 4 sets of numbers can have a maximum decimal value of 255.

There are two sections in which an IPv4 address can be divided in: the network and the host. The network section identifies the unified group of computers in a certain area (IBM owns all addresses that have a 9 as the first octet like : 9.127.127.127) and the host section identifies the node (the device) that the address belongs to.

Given how the host and network sections are distributed between those 4 octets you can have a certain type of address. There are three types of IP addresses and they are:

  • Class A: the first octet is used for the network ID and the next three octets are used for the host ID. If the first octet begins within 0–126 the address is class A.
  • Class B: the first two octets are for the network and the other two are for the host. If the first octet begins within 128–191 the address is class B.
  • Class C: the first three octets are used for the network and the last octet is used for the host. If the first octet begins within 192–224 the address is class C.

The range of hosts space ranges widely from class A to class C because of the amount of octets in each one!

*Note: there are some values missing as you can tell (225–255) but those are used for other things and you won’t usually see one.

What is Subnetting?

Remember that we ran out of IPv4 addresses? Well, this is how you can keep using that IP version!

Subnetting is the process of transforming an IP address and replacing some of the ‘host’ section of it with the subnet number. You now have a 32 bit number (the whole 4 blocks (octets) of an IP address) that can be accurately delivered accross other networks. It’s like putting a mask on it and conviniently that is how the process is done.

A subnet mask defines the subnet ID and this will give you the number of hosts you can handle despite of the class of IP you are using.

Let’s say for example you have an IP address of 125.127.198.18

In this case you can tell it is a Class A IPv4 address. Apart from that you now know that the first decimal number (125) is the network section and the other three are hosts. But now you can put a mask on it!

A subnet mask will cover the network ID and some of the hosts. The mask could be 255.255.255.0, this means that you now have a subnet created using 125.127.198 and the last octet will now be available to be used for the host like if it was a Class C IPv4. Wonderful, isn’t it?

CIDR (classless inter-domain routing)

This is another ay to describe IPs and it expands from subnets. The network id and the subnet id are combined and it is notated with a slash next to the network section followed by the number of bits that it has.

Example:

Previously the mask 255.255.255.0 was used for 125.127.198.18. Now, with CIDR notation you can do something like 125.127.198.18/24 and this means the first 24 bits (the first three octets) are the network id.

If you play around with that bit number following the slash you can increase the amount of hosts available even further.

This was a quick introduction to the IP section of the network layer. Next time you see something related to networks, like when setting up an AWS architecture, you may make better sense of what you see.

There’s a whole lot more to this than what I just layed out for you but take this as a first step into a thousand mile walk.

I hope you have a great day!

S.

Follow me on twitter! @SergioPietri

--

--

Sergio Pietri

Backend Developer. I like to write about tech and other stuff. Follow me on twitter for more content!