Tuesday, March 27, 2007

Classless Static Routes using DHCP server

A very hidden and untalked about feature of Microsoft DHCP server is the ability to publish Classless Static Routes to DHCP clients. I have been looking for a feature like this at my company for a while now and was hitting a dry spot over the Internet. So, once I figured out how to successfully do this, I wanted to share it with anyone else who would be looking for this.

Situation:

Consider a situation (like mine), wherein you have a corporate network and want to assign static routes to your client machines, historically the but the only obvious options were:

- to use a *.cmd or *.bat file that the users could execute
- to use a Group Policy to push routes to users

None of these options appealed to me, 'cause about 30-40 percent of my users were mobile users, who often traveled around with their laptops. I did not want the static routes assigned to them, when they connect remotely. Also, they moved frequently between offices and it would create a havoc if they had those routes assigned to them when they were connected at a remote office.

The best possible option would be to somehow assign these routes via DHCP so that their mobile computers forget the route as soon as they disconnected from my network.

This is possible via DHCP option 249 and the appropriate RFC can be found at IETF. I would sincerely recommend giving the RFC a read. It isquite small and easy to understand. Windows 2003 server comes with this option, but for if you are a Network guy who is stuck with Windows 2000 Server (for whatever reason), then you can follow the steps below to
achieve the same:

- Start the DHCP Console


file:///media/sda1/Downloads/Blog/dhcpconsole.png

- Right- Click on "server options" and select "Set Predefined Options" file:///media/sda1/Downloads/Blog/setpredefoptions.png
- Click on "Add" in the "Predefined Options and Values" window, and it
will bring up the "Option type" Window.

file:///media/sda1/Downloads/Blog/addoption.png

- In the "Option Type" window type in the details as shown in the
figure below:

Name = Classless Static Routes
Data type= IP Address : check the checkbox for Array
Code= 249
Description= You can type in any description you want.

file:///media/sda1/Downloads/Blog/classless.png

- Click on "OK" and click on "OK" on the Predefined Options and Values"



Now a little theory on how this Classless Static Route works (or you
could just read the RFP noted above) :

It takes two parameters:

- Destination Descriptor
- Router/Gateway

Destination descriptors describe the IP subnet number and subnet mask
of a particular destination using a particular destination using a
compact encoding. With this kind of encoding the first octet describes
the width of the subnet mask, followed by all the other octets of
the subnet number.

eg:-





































Subnet number Subnet mask Destination descriptor
0 0 0
12.0.0.0 255.0.0.0 8.12
12.0.0.0 255.255.255.0 24.12.0.0
12.19.0.0 255.255.0.0 16.12.19
12.32.131.0 255.255.255.0 24.12.32.131
12.219.0.128 255.255.255.128 25.12.219.0.128

Now that we know how it works, lets start configuring the Scope Options.

- Right-click on "Scope Options" and select " Configure
Options". Select "249 Classless Static Routes" and add the network
address and gateway address one after the other as shown in the figures
below:



file:///media/sda1/Downloads/Blog/addstaticdone.png

- This is how it would look in the DHCP console

file:///media/sda1/Downloads/Blog/addstaticgwdhcpcon.png

- Check your DHCP client ( you may have to renew your IP address for
changes to take effect). Open Command Prompt and type in "route print"

file:///media/sda1/Downloads/Blog/routeprint.png

It sure worked for me.