Skip to content
Topic guide · Networking

IP Addressing and Subnetting: Classes, CIDR and Worked Examples · আইপি অ্যাড্রেস ও সাবনেটিং: ক্লাস, সিআইডিআর ও উদাহরণ

An IPv4 address is a 32-bit number written as four decimal octets (for example 192.168.10.77), split into a network part and a host part by the subnet mask or the CIDR prefix such as /24. Subnetting borrows host bits to make smaller networks: a /n prefix leaves 32 − n host bits, so each subnet has 2³²⁻ⁿ addresses and 2³²⁻ⁿ − 2 usable hosts (the first is the network address and the last the broadcast address).

আইপিভি৪ অ্যাড্রেস হলো ৩২ বিটের একটি সংখ্যা, যা চারটি দশমিক অক্টেটে লেখা হয় (যেমন ১৯২.১৬৮.১০.৭৭); সাবনেট মাস্ক বা /২৪-এর মতো সিআইডিআর প্রিফিক্স এটিকে নেটওয়ার্ক অংশ ও হোস্ট অংশে ভাগ করে। সাবনেটিংয়ে হোস্ট বিট ধার নিয়ে ছোট ছোট নেটওয়ার্ক তৈরি করা হয়: /n প্রিফিক্সে হোস্ট বিট থাকে ৩২ − n, তাই প্রতিটি সাবনেটে ২-এর (৩২ − n) ঘাতসংখ্যক অ্যাড্রেস থাকে এবং ব্যবহারযোগ্য হোস্ট তার চেয়ে ২টি কম (প্রথমটি নেটওয়ার্ক অ্যাড্রেস, শেষটি ব্রডকাস্ট অ্যাড্রেস)।

Asked in past exams
168
Papers
116

1. What an IP address is

Every device on an IP network needs an address so that packets can find it. An IPv4 address is 32 bits long. To make it readable we split it into four 8-bit groups (octets) and write each in decimal, separated by dots:

Dotted decimal 192 168 10 77
Binary 11000000 10101000 00001010 01001101

Each octet is 0 to 255, because 8 bits can hold 2⁸ = 256 values. The bit values in an octet, from left to right, are 128, 64, 32, 16, 8, 4, 2 and 1: 77 = 64 + 8 + 4 + 1 = 01001101. An address has two parts: the network part (which network the device is on, used by routers) and the host part (which device inside that network).

2. Classful addressing (still asked in exams)

Before 1993 the first bits of the address fixed where the network part ended. These classes are obsolete on the real Internet (replaced by CIDR, section 4), but exam questions still use them:

Class First octet Leading bits Default mask Networks Usable hosts per network Use
A 1 – 126 0 255.0.0.0 (/8) 126 16,777,214 Very large networks
B 128 – 191 10 255.255.0.0 (/16) 16,384 65,534 Medium networks
C 192 – 223 110 255.255.255.0 (/24) 2,097,152 254 Small networks
D 224 – 239 1110 – – – Multicast
E 240 – 255 1111 – – – Reserved (experimental)

By its leading bit (0), class A covers first octets 0 to 127, but two of those networks are reserved: 0.0.0.0/8 means "this network", and 127.0.0.0/8 is the loopback range (127.0.0.1 means "this computer"). That is why usable class A networks run from 1 to 126 (2⁷ − 2 = 126), while a 127.x.x.x address is still called class A. Class B has 2¹⁴ networks and class C 2²¹.

3. Private and special addresses

Some ranges never appear on the public Internet. Routers there drop them, so organisations reuse them inside their own networks behind NAT (section 7):

Range CIDR Class it falls in Purpose
10.0.0.0 – 10.255.255.255 10.0.0.0/8 A Private (RFC 1918)
172.16.0.0 – 172.31.255.255 172.16.0.0/12 B Private (RFC 1918)
192.168.0.0 – 192.168.255.255 192.168.0.0/16 C Private (RFC 1918)
0.0.0.0 – 0.255.255.255 0.0.0.0/8 A "This network"; 0.0.0.0 alone means "unspecified" (and, in routing, the default route)
127.0.0.0 – 127.255.255.255 127.0.0.0/8 A Loopback
169.254.0.0 – 169.254.255.255 169.254.0.0/16 B Link-local (APIPA: given when DHCP fails)
255.255.255.255 255.255.255.255/32 – Limited broadcast

