Q & A
Using One DHCP Server To Serve Multiple VLANs on Different Subnets
by Scott Morris
Question:
June 29, 2004
Hi,
Is it possible for one DHCP server to serve multiple VLANS with
different IP subnets for each VLAN?
VLAN1: 192.168.1.0/24
VLAN2: 192.168.2.0/24
VLAN3: 192.168.3.0/24
How does it work?
Thanks,
-- "Sir June"
Answer:
Sir,
Absolutely!
Oh, you probably want more than that. Well, let's think about how
things work with DHCP, and that will assist in answering the
question.
Typically, when a workstation powers on, or joins a network, it needs
to figure out what's up but doesn't know where to begin. So it sends
out a DHCP Discover packet. At this point, the client lists its
own IP as 0.0.0.0 (since it doesn't know who it is), and addresses
the packet to 255.255.255.255 the global broadcast address.
The All-255's broadcasts are replicated across a broadcast domain, but
not across routed ports. So this really limits us to having a DHCP
server that resides on the same layer 2 network as our client
workstations. This doesn't help you very much.
But continuing down this thought, if a DHCP server is present on the
same LAN, it will receive the broadcast and prepare a DHCP-Offer for
the workstation. It knows which network pool to assign the address from
based on the received interface.
So continuing down this path, if I server were to have three separate
NICs, each on a separate VLAN as you listed, it would seem fairly
simple to pick which pool of addresses (known as a "scope") to
assign from.
| -- advertisement (story continued below) -- | |
|
If the 255.255.255.255 broadcast was received on NIC A (with local
IP of 192.168.1.254), it would be part of the VLAN1 pool. If received
on NIC B (with local IP of 192.168.2.254), it would be part of the
VLAN2 pool. So on and so forth.
Much of the time though, we don't have a DHCP server that "touches"
every LAN in our network. Sometimes the DHCP servers will actually be
in a completely different location. So more magic comes into play here.
There are DHCP forwarding agents that can be involved. This piece of
code will see the 255.255.255.255 UDP broadcast to the DHCP port and
forward it on as a unicast packet (through the network) to a pre- determined
address. Routers have this function called an
"ip helper-address."
So let's put our DHCP server on a 192.168.66.254 address, which is
in some other location physically. When a workstation on VLAN1
powers up, it doesn't know what its IP is, so it sends out the DHCP
Discover packet to 255.255.255.255. The forwarding agent (router)
receives this broadcast and activates the helper-address code. This
resends the message as a unicast packet to 192.168.66.254. So the
DHCP server receives it.
The next catchy part here is to work backwards to figure out what's
going on. The DHCP server receives the packet now, which is one step,
but the next part is to try to determine which scope the IP needs to
be assigned from. Remember, the workstation that was booting doesn't
know who it is, and only has its MAC address already assigned. So
unless you have a reservation by MAC address set up, this won't help
much in narrowing things down.
There are two options though. First, when the router or forwarding
agent resends the DHCP Discover packet as a unicast, it not only
rewrites the destination address to 192.168.66.254, but also rewrites
the source address to its own received interface (192.168.1.253). The DHCP server
can match the pool of the IP source.
Another option is that the DHCP forwarding agent (a.k.a. relay agent)
can also insert a field within the DHCP information called a "giaddr"
field, or "Gateway Interface Address" which allows the DHCP process
to
figure out what the original receiving interface was in order to select
a pool of addresses.
Centralized DHCP servers are becoming a very common thing to help
spruce up the efficiency of networks. I hope this helps answer your
question on the functionality of multiple DHCP scopes on a single
server!
-- Scott
Send your toughest CCIE-level technical questions to editor@tcpmag.com.
Scott Morris, quadruple CCIE, JNCIE and all-around uber-geek, can often be seen
traveling around the world consulting and delivering CCIE training. He recently
accepted a new Senior CCIE Instructor position with Internetwork Expert! For more
information on him check out http://www.uber-geek.net
or for CCIE training check out http://www.internetworkexpert.com.
You can contact Scott via editor@tcpmag.com. You can contact Scott
about "Using One DHCP Server To Serve Multiple VLANs on Different Subnets" at editor@tcpmag.com.
|