IP / Subnetting

IP

IP or Internet Protocol is Network OSI layer protocol, which is used for identifying devices in the Internet. For this it uses IP addresses. Computer gets it's IP address from software and obtained automatically from a DHCP server.

NIC

IP addresses, whether dynamic or static, are assigned to a Network Interface Controller (NIC), also known as a Network Adapter. A system can have multiple NICs (both physical and virtual), allowing it to connect to different networks with multiple IP addresses.

Network Address

Identifies a specific network and its range of IPs.

Example: 192.168.1.0/24 includes IPs from 192.168.1.1 to 192.168.1.254.

Broadcast Address

The highest IP in a subnet, used to send messages to all devices within the network.

Example: In 192.168.1.0/24, the broadcast address is 192.168.1.255.

Gateway Address

The router's IP that connects a network to others.

Example: 192.168.1.1 is the gateway for 192.168.1.0/24.

Subnet

There are billions of devices, so to communicate fast and easy with each of it, IP connects firstly not to devices itself, but to subnet, in which this device is located. This is called Scaling. Also IP address is 32 bit number, where every 8 bit is called octet.

Subnet - is the set of computers, which older part of IP address is same:

  • 312.245.10.1

  • 312.245.10.2

  • 312.245.10.3

Subnet Mask

Subnet mask is 32-bit number, which shows us, where in IP address number of network, and where is host. Previously, Subnet Classes were used to classify subnets, but this scheme is outdated, so they started using CIDR, which means Classless Inter-Domain Routing.

Mask structure: bits with 1 is reserved for network, and cannot be changed. Otherwise bits with 0 can be changed and reserved for hosts. So the prefix /24, /25, /32 is just amount of reserved and non-touchable bits.

Explanation
Number

IP(Decimal):

213.180.193.3

IP:

11010101.10110100.11000001.00000011

Mask:

11111111.11111111.11111111.00000000

Subnet:

11010101.10110100.11000001.00000000

Subnet mask could be shown with 2 types: decimal and prefix

  • Decimal: 255.255.255.0

  • Prefix: /24. Prefix 24 means 24 bits of subnet address in IP address.

The subnet mask does not have to end on an octet boundary

Explanation
Number

IP(Decimal):

213.180.193.3 /20

IP:

11010101.10110100.11000001.00000011

Mask:

11111111.11111111.11110000.00000000

Subnet:

11010101.10110100.11000000.00000000

Subnet(Decimal):

213.180.192.0

Host(Decimal):

0.0.1.3

So algorithm is that you should replace all one's in IP with zero's in mask at the same position.

Manual Math

Binary to Decimal

Decimal to Binary

Subnet hosts with Mask

All IP Address has 32 bits. /27 as example is amount of untouchable bits, so subnet mask would look like 11111111.11111111.11111111.11100000. So the amount of 0's is the bits we have for hosts (5), and for calculating amount of accessible hosts we need only to do 2 ^ 5 = 32. Which means we now have 32 accessible hosts with this subnet mask

Dividing into subnets

As example we would divide 10.200.20.0/27 network into 4 different subnets.

Divide the network into 4 subnets:

  • 32 / 4 = 8, so each subnet will contain 8 IP addresses, including network and broadcast addresses.

  • Calculate the ranges for each subnet:

    • Start with the network address (10.200.20.0) and increment by 8 for each new subnet.

    • For each range:

      • The first IP is the network address of the subnet.

      • The last IP is the broadcast address of the subnet.

    Subnet calculations:

    • Subnet 1:

      • Range: 10.200.20.0 - 10.200.20.7

      • Network address: 10.200.20.0

      • Broadcast address: 10.200.20.7

    • Subnet 2:

      • Range: 10.200.20.8 - 10.200.20.15

      • Network address: 10.200.20.8

      • Broadcast address: 10.200.20.15

    • Subnet 3:

      • Range: 10.200.20.16 - 10.200.20.23

      • Network address: 10.200.20.16

      • Broadcast address: 10.200.20.23

    • Subnet 4:

      • Range: 10.200.20.24 - 10.200.20.31

      • Network address: 10.200.20.24

      • Broadcast address: 10.200.20.31

Last updated