Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am currently trying to understand VLS....but I don't quite get it how an address space is divded up to accomidate different length subnets, For example,

Suppose you were given the IPv4 network block
137.73.64.0/20. Using variable length subnet masking (VLSM)
divide the network block in order to provide the following
subnetworks:
1. A, with at least 1800 hosts
2. B and C, with at least 500 hosts each
3. D, E and F, with at least 240 hosts each

I understand the way to do it is to

1. Take each subnet in turn, starting with the one
with largest number of hosts
2. Calculate bits required to represent this number
of hosts
3. Use remainder of host ID bits for subnet's ID
4. Allocate one subnet ID to the subnet that does
not have the same prefix as any of the already
allocated subnets
5. Move on to next largest subnet

But I still do not quite understand for the life of my how to arrive at this answer:

A possible solution, with subnet IDs highlighted, is:
A: 137.73.01000000.0 = 137.73.64.0/21
Host addresses: 2^11 − 2 = 2048 − 2 = 2046
B: 137.73.01001000.0 = 137.73.72.0/23
Host addresses: 2^9 − 2 = 512 − 2 = 510
C: 137.73.01001010.0 = 137.73.74.0/23
host addresses: 2^9 − 2 = 512 − 2 = 510
D: 137.73.01001100.0/24 = 137.73.76.0/24
host addresses: 2^8 − 2 = 256 − 2 = 254
E: 137.73.01001101.0/24 = 137.73.77.0/24
host addresses: 2^8 − 2 = 256 − 2 = 254
F: 137.73.01001110.0/24 = 137.73.78.0/24
host addresses: 2^8 − 2 = 256 − 2 = 254
Unallocated:
137.73.01001111.0/24 = 137.73.79.0/24
host addresses: 2^8 − 2 = 256 − 2 = 254 (unallocated)
Range of addresses unused: 137.73.79.1/24 to 137.73.79.254/24

Can anyone talk me through it maybe?

share|improve this question

migrated from stackoverflow.com Dec 29 '09 at 14:38

This question came from our site for professional and enthusiast programmers.

1  
I'm just gonna plug Evan Anderson's thorough answer serverfault.com/questions/49765/… –  Zypher Dec 29 '09 at 16:33

4 Answers 4

up vote 1 down vote accepted

The easiest way for me to remember is to take the largest range you need first (1800 hosts). This means you need to go for a total of 2048 (2^11) and to find your slash notation you just take 32 - 11 = 21 so your answer to 1 is:

A 137.73.64.0/21

The subnet mask of a /21 is 255.255.248.0 to find out your block size you take 256 - 248 = 8

This means your A address spaces ends at:

137.73.71.255

This means your next highest address space (B with 500 hosts) will start at:

137.73.72.0

The B address space will use 512 (2^9) so your slash is 32 - 9 = 23 Which means your B address space is:

137.73.72.0/23

The subnet mask of a /23 is 255.255.254.0 so the block size is 256 - 254 = 2 Therefore your B ends at:

137.73.73.255

And your next highest (C with 500 hosts) starts at:

137.73.74.0

Since your C has the same hosts as your B it uses the same subnet mask (/23):

137.73.74.0/23

Its block size is also 2 which means C ends at:

137.73.75.255

Your next highest address space (D with 240 hosts) will start at:

137.73.76.0

The D address space will use 256 (2^8) so it's slash notation is 32 - 8 = 24:

137.73.76.0/24

A /24 has a subnet mask of (255.255.255.0) so it's block size is 256 - 255 = 1 Therefore, your D address space will end at:

137.73.76.255

Your E address space is the same as D so it has a block size of 1 and a /24:

137.73.77.0/24

Since its block size is 1 it ends at:

137.73.77.255

Your F address space is also the same as D and E so it has a block size of 1 and a /24:

137.73.78.0/24

Since its block size is 1 it ends at:

137.73.78.255

Therefore, your final subnets are:

A 137.73.64.0/21
B 137.73.72.0/23
C 137.73.74.0/23
D 137.73.76.0/24
E 137.73.77.0/24
F 137.73.78.0/24

To find your unallocated, you use the same concepts. You have a /20 which has a subnet mask of 255.255.240.0 so it's block size is 256 - 240 = 16

