DHCP relay agents enable clients on one VLAN to reach DHCP servers located on a separate network segment. This topic covers how to configure a Cisco Layer 3 switch as a relay agent for both IPv4 and IPv6 DHCP traffic.
DHCP Relay Agent Setup
We've talked a lot about IP addressing, we've talked about SLAAC, we've talked about DHCP, we talked about IPv4 and IPv6. We've gone over a lot of information, but so far we've really been talking about communication that happens across a layer 2 network. That is the communication that's happening on your local area network. Broadcast and multicast, these communications that are going out on your network, are all from a layer 2 perspective.
But there are sometimes when we want to remove some of these services and put them on another network, and so what will happen is that communication doesn't get to that other network. And so what we need to do is we need to set up some sort of relay agent. We can use your Cisco devices as relay agents for this information.
In the examples we talked about, this demo Pi 2 being a DHCP version 6 server, or perhaps maybe it is just a DHCP server, whatever the case may be, this demo laptop is on a different network. So if we're talking about DHCP, that initial request is not going to go outside of VLAN 10. Same thing when it comes to DHCP version six, that initial request stays within VLAN 10, and this is part of VLAN 20. This demo Pi 2 is part of VLAN 20. So somehow we need something that's going to take these requests from VLAN 10 and send it to VLAN 20. And so what we're going to do is we're going to talk about turning this layer 3 switch into a relay agent for this information.
What's going to happen is the request is going to be sent out, whether we're talking about DHCP for IPv4 or we're talking about DHCP version 6. This demo laptop will send out the request. This layer 3 device will then take that request and then forward it on, and it could be in a very distant network. In this one it happens to be also a locally connected network, but it could be in a whole other location. And then it sends the information back to this switch right here, and then this switch then sends it to the demo laptop. So that's how this communication happens across here.
The idea behind this is that many of your servers you want on a separate network. You probably do want to put your devices that need to be more secure, and you want to control some of the access to that, so you have it on this separate network. So how do we get that DHCP response to get back to those clients?
One thing to note is I can actually set this up for many different services, so I can set up different layer 2 services to be forwarded onto a server, but we're just going to take it from the DHCP standpoint at this point, because that's what we're specifically talking about here.
So the first thing I'm going to do is get into the global configuration mode, and then in the global configuration mode I can do my ipv6 unicast-routing. This is the same command that we've been using to turn on SLAAC and turn on the ability to send out the router advertisements, so now we do it with this one as well.
The next thing I'm going to do is get into an interface. In this particular case, what we're doing is we're getting into the interface that we want to accept that layer 2 packets that are being sent out, frames that are being sent out. So we say interface VLAN 10 to get into that interface, so that way that is the VLAN that we are going to take those layer 2 information and forward it onto a server.
So then I'm going to type in my ip helper-address statement, and the address, 10.1.20.22, it's in a different VLAN, so that's the IP address I want to send it to. And there you have it, we set it up. Now if a DHCP request comes in for IPv4, it's going to now send it to 10.1.20.22, that demo Pi 2. It's going to send those requests onto there.
So if we want to do IPv6, then the command for IPv6 is ipv6 dhcp relay destination, and then the destination it's going to go to, which is going to be fc00:1:20::22. We're going to get that command in there, now it's going to relay that information off. For IPv6, the DHCP request is going to be sent now to that demo Pi 2 that we have.
One of the commands that we can do just to take a look at and see what's happening here: I can do a show ipv6 dhcp interface, and then the interface that we want, which is VLAN 10. Hit enter, and now we can see the relay destination that's added into there. So there you have it, this is up and functioning.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →