How To Subnet Using VLSM

John Storms (jstorms@livingston.com)
Mon, 21 Jul 1997 13:03:12 -0700

I've been meaning to write this note for a while now since this sort of
thing gets asked quite a bit.

>I am looking for several configs for an Office Router HS to get me going
>on setting up moderate to complicated Varible Length Subnetting
>Configurations.
>
>First off... I am very new to this. Not that that will stop me... I'm
>very... (stubborn would be the polite word)
>
>I want to learn to do this fairly quickly and I have found in the past
>that being able to examine a variety of setups will help me a great deal.

HOW TO SUBNET USING VLSM

HANDY TOOLS FOR SUBNETTING

* First, this subnet table will save you some time.
http://www.livingston.com/Tech/Technotes/Routing/subnet-table.shtml

* Next, you need to be able to convert network bits to netmasks. Just two
different ways of representing a netmask. This chart covers that and then
some.

+----------------------------------------------------------+
| Subnet Masks for a Class C sized Subnet |
+------+----+-------+-----------+----------+---------------+
|Subnet|Host|Num. of|# of hosts/| | Dotted decimal|
|bits |bits|Subnets|subnet | Hex mask | mask |
+------+----+-------+-----------+----------+---------------+
| 24 | 8 | 1 | 254 | 0 |255.255.255.0 |
| 25 | 7 | 2 | 126 |0xffffff80|255.255.255.128|
| 26 | 6 | 4 | 62 |0xffffffc0|255.255.255.192|
| 27 | 5 | 8 | 30 |0xffffffe0|255.255.255.224|
| 28 | 4 | 16 | 14 |0xfffffff0|255.255.255.240|
| 29 | 3 | 32 | 6 |0xfffffff8|255.255.255.248|
| 30 | 2 | 64 | 2 |0xfffffffc|255.255.255.252|
| 32 | 0 | 255 | 1 |0xffffffff|255.255.255.255|
+----------------------------------------------------------+

VOCAB:

These might not be textbook definitions, but this is how I use them in this
document.
* Class C - A 24 bit subnet (255.255.255.0). Often when I refer to a
'class c' I'm referring to a 'class c' sized subnet of 254 hosts.
* Host - A network interface on an individual machine
* Netmask - A 32 bit mask used to define the network portion of an IP
address. Comes in 2 formats. Dotted decimal or using the number of bits
in the network portion.
255.255.255.0 = /24 bits
* Network - a group of IPs matching a specified netmask
* PTP - Point to Point WAN link
* Subnet - a group of IPs matching a specified netmask
* VLSM - Virtual Length Subnet Mask
I'll use "network" and "subnet" interchangably.

HOWTO:

Here's an example of how to plan out a VLSM network.

1) First thing, make a list of everything all IP subnet requirements.

* I'll use the following made-up network as an example.
* Also lets say I have the 192.168.9.0/24 IP subnet network allocated to me.
Thats 192.168.9.1 - 192.168.0.254 useable IPs.

===INTERNET============
|
|
+------------+ +------------+
| s1 | | sn | +------------+ +------------+
| IRX111 | | PM2e30 | |Big Bad PC | |Commodore 64|
| e0 | | e0 | | e0 | | e0 |
+------------+ +------------+ +------------+ +------------+
| | | |
=========main ethernet=========== ====home ethernet=============
| | |
+------------+ +------------+ +------------+
| e0 | | e0 | | e0 |
| IRX114 | | OR/U | | OR/U |
|s1 s2 s3 s4 | | s1/s2|===PTP Dialup===|s1/s2 |
+------------+ +------------+ +------------+
|P
|T
|P
+------------+ +------------+
| s1 | | Proxy |
| IRX211 e1|======Public Ethernet========|e0 Server |
| e0 | | |
+------------+ +------------+
|
======private ethernet========
| |
+------------+ +------------+
| e0 | | e0 |
| BSDI | | PM25 |
|50 virtual | | Sn |
| hosts | +------------+
+------------+

