IP Subnet Calculation & Design Online Documentation

Contents

Related Information

Purpose & Scope

The purpose of this tool is to provide a way to calculate IP subnetting which is fast, easy, and error free. Doing such calculations manually is time consuming and susceptible to common mathematical mistakes (especially in conversions between binary and decimal numbers).

While the tool is useful, it doesn't teach IP subnetting. It is highly recommended that users understand the mechanics behind IP subnetting by reading other sources like "Internetworking with TCP/IP" by Comer.

This tool is for calculations only, and doesn't implement limitations and rules imposed by various RFCs. For practical purposes, users must understand these limitations and rules. For example, the network 10.0.0.0 should not be advertised on internet and should be used internally, however the tool doesn't distinguish this network address from others.

User Interface

Inputs

IP Address is an input that specifies the IP address for which the subnet calculation and/or design is desired.

Address Mask is an input that specifies the classful IP address mask using which the subnet calculation can be achieved.

Minimum Subnets is an input that specifies the minimum number of subnets that must be available in the subnet design.

Minimum Hosts/Subnet is an input that specifies the minimum number of hosts that must be available in every subnet of the subnet design.

VLSM Masks are inputs that specify the classful IP address masks for calculation of subnetting which incorporates variable length subnet masking (VLSM).

Actions

Calculate All IP Subnets

Find IP Subnet for this address

Design IP Subnetting (maximize subnets)

Design IP Subnetting (maximize hosts)

Design IP Subnetting (minimize wastage)

Calculate Subnetting using VLSM

Interpreting Results

Sample Output 1

Source: This output is obtained by using IP Address 150.150.10.10, Address Mask 255.255.224.0 (or 3 classful mask bits), and action "Calculate All IP Subnets". The action "Find IP Subnet for this address" will give the same output except that only one subnet will be shown which contains this IP Address (subnet 0 in this case).

Action "Design IP Subnetting (maximize subnets)" will give exactly the same output if Minimum Subnets between 1 and 6, and Minimum Hosts/Subnet between 4096 and 8192 is used. Action "Design IP Subnetting (maximize hosts)" will give exactly the same output if Minimum Subnets between 4 and 6, and Minimum Hosts/Subnet between 1 and 8192 is used. Action "Design IP Subnetting (minimize wastage)" will give exactly the same output if Minimum Subnets between 1 and 6, and Minimum Hosts/Subnet between 4096 and 8192 is used.

-----------------------------------------------------------------------------
IP Class:       B               IP Address:      150.150.10.10
Mask Bits:      3               Subnet Mask:     255.255.224.0
Subnets:        6+1             IP Major Net:    150.150.0.0
Hosts/Subnet:   8190            Major Net Bcast: 150.150.255.255

                  Subnets for Fixed Length Subnet Masking
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  No.     Subnet           Hosts            Hosts            Broadcast
          Address          From             To               Address

       0  150.150.0.0      150.150.0.1      150.150.31.254   150.150.31.255
       1  150.150.32.0     150.150.32.1     150.150.63.254   150.150.63.255
       2  150.150.64.0     150.150.64.1     150.150.95.254   150.150.95.255
       3  150.150.96.0     150.150.96.1     150.150.127.254  150.150.127.255
       4  150.150.128.0    150.150.128.1    150.150.159.254  150.150.159.255
       5  150.150.160.0    150.150.160.1    150.150.191.254  150.150.191.255
       6  150.150.192.0    150.150.192.1    150.150.223.254  150.150.223.255
       7  150.150.224.0    150.150.224.1    150.150.255.254  150.150.255.255

Don't use subnet 0 (unless using ip subnet-zero command) and subnet 7.
Address space wasted by subnetting =  25.02% ( 12.52% with ip subnet-zero)
-----------------------------------------------------------------------------

Understanding: Top four lines show the basic information like the IP address and subnet mask (or mask bits) given by user, the extracted IP class, network address (Major Net), and network broadcast address. Also given are number of subnets [ = 2^(mask bits) -2 ] and hosts/subnet [ = 2^(32 -16 -mask bits) -2 for class B]. The +1 in front of subnets should be added if ip subnet-zero command is used on Cisco router.

The table that follows shows info about each subnet including subnet number, subnet address, first host address in subnet, last host address in subnet, and subnet's broadcast address.

Note that even though all subnets are shown, subnet zero should not be used as its subnet address matches the major net address (some older versions of Unix also used an all zero broadcast which is another factor in the problem). However, this restriction is waived if ip subnet-zero command is used. Also the last subnet (7 in this case) shouldn't be used as its broadcast address is the same as major net broadcast address.

Finally, address space wastage is given. Address space is wasted because subnet zero and the last subnet can't be used, and also because the first address and the last address of the subnet can't be used (first address identifies the subnet itself, and last address is its broadcast address). This is also the reason for -2 in the above two formulae. However, using ip subnet-zero command helps bring wastage down as the subnet 0 becomes usable with this. Note that wastage due to subnetting is at its minimum when number of subnets and hosts/subnet are the same.