A classic trap: 172.16.x.x to 172.31.x.x is private, but 172.15.x.x and 172.32.x.x are public.

4. Subnet masks and CIDR notation

A subnet mask has 1-bits over the network part and 0-bits over the host part. CIDR (Classless Inter-Domain Routing) writes the same thing as a slash and the count of 1-bits:

  • 255.255.255.0 = 11111111.11111111.11111111.00000000 = /24
  • 255.255.255.192 = …11000000 = /26

With CIDR the network can end at any bit, not only at an octet boundary. The formulas follow directly:

  • host bits h = 32 − prefix
  • addresses per subnet = 2ʰ
  • usable hosts = 2ʰ − 2
  • number of subnets = 2ⁿ, where n is the number of host bits borrowed

(Exceptions: a /31 point-to-point link uses both of its addresses (RFC 3021), and a /32 is a single host.)

Prefix Mask Block size (last octet) Addresses Usable hosts
/24 255.255.255.0 256 256 254
/25 255.255.255.128 128 128 126
/26 255.255.255.192 64 64 62
/27 255.255.255.224 32 32 30
/28 255.255.255.240 16 16 14
/29 255.255.255.248 8 8 6
/30 255.255.255.252 4 4 2

The block size is 256 minus the mask's interesting octet (256 − 224 = 32 for /27). Subnets start at multiples of the block size.

5. Worked example: the subnet an address belongs to

Question: for 192.168.10.77/27, find the network address, broadcast address, usable range and number of hosts.

  1. /27 → mask 255.255.255.224, block size 256 − 224 = 32.
  2. Subnets in the last octet start at 0, 32, 64, 96 … 77 lies between 64 and 95.
  3. Network address = 192.168.10.64; broadcast = the next block start minus one = 192.168.10.95.
  4. Usable hosts = 192.168.10.65 to 192.168.10.94, that is 2⁵ − 2 = 30 hosts.
For a /27 the block size is 32, so 77 falls in the block 64–95: network .64, broadcast .95, hosts .65 to .94 (30 hosts).

6. Worked examples: dividing a network

Equal subnets. Divide 192.168.1.0/24 into 4 subnets. You need 2 extra bits (2² = 4), so the prefix becomes /26 (62 hosts each). In general, borrowing n bits gives 2ⁿ subnets. Older textbooks use 2ⁿ − 2, leaving out the all-zeros and all-ones subnets; RFC 1878 made that rule obsolete, so use 2ⁿ unless the options only fit 2ⁿ − 2.

Subnet Network Usable hosts Broadcast
1 192.168.1.0/26 .1 – .62 .63
2 192.168.1.64/26 .65 – .126 .127
3 192.168.1.128/26 .129 – .190 .191
4 192.168.1.192/26 .193 – .254 .255

Different sizes (VLSM). From 192.168.5.0/24, give one LAN 100 hosts, one 50 and one 20. Allocate the biggest first, each with the smallest block (the longest prefix) that fits:

Need Smallest fit Network Usable range
100 hosts /25 (126) 192.168.5.0/25 .1 – .126
50 hosts /26 (62) 192.168.5.128/26 .129 – .190
20 hosts /27 (30) 192.168.5.192/27 .193 – .222

192.168.5.224/27 is left over for later. Allocating largest-first keeps every block on its natural boundary, so the blocks never overlap.

Bigger than one octet. 172.16.45.200/20: the mask is 255.255.240.0, so the block size works in the third octet: 256 − 240 = 16. 45 lies in 32–47, so the network is 172.16.32.0/20, the broadcast 172.16.47.255, and there are 2¹² − 2 = 4,094 usable hosts.

7. NAT and why private addresses work