When identifying the need for subnets I come up with the following list:
A. main ethernet, needs 4 ips
B. home ethernet, needs 3 ips
C. public ethernet, needs 2 ips
D. private ethernet, needs 3 ips
E. pm2e30 (main ethernet), needs 30 ips for its IP pool
F. pm25 (private ethernet), needs 25 ips for its IP pool
G. ptp link to home network, needs 2 ips (I'm doing a ptp numbered connection)
H. ptp link to private/public network, needs 2 ips (I'm doing a ptp
numbered connection)
I. BSDI virtual hosting, needs 50 ips.

2) The next step is to figure out how big of subnets I want to give each of
the above. Be
sure to keep in mind future expansion plans of your ethernets and such.

My subnet sizes are as follows:
24 network bits = 254 hosts per subnet
25 network bits = 126 hosts per subnet
26 network bits = 62 hosts per subnet
27 network bits = 30 hosts per subnet
28 network bits = 14 hosts per subnet
29 network bits = 6 hosts per subnet
30 network bits = 2 hosts per subnet
32 network bits = 1 host per subnet

A. main ethernet, needs 4 ips
This one I'm going to give a 29 bit subnet of 6 hosts. I'll 2 ips left
over for future use
on this segment.

B. home ethernet, needs 3 ips
This one I'm going to give a 29 bit subnet of 6 hosts.

C. public ethernet, needs 2 ips
A 30 bit subnet will give me exactly 2 ip address.

D. private ethernet, needs 3 ips
This one I'm going to give a 29 bit subnet of 6 hosts. I'm planning on
putting some web
servers out here later on.

E. pm2e30 (main ethernet), needs 30 ips for its IP pool
A 27 bit subnet with 30 ip address fits perfectly here.

F. pm25 (private ethernet), needs 25 ips for its IP pool
A 27 bit subnet with 30 ip address fits pretty good here.

G. ptp link to home network, needs 2 ips (I'm doing a ptp numbered connection)
A 30 bit subnet will give me exactly 2 ip address.

H. ptp link to private/public network, needs 2 ips (I'm doing a ptp
numbered connection)
A 30 bit subnet will give me exactly 2 ip address.

I. BSDI virtual hosting, needs 50 ips.
A 26 bit subnet will give me 62 hosts which is good because virtual hosting
is something
that may expand.

3) Next, chop up the subnet into smaller subnets to fit each of the subnet
requirements
from step 2.

I've found that drawing a chart like the below is handy.
It represents all 255 ips in the last octet of a class C.
Each column represents a 26 bit subnet (1/4 of a class C)
If I wanted a subnet of 25 bits (1/2 of a chass C) I would span columns 1 &
2, or columns 3 & 4. It could NOT span columns 2 & 3 because we cannot
cross the bit boundries.
-So the first column represents IPs .0 - .63
-The second column represents IPs .64 - .127
-The third column represents IPs .128 - .191
-The second column represents IPs .192 - .255

NOTE: Its a good idea start with the largest subnet requirement and work
your way down to
the smallest.

* My largest sunet requirement is "I" which requires a 26 bit subnet.
"I. BSDI virtual hosting, needs 50 ips."
For this one I'll just use the first column. Which means my virtual hosts
will be .1 - .63.
I prefer to keep bigger subnets to the front, but you don't have to as long
as you don't
cross any bit boundries.

192.168.9.0/24 VLSM Subnet Chart
+---------------+---------------+---------------+---------------+
|.0 |.64 |.128 |.192 |
|"I" BSDI |.65 | | |
|Virtual |.66 | | |
|Hosting |... | | |
|/26 netmask | EMPTY | EMPTY | EMPTY |
|net=.0 | /26 bit | /26 bit | /26 bit |
|ips=.1-.62 |... | | |
|broadcast=.63 |.126 | | |
|.63 |.127 |.191 |.255 |
+---------------+---------------+---------------+---------------+

* My next two largest Subnet requirements are "E" and "F"
E. pm2e30 Address Pool, needs 30 ips for its IP pool = 27 bit subnet (30 ips)
F. pm25 Address Pool, needs 25 ips for its IP pool = 27 bit subnet (30 ips)