Sample Output 2

Source: This output is obtained by using IP Address 150.150.10.10, VLSM Mask bits 2, 3, and 5, and action "Calculate Subnetting using VLSM."

-----------------------------------------------------------------------------
IP Class:       B               IP Address:      150.150.10.10
Mask1 Bits:     2               Subnet Mask1:    255.255.192.0
Mask2 Bits:     3               Subnet Mask2:    255.255.224.0
Mask3 Bits:     5               Subnet Mask3:    255.255.248.0

                Subnets for Variable Length Subnet Masking
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
     Subnet                Hosts            Hosts            Broadcast
     Address               From             To               Address

150.150.0.0                150.150.0.1      150.150.63.254   150.150.63.255
     150.150.0.0           150.150.0.1      150.150.31.254   150.150.31.255
          150.150.0.0      150.150.0.1      150.150.7.254    150.150.7.255
          150.150.8.0      150.150.8.1      150.150.15.254   150.150.15.255
          150.150.16.0     150.150.16.1     150.150.23.254   150.150.23.255
          150.150.24.0     150.150.24.1     150.150.31.254   150.150.31.255
     150.150.32.0          150.150.32.1     150.150.63.254   150.150.63.255
          150.150.32.0     150.150.32.1     150.150.39.254   150.150.39.255
          150.150.40.0     150.150.40.1     150.150.47.254   150.150.47.255
          150.150.48.0     150.150.48.1     150.150.55.254   150.150.55.255
          150.150.56.0     150.150.56.1     150.150.63.254   150.150.63.255
150.150.64.0               150.150.64.1     150.150.127.254  150.150.127.255
     150.150.64.0          150.150.64.1     150.150.95.254   150.150.95.255
          150.150.64.0     150.150.64.1     150.150.71.254   150.150.71.255
          150.150.72.0     150.150.72.1     150.150.79.254   150.150.79.255
          150.150.80.0     150.150.80.1     150.150.87.254   150.150.87.255
          150.150.88.0     150.150.88.1     150.150.95.254   150.150.95.255
     150.150.96.0          150.150.96.1     150.150.127.254  150.150.127.255
          150.150.96.0     150.150.96.1     150.150.103.254  150.150.103.255
          150.150.104.0    150.150.104.1    150.150.111.254  150.150.111.255
          150.150.112.0    150.150.112.1    150.150.119.254  150.150.119.255
          150.150.120.0    150.150.120.1    150.150.127.254  150.150.127.255
150.150.128.0              150.150.128.1    150.150.191.254  150.150.191.255
     150.150.128.0         150.150.128.1    150.150.159.254  150.150.159.255
          150.150.128.0    150.150.128.1    150.150.135.254  150.150.135.255
          150.150.136.0    150.150.136.1    150.150.143.254  150.150.143.255
          150.150.144.0    150.150.144.1    150.150.151.254  150.150.151.255
          150.150.152.0    150.150.152.1    150.150.159.254  150.150.159.255
     150.150.160.0         150.150.160.1    150.150.191.254  150.150.191.255
          150.150.160.0    150.150.160.1    150.150.167.254  150.150.167.255
          150.150.168.0    150.150.168.1    150.150.175.254  150.150.175.255
          150.150.176.0    150.150.176.1    150.150.183.254  150.150.183.255
          150.150.184.0    150.150.184.1    150.150.191.254  150.150.191.255
150.150.192.0              150.150.192.1    150.150.255.254  150.150.255.255
     150.150.192.0         150.150.192.1    150.150.223.254  150.150.223.255
          150.150.192.0    150.150.192.1    150.150.199.254  150.150.199.255
          150.150.200.0    150.150.200.1    150.150.207.254  150.150.207.255
          150.150.208.0    150.150.208.1    150.150.215.254  150.150.215.255
          150.150.216.0    150.150.216.1    150.150.223.254  150.150.223.255
     150.150.224.0         150.150.224.1    150.150.255.254  150.150.255.255
          150.150.224.0    150.150.224.1    150.150.231.254  150.150.231.255
          150.150.232.0    150.150.232.1    150.150.239.254  150.150.239.255
          150.150.240.0    150.150.240.1    150.150.247.254  150.150.247.255
          150.150.248.0    150.150.248.1    150.150.255.254  150.150.255.255
-----------------------------------------------------------------------------

Understanding: Top four lines show the basic information like the IP Address and VLSM Mask bits entered by user, and the IP class and masks calculated.

