How to calculate netmask from IP range

Written by joe teagno
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to calculate netmask from IP range
Calculating a netmask is easier with a scientific calculator. (Calculator image by Alhazm Salemi from

Internet traffic is sent as a series of Internet protocol, or IP, packets. IP packets contain a destination address that routers use in order to decide where to send the packets. Because there are more than 4 billion possible IP addresses, it is impractical for a router to keep track of how to handle packets addressed to every possible IP address. Instead, routers use the classless inter-domain routing, or CIDR, system, a scheme in which groups of contiguous IP addresses are handled as one manageable unit. A netmask identifies the CIDR subnet to which an IP address belongs.

Skill level:
Moderately Challenging

Things you need

  • Scientific calculator

Show MoreHide


  1. 1

    Write down the first IP address and the last IP address in the range.

    IP addresses are written in "dot decimal" notation; they are four numbers between 0 and 255 separated by periods. For this example, assume that the first and last IP addresses are and

  2. 2

    Type the first portion of the first IP address--the first octet--into the scientific calculator.

    If the first IP address is, you should type "11" into the calculator.

  3. 3

    Use the calculator to convert the number from decimal to binary.

    For example, 11 in decimal gets converted to 1011 in binary.

  4. 4

    Pad the binary number with leading zeroes such that the new binary number is exactly 8 digits long.

    If the calculator displays 1011 in binary, write it as 00001011.

  5. 5

    Convert the remaining three octets of the first IP address from decimal into binary, padding them to 8 digits.

    If the last three octets of the first address are 22, 33, and 44, then write these as 00010110, 00100001, and 00101100, respectively.

  6. 6

    Convert all four octets of the last IP address from decimal to binary.

    If you are using as the last IP address, then write these octets as 00001011, 00010110, 00100001, and 00110111, respectively.

  7. 7

    Write the two IP addresses in binary form such that the last IP address is aligned beneath the first IP address. Use periods to separate the octets from each other.

    In the example using and write:



  8. 8

    Compare the first two digits in the leftmost column. If these two digits are the same, then keep moving one column to the right until you find a column where the two digits are not the same.

  9. 9

    Label the column at which the two digits are not the same. This column is called the "network-host boundary."

    Using the example of and, the network-host boundary appears after the 27th digit. The boundary is shown below as a space:

    00001011.00010110.00100001.001 01100

    00001011.00010110.00100001.001 10111

  10. 10

    Starting in the leftmost column, write a series of "1" digits in a new line aligned below the two binary IP addresses.

    If you are following the example, start by writing:




  11. 11

    Stop writing "1" digits at the network-host boundary and start writing "0" digits instead.

    Your numbers should look like this:




  12. 12

    Continue writing "0" digits until all 32 digits are accounted for.

    Your finished lines will resemble the following:




  13. 13

    Circle the binary number on the last line--it's the netmask.

    In this example, the netmask is:


  14. 14

    Convert each of the octets of the netmask from binary to decimal.

    If you are following this example, your netmask is:

Tips and warnings

  • Plenty of free software programs exist that compute subnet masks from IP address ranges.
  • An IP address range can be covered by more than one subnet mask. There is no way to find the "ideal" netmask given a range of addresses.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.