Interview Q&A / Computer Networks

BeginnerQuick answer1 min readUpdated 3 Oct 2026

Convert 255.255.255.240 to CIDR notation, and /21 to a dotted mask.

SHORT ANSWER

255.255.255.240 has 28 one-bits (24 plus 4 from 240 = 11110000), so it is /28, giving 16 addresses and 14 usable hosts. A /21 is 255.255.248.0.

Explain it simply

A subnet mask is a row of 32 bits: ones for the network part, zeros for the host part, always ones first. CIDR just counts the ones. Converting is counting in either direction.

Example

text
255.255.255.240
= 11111111.11111111.11111111.11110000
  8 + 8 + 8 + 4 = 28 ones  ->  /28
hosts: 2^4 - 2 = 14

/21 -> 21 ones = 8 + 8 + 5
third octet: 11111000 = 128+64+32+16+8 = 248
mask = 255.255.248.0
hosts: 2^11 - 2 = 2046

Common values for one partial octet: 128, 192, 224, 240, 248, 252, 254, 255, which correspond to 1, 2, 3, 4, 5, 6, 7 and 8 ones. A trick is that 256 minus the mask value gives the block size: 256 - 240 = 16.

Masks like 255.0.255.0 are invalid because the ones must be contiguous.

What to say in the interview

"I convert the odd octet to binary and count the ones. 240 is 11110000, so four ones, 24 plus 4 is 28. For /21, 21 is 16 plus 5 ones, giving 248 in the third octet. Block size is 256 minus the mask octet."

Common mistakes

  • Writing masks with non-contiguous ones.

#subnet-mask#cidr#worked-example

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.