DEV Community

Santhoshi Mary A
Santhoshi Mary A

Posted on

IP address and Subnet

What does an IP address mean?
Every device that is connected to a computer network has a unique number called an IP address (Internet Protocol address). An IP address is like a home address in that it tells the internet exactly where to send data, just like a postal address tells the delivery person exactly where to drop off your package.
There are two versions that people use today:

IPv4 is the older and most common format. Written as four groups of numbers with dots between them, like 192.168.1.1. There are about 4.3 billion possible addresses because each number can be between 0 and 255.
IPv6 is the newer format that was made to fix the problem of IPv4 running out. Written in hexadecimal, like this: 2001:0db8:85a3:0000:0000:8a2e:0370:7334. It can handle an almost infinite number of addresses.
Public IP Address vs. Private IP Address
IP Address
Given by the Internet Service Provider (ISP)
Used online
One of a kind around the world
IP for private use
Used in networks that are close by
Not directly reachable from the web

Private IP ranges:

10.0.0.0 to 10.255.255.255
172.16.0.0 to 172.31.255.255
192.168.0.0 to 192.168.255.255
The Parts of an IPv4 Address
There are 32 bits in an IPv4 address, and they are grouped into four octets, each with 8 bits.

  1. 168. 1. 10 11000000 10101000 00000001 00001010 There are two parts to every IP address:

Network part: This tells you which network the device is on.
Host part: Identifies the exact device on that network
What is a Subnet?

A Subnet (Subnetwork) is a smaller division of a large network.

Instead of having one large network with thousands of devices, we divide it into smaller networks

The Mask for the Subnet
A subnet mask is a 32-bit number that tells devices which part of an IP address belongs to the network and which part belongs to the host.
For example:
192.168.1.10 is the IP address.
255.255.255.0 is the subnet mask.
In binary:
IP: 11000000.10101000.00000001.00001010
Mask:11111111.11111111.11111111.00000000
The 1s in the mask are the network part.
The mask's 0s stand for the host part.
The first three octets (192.168.1) tell you which network you're on, and the last octet (.10) tells you which host you're on.

CIDR Notation
CIDR (Classless Inter-Domain Routing) notation is a way to write the subnet mask in a short way by counting the number of 1-bits.
192.168.1.0/24 → 255.255.255.0 (the mask has 24 ones)
10.0.0.0/8 → 255.0.0.0 (the mask has 8 ones in it)
172.16.0.0/16 → 255.255.0.0 (the mask has 16 ones in it)

Note: Two addresses in every subnet are always reserved — one for the network address and one for the broadcast address — which is why usable hosts = total addresses minus 2.

Network Address — First address of a subnet (not assignable to a host)
Broadcast Address — Last address of a subnet (sends data to all hosts in the subnet)

Top comments (0)