Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1493
  • Last Modified:

Convert CIDR to IP

My apologies if this has been answered.

I'm having a hard time understanding how to turn, for example, 172.16.32.0/21 in to a subnet mask... I know it's not tough but for some reason, it's eluding me.

Any 'lamens' help would be much appreciated :).
0
GaleBeckwith
Asked:
GaleBeckwith
  • 3
  • 2
  • 2
  • +3
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
This calculator http://www.subnet-calculator.com/cidr.php seems to work right.  Enter the base IP (172.16.32.0) and then below that the mask bits (21) and it calculates the rest.
0
 
GaleBeckwithAuthor Commented:
I'm actually trying to figure out how to do it myself, without a calculator.
0
 
Dave BaldwinFixer of ProblemsCommented:
Then this is a better explanation: http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing   If you take the IP address as 4 8-bit bytes, the mask number is the left-most bits, 21 in your case.  I don't think all combinations are valid though.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
Jan SpringerCommented:
I find it's easiest when looking at the mask in binary with the offset starting at 0 (not 1):

/21 = 21 bits to the mask 11111111.11111111.11111000.00000000

1            1            1           1          1         1        1        1   =   11111111 = 255
-------------------------------------------------------------------
 128     64         32         16          8         0        0         0  =    248

128+64+32+16+8 = 248

/21 = 255.255.248.0
0
 
GaleBeckwithAuthor Commented:
Thanks Jesper... but could you explain how you put the /21 into binary a little more, if you can, please?
0
 
Dave BaldwinFixer of ProblemsCommented:
I'm curious what you are expecting.  What _jesper_ showed is the same as on the link I posted and is the way it is normally done.  There are a few rules and restrictions in addition but that is the 'math' to do it.
0
 
Jan SpringerCommented:
There are 8 bits to each octet => 11111111

There are four octets that define the value of an IP address or netmask.

Add the binary bits from right to left with the value of the bit to the immediate left being double the amount of the bit to its right.                  1      1   1    1   1  1  1  1
                                                                                --------------------------------
There are a maximum of 255 bits to each octet => 128+64+32+16+8+4+2+1

(count the number of "1"s below)

/21 = 1 1 1 1 1 1 1 1     .     1 1 1 1 1 1 1 1     .      1 1 1 1 1 0 0 0                     .     0

                 255                     255                            128+64+32+16+8 = 248      .    0

                                            255.255.248.0

How many bits are remaining?  7 = 4+2+1.   This is also the number used in an inverse mask.  Add 7 to the 3rd octet and you will see the last usable number within that field that you may use within that /21.  Because you include the starting subnet boundary, you have a total of 8 /24s for your use.
0
 
BillBondoCommented:
Hope I remember this correctly.... I just count on my fingers. You are using 11 bits for your computers and 5 for the subnets. 11 should give you 2048 computers per subnet and 32 subnets. With 3 bits being used in the second octet, you would count 2-4-8 and subtract 8 from 256 and get 248.   Bit count goes on your fingers 2 4 8 16 32 64 128 256 .... Been a while since I took that ccna. So if I have it correct and using your address and I needed 500 users per subnet, I should have a mask of /23 or 255.255.254.0 giving me 512 users for 128 subnets.
0
 
rochey2009Commented:
Hi,

The /21 determines how many bits in the subnet mask are set to one from left to right as you write them down. After you've written down 21 consecutive one's, start writing consecutive zero's until you have 32 bits. (Break them up into 8 bits separated by a decimal point)

In binary this will be:

Subnet Mask = 11111111.11111111.11111000.00000000

Convert the binary to decimal:

Subnet Mask = 255.255.248.0
0
 
Darr247Commented:
And I'll add another $0.02 worth...

Given a starting address of 172.16.32.0 /21

Without a calculator, you count the total bits to convert from  'slash' format. e.g.
1111 1111 . 1111 1111 . 1111 1000 . 0000 0000 Subnet Mask = /21 (out of 32-bits total)
           255  .            255 .   3rd octet  .   4th octet


3rd octet in mask            times 256 (from the 4th octet - 0 through 255 = 256)
1111 1111 = /24  = 255   (1     *  256 =     256 IPs)  172.16.32.0 to 172.16.32.255
1111 1110 = /23  = 254   (2     *  256 =     512 IPs)  172.16.32.0 to 172.16.33.255
1111 1100 = /22  = 252   (4     *  256 =   1024 IPs)  172.16.32.0 to 172.16.35.255
1111 1000 = /21  = 248   (8     *  256 =   2048 IPs)  172.16.32.0 to 172.16.39.255
1111 0000 = /20  = 240   (16   *  256 =   4096 IPs)  172.16.32.0 to 172.16.47.255
1110 0000 = /19  = 224   (32   *  256 =   8192 IPs)  172.16.32.0 to 172.16.63.255
1100 0000 = /18  = 192   (64   *  256 = 16384 IPs)  172.16.0.0  to  172.16.63.255
1000 0000 = /17  = 128   (128 *  256 = 32768 IPs)  172.16.0.0  to  172.16.127.255
0000 0000 = /16  =     0   (256 *  256 = 65536 IPs)  172.16.0.0  to  172.16.255.255

Available IP addresses is always 2 less than possible, because one is reserved as the network identifier and one is reserved as the broadcast IP.

So, for the 172.16.32.0 /21 network, there are really only 2046 IPs available.

---
There are 10 kinds of people - those who think in binary, and those who don't.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now