Since these two are the same size I'm planning them at the same time.

Note that whenever I increase the netmask by one bit I cut the size of the
subnet in half.
The /27 bit netmask cuts the column (a /26 bit netmask) in half. IP .96 is
the start of the
second subnet in the second column.

Network IPs available Network Network
Address for hosts Broadcast Bits
---------------------------------------------------
.64 .65-.94 .95 /27
.96 .97-.126 .127 /27

192.168.9.0/24 VLSM Subnet Chart
+---------------+---------------+---------------+---------------+
|.0 |.64 |.128 |.192 |
|"I" BSDI |"E" PM2e30 | | |
|Virtual |Address Pool | | |
|Hosting |/27 netmask | | |
|/26 netmask |net=.64 | | |
|net=.0 |ips=.65-.94 | | |
|ips=.1-.62 |broadcast=.95 | | |
|broadcast=.63 | | | |
| | | EMPTY | EMPTY |
| | | /26 bit | /26 bit |
| | | | |
| | | | |
| | | | |
| | | | |
| |.95 | | |
| +---------------+ | |
| |.96 | | |
| |"F" PM25 Addres| | |
| |Pool | | |
| |/27 netmask | | |
| |net=.96 | | |
| |ips=.96-.126 | | |
| |broadcast=.127 | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
|.63 |.127 |.191 |.255 |
+---------------+---------------+---------------+---------------+

* Next I'm going to plan out "A", "B", and "C" from my subnet requirements
since they all
need 29 bit subnets each with 6 ip address available to be assinged to hosts.

A. main ethernet, needs 4 ips, 29 bit subnet => 6 ips for hosts
B. home ethernet, needs 3 ips, 29 bit subnet => 6 ips for hosts
D. private ethernet, needs 3 ips, 29 bit subnet => 6 ips for hosts

Since I've allocated all the IPs in the first two columns I'm going to
start at .128 in the
3rd column. At this point if I had a requirement for a /25 bit subnet
(half a class C) I
could put it here to span columns 3 & 4.

Here is a list of all the /29 bit subnets I could fit into the 3rd column.

Network IPs available Network Network
Address for hosts Broadcast Bits
---------------------------------------------------
.128 .129-.134 .135 /29
.136 .137-.142 .143 /29
.144 .145-.150 .151 /29
.152 .153-.158 .159 /29
.160 .161-.166 .167 /29
.168 .169-.174 .175 /29
.176 .177-.182 .183 /29
.184 .185-.190 .191 /29

I only need 3 /29 bit subnets so I can use the first half of column 3.
This will leave me
with one /29 bit subnet left over. I can subnet this down further for
other smaller
subnets, or I can leave this subnet unused if I were planning on having a
future subnet
requirement for a block this size. We're going to subnet it down further.
NOTE: you cannot
use this /29 bit subnet to combine it with another subnet to make a larger
one.

My notes are starting not to fit in the blocks in the chart, so heres the
information about
the 3 subnets for requirements "A", "B" and "D"

Network IPs available Network Network
Address for hosts Broadcast Bits
---------------------------------------------------
.128 .129-.134 .135 /29
.136 .137-.142 .143 /29
.144 .145-.150 .151 /29
.152 .153-.158 .159 /29

192.168.9.0/24 VLSM Subnet Chart
+---------------+---------------+---------------+---------------+
|.0 |.64 |.128 "A" main |.192 |
|"I" BSDI |"E" PM2e30 |ethernet /29bit| |
|Virtual |Address Pool |.129-.134,.135 | |
|Hosting |/27 netmask +---------------+ |
|/26 netmask |net=.64 |.136 "B" home | EMPTY |
|net=.0 |ips=.65-.94 |ethernet /29bit| /26 bit |
|ips=.1-.62 |broadcast=.95 |.137-.142,.143 | |
|broadcast=.63 | +---------------+ |
| | |.144 "D" privat| |
| | |ethernet /29bit| |
| | |.145-.150,.151 | |
| | +---------------+ |
| | |.152 | |
| | | EMPTY | |
| | | /29 bit | |
| |.95 |.159 | |
| +---------------+---------------+ |
| |.96 |.160 | |
| |"F" PM25 Addres| | |
| |Pool | | |
| |/27 netmask | EMPTY | |
| |net=.96 | /27 bit | |
| |ips=.96-.126 | | |
| |broadcast=.127 | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
|.63 |.127 |.191 |.255 |
+---------------+---------------+---------------+---------------+

