Every device on a network needs an address so that data knows where to go. In this module you will see how IPv4 addresses are structured and how subnet masks help define which part of the address identifies the network and which part identifies the host.
You will also practise converting between binary and decimal so you can understand what is really happening behind dotted decimal IPv4 addresses like 192.168.1.1.
"Once you can read IPv4 addresses in binary, subnet masks and network layouts start to make a lot more sense."
๐ What you will learn
- How IPv4 addresses are built from four 8 bit octets
- How to convert between binary and decimal for IPv4
- How subnet masks separate the network and host portions of an address
- Why devices in the same network share a network portion but have unique host portions
๐ง IP addressing
Addressing is a key function of network layer protocols. Both IPv4 and IPv6 use hierarchical addressing so that routers can forward traffic between networks instead of broadcasting everywhere.
๐ What is IPv4?
IPv4 is the fourth version of the Internet Protocol and it uses a binary numbering system. An IPv4 address contains 32 bits, grouped into four 8 bit blocks called octets, written in dotted decimal.
Example: 192.168.1.1 is an IPv4 address written in dotted decimal form.
Tip: On Windows you can run ipconfig in Command Prompt to see the IPv4 address that your computer is currently using.
๐ข Converting binary to decimal
Each bit in an octet has a place value based on powers of two, from 27 down to 20. To convert a binary octet to decimal, add the place values where the bit is 1.
Example: 01101101 = 0ยท128 + 1ยท64 + 1ยท32 + 0ยท16 + 1ยท8 + 1ยท4 + 0ยท2 + 1ยท1 = 64 + 32 + 8 + 4 + 1 = 109
Try it yourself: convert 11001010 to decimal before checking the answer below.
๐๏ธ IPv4 address structure
All devices in the same IPv4 network share the same network portion of the address while each device has a unique host portion. The subnet mask tells network devices where the split between network and host occurs.
๐งฎ Subnet masks and CIDR
A subnet mask is also 32 bits long. Bits set to 1 represent the network portion and bits set to 0 represent the host portion.
Example: 255.255.255.0 is a common subnet mask. In binary that is 24 ones followed by 8 zeros, which we can write as /24 in CIDR notation.
Understanding how masks work is essential before moving on to manual subnetting and network design.
Answer to the earlier exercise: binary 11001010 is decimal 202.
โ Key takeaway
IPv4 addresses, subnet masks and binary math go hand in hand. Once you are comfortable converting between binary and decimal and reading masks, you are ready to tackle subnetting and more advanced network design.