Skip to main content

Subnetting – In a Nutshell

· 6 min read
Strider

Hi, I thought I'd do something on the subject of subnetting. Had not done anything in networking for a long time, which is why I'm slowly getting back into it, would like to.

Why this topic? Well because it is relatively easy to get started 😄.

what is subnetting?

Subnetting is a method in network technology to divide a large network into smaller networks. Since in many cases it makes little sense to run all hosts in a large network, we therefore divide the whole network. The division is done in such a way that each subnet includes a certain number of hosts.

A small example

Let's assume we have a network where accounting, administration, executive floor as well as workshop A and B are present. There are 200 hosts in this network. The address of the network is 192.168.100.0/24. In addition, the division, which network how many hosts.

Accounting 20 hosts Administration 12 hosts Executive floor 4 hosts Workshop A 120 hosts Workshop B 55 Hosts

This is all the information we need to subnet once.

We are only missing the broadcast address and the network ID, so we know how many hosts fit into the network.

First a little intro what exactly is what.

What is IPv4?

An IPv4 address consists of 4 octets, i.e. 4 x 8 bits, which are separated by dots.

An IPv4 address looks like this from the scheme:

OCTET-1 . OCTET-2 . OCTET-3 . OCTET-4

Each octet, goes from 0 - 255, because here we work with powers of 2.

27262524232221202^{7}2^{6}2^{5}2^{4}2^{3}2^{2}2^{1}2^{0}

I think from here it becomes clear why each octet goes from 0 - 255.

Subnet mask

Each network has a subnet mask, which specifies the valid address range for the hosts. The subnet mask has two notations, one as a full address or as a number that specifies the network bits.

A subnet mask looks like this:

Subnet mask 255.255.255.0 = /24

NNNNNNNN.NNNNNNNN.NNNNNNNN.HHHHHHHH

Here we see that the subnet mask specifies what is in the IPv4 address, the network portion, and what is the host portion. The N's are the network portion, and all H's are the host portion, which can be freely used for the hosts. The subnet mask is present in every network. Here in the example we see that we have a complete octet full of H's. So 2562256-2 hosts fit in here.

Network address / Network ID

A network always consists of a network address / network ID. The network ID is the smallest even address of each network. The curious thing is that this address cannot be assigned to hosts. Because a network ID identifies the respective network together with the subnet mask. Is so seen the start, from where the network begins.

For example, the network ID looks like this.

Host address : 172.10.1.112/16
Network ID : 172.10.0.0/16

Broadcast address

For each network there is also a broadcast address. This is the largest odd address in the network. The address cannot be assigned to any hosts. A broadcast address indicates where the network ends. You can also say, broadcast = (network ID of the next network) - decreased by 1 at the lowest octet.

A broadcast address looks like this:

Host address : 172.10.1.112/16
Broadcast address : 172.10.255.255/16

Sounds all well and good, but how does this help with subnetting?

With this information you can now divide networks into subnets.

We now take the network from above, and find out what the network ID is. First we convert the single octets to binary. Here we need the IPv4 address and the subnet mask. Both are written under each other and rounded. As a result we get the network ID.

192.168.100.0

/24 = 255.255.255.0

11000000.10101000.01100100.00000000
11111111.11111111.11111111.00000000 AND
---------------------------------------
11000000.10101000.01100100.00000000
192 .168 .100 .0

We now know that the network ID is 192.168.100.0/24. This is also the address mentioned above. The whole thing can be calculated with any address. Example here:

192.168.100.23

/24 = 255.255.255.0

11000000.10101000.01100100.00010111
11111111.11111111.11111111.00000000 AND
---------------------------------------
11000000.10101000.01100100.00000000
192 .168 .100 .0

Here, too, we get the same network ID. This is due to the subnet mask, since this divides the address into network and host portion.

To calculate the broadcast address, we have to invert the subnet mask and verify it with the IPv4 address. That's all it really is.

192.168.100.23

/24 = 255.255.255.0

11000000.10101000.01100100.00010111
00000000.00000000.00000000.11111111 OR
---------------------------------------
11000000.10101000.01100100.11111111
192 .168 .100 .255

We now know what the broadcast address is, it is 192.168.100.255/24.

With these two pieces of information, we can now determine the exact subnets. With this we can also determine how many hosts fit into a network. To divide a network into subnets, we have to add bits to the subnet mask on the left. The whole thing is then continued per subdivision. For example, if we want to divide the network into 2 subnets of the same size, we add 1 bit to the mask. If we want to quarter it, we add 2 bits. This goes on and on.

You can play the game until all 32 bits are used up. Mostly, however, one goes up to the subnet mask /30. Here, max. 2 hosts fit in.

dia.png

Ok let's start subnetting the network. If we apply the diagram from above, the whole thing will look like this afterwards:

Names of the subnets are written in german language

dia2.png

If we do the math, it should look like this.

192.168.100.0 / 24

Workshop A: Subnetzmaske / 25

Netzwerk-ID
11000000.10101000.01100100.00000000
11111111.11111111.11111111.10000000 AND
---------------------------------------
11000000.10101000.01100100.00000000
192 .168 .100 .0

Broadcast-Addresse
11000000.10101000.01100100.00000000
00000000.00000000.00000000.01111111 OR
---------------------------------------
11000000.10101000.01100100.01111111
192 .168 .100 .127



Workshop B: Subnetzmaske / 26

Netzwerk-ID
11000000.10101000.01100100.10000000
11111111.11111111.11111111.11000000 AND
---------------------------------------
11000000.10101000.01100100.00000000
192 .168 .100 .128

Broadcast-Addresse
11000000.10101000.01100100.10000000
00000000.00000000.00000000.00111111 OR
---------------------------------------
11000000.10101000.01100100.10111111
192 .168 .100 .191



Accounting: Subnetzmaske / 27

Netzwerk-ID
11000000.10101000.01100100.11000000
11111111.11111111.11111111.11100000 AND
---------------------------------------
11000000.10101000.01100100.00000000
192 .168 .100 .192

Broadcast-Addresse
11000000.10101000.01100100.11000000
00000000.00000000.00000000.00011111 OR
---------------------------------------
11000000.10101000.01100100.11011111
192 .168 .100 .223



Administration: Subnetzmaske / 28

Netzwerk-ID
11000000.10101000.01100100.11100000
11111111.11111111.11111111.11110000 AND
---------------------------------------
11000000.10101000.01100100.00000000
192 .168 .100 .192

Broadcast-Addresse
11000000.10101000.01100100.11100000
00000000.00000000.00000000.00001111 OR
---------------------------------------
11000000.10101000.01100100.11101111
192 .168 .100 .223

Executives: Subnetzmaske / 28

Netzwerk-ID
11000000.10101000.01100100.11110000
11111111.11111111.11111111.11111000 AND
---------------------------------------
11000000.10101000.01100100.00000000
192 .168 .100 .240

Broadcast-Addresse
11000000.10101000.01100100.11110000
00000000.00000000.00000000.00000111 OR
---------------------------------------
11000000.10101000.01100100.11110111
192 .168 .100 .247


Workshop A: 192.168.100.0 - 192.168.100.127/25
Workshop B: 192.168.100.128 - 192.168.100.191/26
Accounting: 192.168.100.192 - 192.168.100.223/27
Administration: 192.168.100.224 - 192.168.100.239/28
Executives: 192.168.100.240 - 192.168.100.247/29

So we see that we can subnet with binary computation as well as with the diagram.

Subnetting is not really difficult in itself.

I hope I could give a little insight into the subject of subnetting 😄