Network Address Translation (NAT) lets many devices with private addresses share one public address. The router rewrites the source address (and usually the port, which is called PAT or NAT overload) on the way out, and reverses the change for replies. That is why a home or office network can use 192.168.0.0/16 internally.

8. IPv6 in brief

IPv4's 2³² ≈ 4.3 billion addresses ran out, so IPv6 uses 128-bit addresses (2¹²⁸ ≈ 3.4 × 10³⁸), written as eight groups of four hexadecimal digits:

  • 2001:0db8:0000:0000:0000:0000:0000:0001 can be shortened: drop leading zeros in a group and replace one run of two or more zero groups (the longest run; the first one if two runs tie) with :: → 2001:db8::1.
  • IPv6 has no broadcast: it uses unicast, multicast and anycast.
  • The usual subnet size is /64 (64 bits for the network, 64 for the interface).
  • Moving between versions: dual stack, tunnelling (IPv6 carried inside IPv4, or the reverse) and translation.

Practice · অনুশীলন

  1. How many usable host addresses does a /29 subnet have?
    Answer

    2³ − 2 = 6 (8 addresses, minus the network and broadcast addresses).

  2. Is 172.32.1.1 a private address?
    Answer

    No. The private class B range is 172.16.0.0 to 172.31.255.255; 172.32.1.1 is just outside it, so it is public.

  3. What is the network address of 10.20.130.5/18?
    Answer

    /18 → mask 255.255.192.0, block size 64 in the third octet. 130 lies in 128–191, so the network is 10.20.128.0 and the broadcast 10.20.191.255.

  4. Which prefix gives the smallest subnet with at least 500 usable hosts?
    Answer

    /23: 2⁹ − 2 = 510 hosts (a /24 gives only 254).

  5. Write 2001:0db8:0000:0000:0000:ff00:0042:8329 in its shortest form.
    Answer

    2001:db8::ff00:42:8329.

Asked in past exams · আগের পরীক্ষায় যেভাবে এসেছে

