Interview Q&A / Computer Networks

IntermediateIn-depth4 min readUpdated 2 Oct 2026

What is an IP address, a subnet and CIDR notation like /24?

SHORT ANSWER

An IPv4 address is a 32-bit number that identifies a device on a network. CIDR notation such as 192.168.1.0/24 says how many leading bits are the network part; the rest identify hosts. A /24 has 256 addresses (254 usable), a /16 has 65,536, and each extra bit halves the size of the subnet.

Explain it simply

Think of a postal PIN code and a house number. The PIN code tells the postal system which area to send a letter to; the house number tells the local postman which door. An IP address works the same way: the first part is the network (the area), and the rest is the host (the specific device).

CIDR notation tells you where the split happens. In 192.168.1.0/24, the /24 means "the first 24 bits are the area code". That leaves 8 bits for house numbers, so 256 possible addresses in that area.

Example

Break down 192.168.1.0/24:

text
IP:       192.168.1.0    = 11000000.10101000.00000001.00000000
Mask /24: 255.255.255.0  = 11111111.11111111.11111111.00000000
                            |------ network (24 bits) -----|host|

Network address:   192.168.1.0     (all host bits 0, not given to a device)
First usable host: 192.168.1.1
Last usable host:  192.168.1.254
Broadcast address: 192.168.1.255   (all host bits 1, not given to a device)
Usable hosts:      2^8 - 2 = 254

Quick sizes worth remembering:

CIDRSubnet maskTotal addressesUsable hosts
/8255.0.0.016,777,21616,777,214
/16255.255.0.065,53665,534
/24255.255.255.0256254
/26255.255.255.1926462
/28255.255.255.2401614
/32255.255.255.2551a single host route

Splitting 192.168.1.0/24 into four /26 subnets gives 192.168.1.0/26, 192.168.1.64/26, 192.168.1.128/26 and 192.168.1.192/26, each with 62 usable hosts.

How it works

An IPv4 address is 32 bits written as four numbers from 0 to 255. Total addresses: 2^32, about 4.3 billion. The formula for a subnet is: host bits = 32 minus the prefix length, total addresses = 2^(host bits), and usable hosts = total minus 2 (network and broadcast).

A device uses its subnet mask to decide where to send a packet. It does a bitwise AND of its own IP and the mask, and of the destination IP and the mask. If the network parts match, the destination is on the same local network and the device delivers it directly. If not, it sends the packet to its default gateway, the router.

Some ranges are private and are never routed on the public internet: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Your laptop at home probably has a 192.168.x.x address. The router uses NAT (Network Address Translation) to share one public IP among all devices in the house.

CIDR (Classless Inter-Domain Routing) replaced the old class A, B and C system, which only allowed /8, /16 or /24 networks and wasted huge numbers of addresses.

Real-world use

When you create a VPC in AWS, you choose a block like 10.0.0.0/16 and split it into subnets like 10.0.1.0/24 for web servers and 10.0.2.0/24 for databases, with different firewall rules for each. Firewall and security-group rules use CIDR too: 0.0.0.0/0 means "anywhere", and 203.0.113.7/32 means one specific IP. Because IPv4 addresses ran out, mobile networks such as Jio rely heavily on IPv6, with 128-bit addresses, and share IPv4 addresses across many customers using carrier-grade NAT.

Common mistakes

  • Forgetting to subtract 2 for the network and broadcast addresses.
  • Thinking a bigger prefix means a bigger network. It is the opposite: /28 is much smaller than /16.
  • Choosing overlapping ranges for two networks that later need to be connected, such as two offices or two VPCs both using 10.0.0.0/16.
  • Exposing a database with a 0.0.0.0/0 rule.
  • Assuming cloud subnets give you every usable address. AWS, for example, reserves 5 addresses in each subnet.

What to say in the interview

"An IPv4 address is 32 bits, split into a network part and a host part. CIDR notation gives the prefix length: in 192.168.1.0/24 the first 24 bits are the network, leaving 8 host bits, so 256 addresses, 254 usable after removing the network and broadcast addresses. A host ANDs addresses with the subnet mask to decide whether a destination is local or must go through the default gateway. Private ranges like 10/8, 172.16/12 and 192.168/16 are used inside networks and reach the internet through NAT. In the cloud I use CIDR to plan VPC subnets and write firewall rules."

Follow-up questions

  • How many usable hosts are in a /27?
  • How does a host decide whether to send a packet to the gateway?
  • What is NAT and why is it needed?
  • What changes with IPv6?

Go deeper

Read these once the basics above feel easy.

A /27 has 32 - 27 = 5 host bits, so 32 addresses and 30 usable hosts, with blocks starting at multiples of 32 (.0, .32, .64 and so on). Two special cases: a /31 is allowed on point-to-point links with no broadcast address, so both addresses are usable, and a /32 describes exactly one address. Routers pick the most specific matching route, the longest prefix match, so a /24 route wins over a /16 route for an address inside both.

#networking#ip-address#subnetting#cidr

Related questions

Practise more Computer Networks questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Computer Networks quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.