Menu
Coddy logo textTech

Mask to Prefix

Lesson 11 of 46 in Coddy's IP Addressing and Subnetting course.

A mask and a prefix length are the same fact in two costumes. To go from mask to prefix, count the ones.

Full octets are easy: each 255 contributes 8. The interesting octet is the partial one. Remember the left-packed bytes from chapter one: 128 is one bit, 192 is two, 224 is three, 240 is four, 248 is five, 252 is six, 254 is seven.

So 255.255.255.192 is 8 + 8 + 8 + 2 = /26. With that little table memorized, you convert masks at a glance.

challenge icon

Challenge

Beginner

Convert each mask to its prefix length. Print one per line, slash included, in this order:

  1. 255.0.0.0
  2. 255.255.255.192

Expected output:

/8
/26

Try it yourself

Terminal

All lessons in IP Addressing and Subnetting

Practice on your own: Terminal playground