Solved

Convert CIDR to IP

Posted on 2012-03-28
10
1,304 Views
Last Modified: 2012-10-24
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
Comment
Question by:GaleBeckwith
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37778211
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
 

Author Comment

by:GaleBeckwith
ID: 37778214
I'm actually trying to figure out how to do it myself, without a calculator.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37778248
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 28

Accepted Solution

by:
Jan Springer earned 500 total points
ID: 37778317
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
 

Author Comment

by:GaleBeckwith
ID: 37778321
Thanks Jesper... but could you explain how you put the /21 into binary a little more, if you can, please?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37778576
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
 
LVL 28

Expert Comment

by:Jan Springer
ID: 37778624
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
 
LVL 11

Expert Comment

by:BillBondo
ID: 37778894
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
 
LVL 17

Expert Comment

by:rochey2009
ID: 37779577
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
 
LVL 44

Expert Comment

by:Darr247
ID: 37780203
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DNS and NSLOOKUP 21 74
Valid LIN protocol Protected ID values 1 37
Network access 4 37
Switch ports not working 8 31
Configuring network clients can be a chore, especially if there are a large number of them or a lot of itinerant users.  DHCP dynamically manages this process, much to the relief of users and administrators alike!
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now