Your entire range of addresses are:

137.73.64.0 - 137.73.79.255

Therefore, your unallocated addresses range from:

137.73.79.0 - 137.73.79.255

Which is simply another /24

Hope that helps

share|improve this answer

I usually start by looking at the IP address space in binary and then work from the left using the process that you've described. Here's a walk through of the process. I'll use ? to represent unassigned bits, X for host-id bits and explicitly include the sub-net id bits. We start with the following pattern.

1000 1001  0100 1001  0100 ????  ???? ????      137.73.64/20

Now we need 11 bits for the first sub-net since log2(1800) is less than 11 and greater than 10.

1000 1001  0100 1001  0100 ?XXX  XXXX XXXX      137.73.64/21

The one bit marked with a ? is the only wild-card bit left. Assign it a value of zero and you've defined the first sub-net. The remaining sub-nets will use a value of one so:

1000 1001  0100 1001  0100 ????  ???? ????      137.73.64/20
1000 1001  0100 1001  0100 0XXX  XXXX XXXX      137.73.64/21    2,048 addresses
1000 1001  0100 1001  0100 1???  ???? ????      137.73.72/21

Next we need a sub-net with a capacity of 500, so we need nine bits. We have 11 remaining in the host-id so we can safely wire down the next two bits.

1000 1001  0100 1001  0100 ????  ???? ????      137.73.64/20
1000 1001  0100 1001  0100 0XXX  XXXX XXXX      137.73.64/21    2,048 addresses
1000 1001  0100 1001  0100 100X  XXXX XXXX      137.73.72/23      512 addresses
1000 1001  0100 1001  0100 101?  ???? ????
1000 1001  0100 1001  0100 11??  ???? ????

The next sub-net is also nine bits so we can use another of the left over bits.

1000 1001  0100 1001  0100 ????  ???? ????      137.73.64/20
1000 1001  0100 1001  0100 0XXX  XXXX XXXX      137.73.64/21    2,048 addresses
1000 1001  0100 1001  0100 100X  XXXX XXXX      137.73.72/23      512 addresses
1000 1001  0100 1001  0100 101X  XXXX XXXX      137.73.74/23      512 addresses
1000 1001  0100 1001  0100 11??  ???? ????

The next three sub-nets are easy - they are all eight bits. We can simply divy up the remaining wildcard bits from the left to the right.

1000 1001  0100 1001  0100 ????  ???? ????      137.73.64/20
1000 1001  0100 1001  0100 0XXX  XXXX XXXX      137.73.64/21    2,048 addresses
1000 1001  0100 1001  0100 100X  XXXX XXXX      137.73.72/23      512 addresses
1000 1001  0100 1001  0100 101X  XXXX XXXX      137.73.74/23      512 addresses
1000 1001  0100 1001  0100 1100  XXXX XXXX      137.73.76/24      256 addresses
1000 1001  0100 1001  0100 1101  XXXX XXXX      137.73.77/24      256 addresses
1000 1001  0100 1001  0100 1110  XXXX XXXX      137.73.78/24      256 addresses
1000 1001  0100 1001  0100 1111  ???? ????      137.73.79/24      256 addresses

The remaining wildcard range is your unallocated space.

share|improve this answer

A subnet holds a total amount of 2^(32-routing_prefix) (that number after the slash) addresses. You can subtract 2 from that range, one for the so-called "network identifier", one for the broadcast address.

This means that, if you want to allocate addresses for 1800 hosts (1802 addresses in total), you have to go for 2^11 (2048). This gives you a routing prefix of 32-11=21.

The so-called "network identifier" is simply the base address with all the "host" bits set to 0 (meaning, that for the 137.73.64.0/21 you set 11 rightmost bits to zero).

Hope that helps a bit.

share|improve this answer

So I finally finished my calculator.

137.73.64.0  /21 -> 1,800  (2,048)
137.73.72.0  /23 -> 500  (512)
137.73.74.0  /23 -> 500  (512)
137.73.76.0  /24 -> 254  (256) ++
137.73.77.0  /24 -> 240  (256)
137.73.78.0  /24 -> 240  (256)
137.73.79.0  /24 -> 240  (256)

The ++ was added by the calculator. It is the largest unused block in the range.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.