subnetting basics

If we checkout the ipconfig (in windows) or in linux (ip addr show) we should find a ip and a subnet-mask if we got one. As well there is a standard-gateway. In the following I will describe how this works and what this will tell you about your network.

With IPv4 the unit of all ip-addresses are capped and in the future we will swap to  IPv6 because of this cap.

If we have a network like 192.168.0.0 /24 you will note the “/24”. This means that the network uses 24 bit to declare the network. The rest of the bits is for the hosts (and network address and broadcast).

8 bits . 8 bits . 8 bits . 8 bits
The first 24 bit are for the network and the last 8 are for the hosts, network and broadcast address.

Now we want to split this network into 56 parts. After this we should have 56 networks. To do this we need to find out the value that you can put in n in 2^n >= the needed unit of the networks. So:

2^n >= 56
2^6 >= 64 … so we will take the 6

So now we check out the values of the last 8 bits that we have to use:

bit 8 -> 2^0 -> 1
bit 7 -> 2^1 -> 2
bit 6 -> 2^2 -> 4
bit 5 -> 2^3 -> 8
bit 4 -> 2^4 -> 16
bit 3 -> 2^5 -> 32
bit 2 -> 2^6 -> 64
bit 1 -> 2^7 -> 128

With this information we take n (6) and check out the bit of this (marked big). So now we now that we have 4 IP address for every network if we want to split it into 56 networks.

As well we should know:

• The first IP address in a network describes the network

So for example the first network of 56 would be like:

192.168.0.1 – first host IP
192.168.0.2 – last host IP

So our last network had 24 bits to describe the network. All of our new networks have 24 + n (6) bits to describe the network. In this case we had a network like /30.

As said if we check out the IP address information we get nothing like /30 or /24. Instead of this we will get the subnet-mask. But this is the same just wrote different. We just have to set all network bits to 1 and the rest to 0 and check out the address as decimal.

/24 -> 1111 1111 . 1111 1111 . 1111 1111 . 0000 0000 -> 255.255.255.0
/30 -> 1111 1111 . 1111 1111 . 1111 1111 . 1111 1100 -> 255.255.255.252 (just take 255 – 2^1 – 2^0)

The standard gateway is the next hop to the internet (if you have one) other way you have to config the standard gateway.