The table that follows shows subnet information similar to SAMPLE OUTPUT 1. It also shows that the major net is divided in 4 subnets due to the mask bits 2. Each of the subnets is divided in 2 sub-subnets due to mask bits 3 (or we can say the major net is divided in 8 subnets). Each sub-subnet is divided into 4 sub-sub-subnets due to mask bits 5 (or we can say that the major net is divided into 32 subnets).

Once this division is understood, a network planner can use a subnet in one portion of the network with more users, and a sub-subnet out of another subnet in some portion of the network with less users. Note that if a subnet has been used in one portion of the network, its sub-subnets or sub-sub-subnets shouldn't be used in other portions of the network. Good planning should lead to logically easy route summarizations.

Error Messages & Warnings

Errors

Address can't start with a 0.
An IP Address input with first byte zero has been entered. This is not a class A, B, or C address. So 0.50.33.5 will cause this error.

Address is missing.
IP Address input has not been specified. It is required for all actions.

Address or Mask has illegal characters.
An IP Address, Address Mask, or VLSM Mask input has characters other than decimal numbers or dots (even spaces are not allowed). So 123.123.!23.123 will cause this error.

Address or Mask has illegal numbers.
An IP Address, Address Mask, or VLSM Mask input has a number greater than 255. This is not allowed as each number in IP address represents one byte which can store a maximum decimal value of 255. So 255.255.256.0 will cause this error.

Address or Mask too long.
An IP Address, Address Mask, or VLSM Mask input string passed from HTML browser to CGI script has more than normal size (16 character, like 255.255.255.255 plus the NULL string terminator). So 123.123.123.1234 will cause this error.

HTML input variable string is too long.
The total HTML string (including variable names, values, and special characters) sent from HTML browser to the CGI script is more than normal length (I chose 1000 characters for no special reason). As the tool's user interface will not generate such a long string, this error message should never show up. If it does show up, then user may have pressed too many spaces in some input box, or Web is just going crazy, or in worst case CGI server is out of mind.

Mask is missing.
Address Mask input has not been provided by user when action "Find IP Subnet for this address" or "Calculate All IP Subnets" is chosen. This input is required for specified actions.

Mask is not good.
An Address Mask, or VLSM Mask input doesn't contain a valid mask. For example, 255.0.255.0 will cause this error. In this case, mask is not too long, contains no illegal numbers or characters, however, it is not contiguous.

Minimum subnets or hosts/subnet entry is missing.
Minimum Subnets or Minimum Hosts/Subnet input has not been provided by user when action "Design IP Subnetting (maximize subnets)", "Design IP Subnetting (maximize hosts)", or "Design IP Subnetting (minimize wastage)" is chosen. This input is required for specified actions.

No Action selected.
None of the possible actions has been selected by user. An action must be selected for achieving results.

Something is really wrong!
This message is in the CGI script for second level checking. During any operation the first level checking (which generates all other error messages and warnings) should catch all errors and exceptions, and this message should not show up at all. If it does show up, reload the tool from HTML browser, as it is due to the browser sending illegal data to the CGI script.

Subnets or Hosts are zero or invalid.
Minimum Subnets or Minimum Hosts/Subnet input provided by user is either zero or an illegal character, when action "Design IP Subnetting (maximize subnets)", "Design IP Subnetting (maximize hosts)", or "Design IP Subnetting (minimize wastage)" is chosen. This input should be a non zero decimal number for specified actions (especially Minimum Subnets input; CGI script may work around Minimum Hosts/Subnet being zero). If you want your Minimum Hosts/Subnet requirement to be regardless of Minimum Subnets, then use 1 as Minimum Subnets.

VLSM masks are missing.
None of the three VLSM Masks have been provided by user, when action "Calculate Subnetting using VLSM" is chosen. This input is required for specified action.

Warnings

Either there are no usable hosts, or no usable subnets.
The inputs and action are such that number of hosts or subnets is zero or less). For example, class C IP Address 200.200.200.0 and Address Mask 255.255.255.254, with action "Calculate All IP Subnets" will cause this warning. This is because out of the only two hosts possible in any subnet, one is the subnet address and the other is broadcast address for that subnet.

No Subnetting Used.
The inputs and action are such that number of bits in classful mask is zero. For example, class C IP Address 200.200.200.0 and Address Mask 255.255.255.0, with action "Calculate All IP Subnets" will cause this warning.

Your desired minimum subnets and hosts requirement not met.
Minimum Subnets or Minimum Hosts/Subnet input provided by user is such that it can't achieved for the given IP Address, when action "Design IP Subnetting (maximize subnets)", "Design IP Subnetting (maximize hosts)", or "Design IP Subnetting (minimize wastage)" is chosen. For example, a network IP Address 200.200.200.0, Minimum Subnets 14, and Minimum Hosts/Subnet 20 will cause this error. This is because we need at least 16x32 = 512 addresses to meet the minimum requirements (used 16 and 32 because they fall on the next bit boundary), while class C networks have at most 256 addresses.