DEV Community

Tomislav Kraljic
Tomislav Kraljic

Posted on • Updated on

How IP Addresses Work

In this article, I will go over what IP addresses are, types of addresses, class-full vs class-less addresses, classes of networks, subnets and CIDR (Classless Inter-Domain Routing) notation.

What is an IP Address?

In the most simplest terms, an IP (Internet Protocol) Address is a unique local address used to locate a computer/device via a network.

There are two types of IP Addresses:

1) IPV4 (32 bit) 
Enter fullscreen mode Exit fullscreen mode

2) IPV6 (128 bit)

Enter fullscreen mode Exit fullscreen mode

In this article, we will focus on IPV4 addresses as they are the ones most commonly used.

Let's take a look at an example of an IPV4 address
Enter fullscreen mode Exit fullscreen mode

Each number is called an octet because it is an 8 bit value.

192: 1100 0000
168: 1010 1000
0: 0000 0000
100: 0110 0100

8 bits means these number can range from 0-255.

0: 0000 0000
255: 1111 1111

This means an IP address starts at and ends at

This range of IP addresses is called the IP Space.

IP Addresses are actually comprised of 2 addresses in one.

  • Network Address
  • Host Address

Let's take a look at an example:

172.16: Network Address
0.1: Host Address

Is it always the first two as the network address and last two as the host address?

No. It is dependent on the class of address. We will take a look at them in the following section.

Class-full Networking and Classes of IP Addresses

There are a total of 5 classes: A, B, C, D, E

For this article, I will only go over classes A, B, and C because they pertain to devices and are the ones most commonly used.

Class A: Large Networks

Range: -


  • The first number (octet) is for the network and the remaining three are for hosts.

1: Network
2.3.4: Hosts

Class B: Medium Networks

Range: -


  • The first two numbers (octets) are for the network and the last two are for hosts.

Class C: Small Networks:

Range: -


  • The first three numbers (octets) are for the network and the last number is for the hosts.

Note: You may notice that 127 is not included in these ranges. The reason is because that is a special one reserved for localhost.

This was called "class-full networking". This was the architecture used from 1981 until 1993. In 1993, CIDR(Class-less Inter-Domain Routing) was invented and we switched over.


Well, let's take a closer look at an IP Address.

This allows for 65,000 hosts per network. If we have a bunch of small offices, we don't need to reserve 65,000 hosts per office. That is over-kill. Thus, we switched over to class-less networking.

Class-less Networking

Class-less networking relies on sub-netting and sub-net masks instead of classes now. We abandoned class-full networking and use class-less networking instead.

What is sub-netting?

  • Sub-netting is breaking up a large network into smaller ones.

What is a sub-net mask?

  • A sub-net mask tells us which part of the IP Address is for the network and host.

Example 1: ->

The 0's are reserved for hosts and the 255 (1) is reserved for the network.

Example 2: ->

Example 3: ->

With sub-netting, let's take a look at a previous IP Address used: would be

This would allow for about 65,000 hosts in our network as mentioned previously.

We can break our network class into something smaller using our subnet mask.

So, instead of, it could be

This would now only allocate 256 hosts per network. That is a lot better, and more manageable than 65,000.

CIDR Notation

CIDR Notation is a way for us to include the IP Address and the subnet mask.

/24 is the same as

This just means the first 24 bits of the subnet mask are turned on.

24 / 8 = 3 (first three octets of IP Address).

Top comments (1)

david_adam profile image
David Adam

IP version 6 is 128 bits