* I have 3 ip subnet Requirements left, each need a 30 bit subnet which is
4 ip address, 2
of which can be assinged to hosts.

C. public ethernet, needs 2 ips, /30 bit netmask => 2 ip address for hosts
G. ptp link to home network, needs 2 ips, /30 bit netmask => 2 ip address
for hosts
H. ptp link to sub network, needs 2 ips, /30 bit netmask => 2 ip address
for hosts

First lets take the left over /29 bit subnet from before that starts at
.152. We use a /30
bit netmask and we cut the /29 subnet in half giving us 2 subnets.

Network IPs available Network Network
Address for hosts Broadcast Bits
---------------------------------------------------
.152 .153-.154 .155 /30
.156 .157-.158 .159 /30

We're still short one /30 bit subnet so lets grab the next one in this same
column.

Network IPs available Network Network
Address for hosts Broadcast Bits
---------------------------------------------------
.160 .161-.162 .163 /30

192.168.9.0/24 VLSM Subnet Chart
+---------------+---------------+---------------+---------------+
|.0 |.64 |.128 "A" main |.192 |
|"I" BSDI |"E" PM2e30 |ethernet /29bit| |
|Virtual |Address Pool |.129-.134,.135 | |
|Hosting |/27 netmask +---------------+ |
|/26 netmask |net=.64 |.136 "B" home | EMPTY |
|net=.0 |ips=.65-.94 |ethernet /29bit| /26 bit |
|ips=.1-.62 |broadcast=.95 |.137-.142,.143 | |
|broadcast=.63 | +---------------+ |
| | |.144 "D" privat| |
| | |ethernet /29bit| |
| | |.145-.150,.151 | |
| | +---------------+ |
| | |.152 "C" 30 bit| |
| | +---------------+ |
| |.95 |.156 "G" 30 bit| |
| +---------------+---------------+ |
| |.96 |.160 "H" 30 bit| |
| |"F" PM25 Addres+---------------+ |
| |Pool |.164 EMPTY /30| |
| |/27 netmask +---------------+ |
| |net=.96 |.168 EMPTY | |
| |ips=.96-.126 | /29 bit | |
| |broadcast=.127 |.175 | |
| | +---------------+ |
| | |.176 | |
| | | | |
| | | EMPTY | |
| | | /28 bit | |
| | | | |
| | | | |
|.63 |.127 |.191 |.255 |
+---------------+---------------+---------------+---------------+

* That addresses all of the IP subnet requirements, now lets look at what
we have left over.
We have 3 leftover subnets.

Network IPs available Network Network
Address for hosts Broadcast Bits
---------------------------------------------------
.168 .169-.174 .175 /29
.176 .177-.190 .191 /28
.192 .193-.254 .255 /26

I can't combine .168/29 and .176/28 to create a larger subnet, again
because it crosses bit boundries. If you're using OSPF you could define an
area to have both of these subnets as ranges, but thats routing not
subnetting.

4) Configure Hosts
Next we would set up each individual host. IP Address for interfaces,
gateways, netmasks etc. I'm not going into detail here.

5) Configure Routing
In order for all this to work we need to implement a classless routing
protocol like OSPF. You could use BGP, but that would be like swatting
flies with a sledgehammer. If you like to abuse yourself you could use
static routes to get it all going. Again, routing is not subnetting so I
won't go into detail here.

Thanks to Tom Fellenz for turning the VLSM light on for me.

---
jstorms@livingston.com
Diplomacy:  The art of saying good doggie
while seaching for a big rock.