Our past papers have 168 questions on this topic (61 MCQ, 107 written) from 116 exams. Here are 12 of them; each links to its full paper.

  1. The size of the IPv6 address is:

    • a)128 bits (correct answer)
    • b)4 bits
    • c)32 bits
    • d)None of the above
    Explanation · ব্যাখ্যা

    Correct answer: (a) 128 bits

    An IPv6 address is 128 bits long. It is written as eight 16-bit groups of up to four hexadecimal digits separated by colons, e.g. 2001:db8:85a3::8a2e:370:7334 ("::" stands for a run of zero groups).

    • Groups × bits: 8 groups × 16 bits = 128 bits (16 bytes)
    • Address space: 2¹²⁸ ≈ 3.4 × 10³⁸ addresses, against IPv4's 2³² = 4,294,967,296 (about 4.3 billion)

    This huge space was the main reason for moving from IPv4 to IPv6.

    Why the other options are wrong

    • (b) 4 bits: 4 bits is the size of the Version field in the IP header (value 6 for IPv6), or one hex digit, not an address.
    • (c) 32 bits: That is the length of an IPv4 address.
    • (d) None of the above: Option (a) is correct, so this cannot be chosen.

    Tip: IPv4 = 32 bits (4 bytes, dotted decimal); IPv6 = 128 bits (16 bytes, colon-hex). The IPv6 header, not the address, is 40 bytes.

    Source: RFC 4291: IP Version 6 Addressing Architecture
    Source: Implementing Network Stack IPv4 and IPv6 - Cisco IOS XR Configuration Guide

  2. IPv6 does not support which of the following addressing modes?

    • a)unicast addressing
    • b)multicast addressing
    • c)broadcast addressing (correct answer)
    • d)anycast addressing
    Explanation · ব্যাখ্যা

    Correct answer: (c) broadcast addressing

    IPv6 defines three kinds of address: unicast, anycast and multicast. RFC 4291 says plainly: "There are no broadcast addresses in IPv6". Jobs that IPv4 did with broadcast are done with multicast groups instead, for example the all-nodes link-local group ff02::1, so only hosts that have joined a group need to process the packet.

    Why the other options are wrong

    • (a) unicast addressing: Supported; a unicast address identifies a single interface.
    • (b) multicast addressing: Supported, and it takes over the role of broadcast; the packet goes to every interface in the group.
    • (d) anycast addressing: Supported; the packet goes to the "nearest" of several interfaces sharing the address, as measured by routing.

    Tip: IPv4: unicast, broadcast, multicast. IPv6: unicast, multicast, anycast (no broadcast).

    Source: RFC 4291: IP Version 6 Addressing Architecture

  3. Which of the following cannot be used as a public IP address?

    • a)17.0.0.1
    • b)168.172.19.34
    • c)172.15.29.63
    • d)192.168.13.18 (correct answer)
    Explanation · ব্যাখ্যা

    Correct answer: (d) 192.168.13.18

    RFC 1918 sets aside three blocks for private networks. Routes for them are not advertised and packets using them are not forwarded across the Internet, so an address from these blocks cannot be a public address:

    • 10.0.0.0 – 10.255.255.255 (10.0.0.0/8)
    • 172.16.0.0 – 172.31.255.255 (172.16.0.0/12)
    • 192.168.0.0 – 192.168.255.255 (192.168.0.0/16)

    192.168.13.18 begins with 192.168, so it lies in 192.168.0.0/16 and is private.

    Quick check with two neighbours: 172.31.250.17 is private, but 172.32.0.17, just past the end of the block, is public.

    Why the other options are wrong

    • (a) 17.0.0.1: The first octet is 17, which is in none of the private blocks (10.x is the only private /8), so it is a public address.
    • (b) 168.172.19.34: Starts with 168, not 172 or 192.168; the digits look like a private range but the address is public.
    • (c) 172.15.29.63: The private 172 block runs only from 172.16 to 172.31; 172.15 is just outside it, so this is public.

    Tip: Private = 10.x.x.x, 172.16–172.31.x.x, 192.168.x.x; watch out for 172.15 and 172.32, which are public.

    Source: RFC 1918: Address Allocation for Private Internets

  4. Encapsulating IPv4 in IPv6 is known as _____.

    • a)Tunneling (correct answer)
    • b)hashing
    • c)NAT
    • d)Traversing
    Explanation · ব্যাখ্যা

    Correct answer: (a) Tunneling

    Tunneling means wrapping a whole packet of one protocol inside a packet of another, so it can cross a network that speaks only the outer protocol. The entry point adds the outer header (encapsulation), and the exit point removes it (decapsulation). It works in both directions: IPv6 packets are tunnelled over IPv4 networks (configured tunnels, RFC 4213), and IPv4 packets are tunnelled over IPv6-only networks, as in Dual-Stack Lite, which combines IPv4-in-IPv6 tunnels with NAT.

    Why the other options are wrong

    • (b) hashing: Computes a fixed-length digest of data for integrity or lookup; it does not carry packets.
    • (c) NAT: Rewrites addresses in the existing header instead of wrapping the packet; even NAT64 translates between IPv6 and IPv4 headers, which is translation, not encapsulation.
    • (d) Traversing: A general word (as in "NAT traversal"), not the name of an IPv4/IPv6 transition mechanism.

    Tip: The three IPv4–IPv6 transition approaches: dual stack, tunneling (encapsulation) and translation (NAT64).

    Sources: RFC 4213: Basic Transition Mechanisms for IPv6 Hosts and Routers; RFC 6333: Dual-Stack Lite Broadband Deployments Following IPv4 Exhaustion

  5. What is private IP range class A, B and C with maximum host of each class?

    Model answer on the paper page

  6. Explain NAT? Differenc between IPv4 and IPv6.

    Model answer on the paper page

  7. What do you mean by Subnet and Subnet Mask? The network address of 172.16.0.0/19 provides how many subnets and hosts? What is the function of OSPF?

    Model answer on the paper page

  8. What is NAT? Explain with topological diagram.

    Model answer on the paper page

  9. What is default subnet mask?

    Model answer on the paper page

  10. How many bits need to identify an IP address in IPv4?

    Model answer on the paper page

  11. How long is an IPv6 address?

    • a)32 bits
    • b)128 bits (correct answer)
    • c)64 bits
    • d)132 bits
    Explanation · ব্যাখ্যা

    Correct answer: (b) 128 bits

    An IPv6 address is 128 bits long. It is written as eight 16-bit groups of up to four hexadecimal digits separated by colons, e.g. 2001:db8:85a3::8a2e:370:7334 ("::" stands for a run of zero groups).

    • Groups × bits: 8 groups × 16 bits = 128 bits (16 bytes)
    • Address space: 2¹²⁸ ≈ 3.4 × 10³⁸ addresses, against IPv4's 2³² = 4,294,967,296 (about 4.3 billion)

    This huge space was the main reason for moving from IPv4 to IPv6.

    Written out in full, even a short address such as 2001:db8:4b::19 becomes 2001:0db8:004b:0000:0000:0000:0000:0019: still eight groups, still 128 bits.

    Why the other options are wrong

    • (a) 32 bits: That is the length of an IPv4 address.
    • (c) 64 bits: That is only half an IPv6 address: the usual interface identifier (the host part of a /64 subnet).
    • (d) 132 bits: No IP version uses 132 bits; it is a near-miss of 128.

    Tip: IPv4 = 32 bits (4 bytes, dotted decimal); IPv6 = 128 bits (16 bytes, colon-hex). The IPv6 header, not the address, is 40 bytes.

    Source: RFC 4291: IP Version 6 Addressing Architecture
    Source: Implementing Network Stack IPv4 and IPv6 - Cisco IOS XR Configuration Guide

  12. Briefly explain Network Address Translation (NAT).

    Model answer on the paper page

