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.
Current TCPmag.com
user comments for "Using One DHCP Server To Serve Multiple VLANs on Different Subnets"
8/23/04 -
Mike
from Minneapolis
says:
I have a similar question relative to VOIP. We have been using our routers for DHCP for phones. Due to some legacy mainframe issues, we have not until reciently tried DHCP for our workstations.
We have about 100 WAN connected sites and about 2000 P.C.'s. Our intent is to centrally use MS2000 DHCP and ip-helper addresses to dole out addresses for the PC's from our main site. The snag is that the locally attached routers will probably serve up a lease from the voice IP range before the initial request makes it to our main site DHCP servers.
How can I effectively manage this process. Would I need to trunk the voice VLANS across the WAN? Can I keep the phone DHCP in the local routers and still allow the PC's to be managed centrally?
Thank you for your thoughts.
10/13/04 -
padmanabhan
from Chennai, India
says:
Thsi article addresses exactly the issues I had on this topic. Brief and to the point.
Thanks for this one.
1/24/05 -
Chris
from San Jose
says:
Great article! Out of curiosity, which DHCP servers support this extended functionality? For instance, would an ISC DHCP daemon or a Microsoft Windows DHCP server be able to be used in the "ip helper-address" manner?
1/24/05 -
Chris
from San Jose
says:
Nevermind. It turns out that the standard ISC daemon works with this no problems. Thanks for your help, Scott!
3/5/05 -
Asad Anwer
from New Delhi, India
says:
Thanks scott, That was really very helpfull for me to understand DHCP process under multiple Vlans.
But can u tell me which commands needs to configure on a cisco cat 6509 sw and why for configuring DHCP on a diffrent network.
Thanks
Asad
4/14/05 -
R L
from Los Angeles
says:
Thanks Scott! I have the same question as Asad in New Delhi
Any Ideas...?
4/24/05 -
Muruganantham
from India
says:
Hi
We are planning to implement VLAN on our environment. Our existing setup has a DHCP server with 6 NIC for 6 Subnets. Our requirement is to implement 25 subnet with two DHCP servers with split scope for redundancy method 50/50.I doesn’t know how to attain this.
5/17/05 -
Kfir Cohen
says:
Scott
Can i use all this configuration with a dhcp server that have only one NIC and multi subnets.
Do you know a way to make dhcp server work with one nic that connect to a multi vlans?
is network aliases work in this configuratoin?
thanks
5/31/05 -
Jacqui
from New Jersey
says:
Scott, that was a wonderful article and it focuses directly on what my office will be doing. However, my question pertains to the ip scheme and setup. All of our network equipment has ip's of 172.16.0.x, all of my servers have ip's of 172.16.1.x, my vlans will have ip ranges from the 172.16.16.x-172.16.23.x (split up per group for our existing scheme). I have 2 NIC's currently in my server running Windows 2003. Will I need to configure the 2 server NIC's with an IP from every VLAN??? I mainly wanted to use the 2 cards for load balancing. This is obviously a new scheme that we are pushing out and unfortunatley, no on in our IT department has ever configured anything this detailed, including me.
6/11/05 -
Marty B
from Phila
says:
Here is a twist to this scenario:
I have 2 offices setup over a WAN with a firewall / VPN on either side and the networks on either side setup with a different network number (192.168.1.x & 192.168.0.x) - There are 2 win2K servers (1 in each location) - and 2 users which travel between offices using laptops. Can I just set up a DHCP server on each side, or will there be a conflict ?
6/21/05 -
AJ
from South Africa
says:
GREAT Article! Thanks for the info!
8/30/05 -
Karthikeyan S.
from Chennai
says:
Eventhough i am a beginner to DHCP, i understood lot more from this docs.
9/11/05 -
Luis Gonzalez
from Puerto vallarta
says:
Exelente articulo, entendi todo lo que necesitaba saber, gracias por la informacion de hecho deberian poner mas blogs de este tipo.
9/29/05 -
Julio
from Chile
says:
hi, i found it this line in a 4506 SW
ip helper-address x.x.x.255
is this correct?
thanks.
10/21/05 -
Jesús Campos
from Aguascalientes México
says:
that ok whit 3 interfaces, one for each vlan, but what happen if we have a lot of vlans ? 60 per example?, thanx
11/19/05 -
Anonymous
says:
How do you configure two separate subnets within a private network.
12/1/05 -
Richard
from Kingston, Jamaica (W.I.)
says:
This site is my new haven for network help. The explanation are so clear its not funny. Its like you know exactly what i want to hear and explain it for the layman and expert.
Tons and tons of thanks.
3/27/06 -
Robin
from Brazil
says:
Scott i am having problems with my dhcp i allready posted a message in expert exchange but i could not get solved, i created the scope in the 2003 server i configured the ip helper address in the switch if i put the static ip i can ping my switch and the dhcp server but when i try to get ip it does not work.
Since now my thanks
Can you help me???