Common mistakes · সাধারণ ভুল

  • Forgetting the − 2: a /26 has 64 addresses but 62 usable hosts.
  • Treating all of 172.x.x.x as private: only 172.16.0.0 – 172.31.255.255 is.
  • Mixing up the mask value and the block size: for /27 the mask octet is 224, the block size is 256 − 224 = 32.
  • Giving a host the network or broadcast address (for example .64 or .95 in a /27 that starts at .64).
  • Using :: twice when shortening an IPv6 address: it may replace only one run of zero groups.
  • Saying IPv6 has broadcast addresses: it uses multicast instead.

বাংলায় সংক্ষেপে

  • আইপিভি৪ অ্যাড্রেস ৩২ বিটের, চারটি অক্টেটে লেখা হয়; প্রতিটি অক্টেটের মান ০ থেকে ২৫৫।
  • ক্লাস A-এর প্রথম অক্টেট ১–১২৬, B-এর ১২৮–১৯১, C-এর ১৯২–২২৩; D মাল্টিকাস্ট, E সংরক্ষিত (পরীক্ষামূলক)। ১২৭.x.x.x লুপব্যাক।
  • প্রাইভেট রেঞ্জ: ১০.০.০.০/৮, ১৭২.১৬.০.০/১২ (১৭২.১৬ থেকে ১৭২.৩১) ও ১৯২.১৬৮.০.০/১৬।
  • /n প্রিফিক্সে ব্যবহারযোগ্য হোস্ট = ২-এর (৩২ − n) ঘাত থেকে ২ বাদ; ব্লক সাইজ = ২৫৬ − মাস্কের সংশ্লিষ্ট অক্টেট।
  • উদাহরণ: ১৯২.১৬৮.১০.৭৭/২৭-এর নেটওয়ার্ক .৬৪, ব্রডকাস্ট .৯৫, হোস্ট .৬৫ থেকে .৯৪ (৩০টি)।
  • আইপিভি৬ অ্যাড্রেস ১২৮ বিটের, হেক্সাডেসিমেলে লেখা হয়; এতে ব্রডকাস্ট নেই, মাল্টিকাস্ট ও অ্যানিকাস্ট আছে।

Updated 2026-10-18. Written by ARBS Academy; the past exam questions are from public recruitment exams.