By default DHCP works via broadcasting on the local subnet and therefore is limited to being able to provide IP addresses for devices on its subnet only. In modern day networks this is a serious limitation as it would mean that for every subnet you would need a DHCP server – imagine the management overhead!
So how can we configure a DHCP server in one subnet to respond and provide IP addresses to clients in multiple other subnets? The answer is to use a DHCP Relay Agent.
The following article explains how to configure a DHCP relay agent for a Cisco SG300 Layer 3 managed switch.
In my home test lab I installed a Microsoft Server 2012 DHCP server in one of my subnets (192.168.10.0/24) to be used to lease IP addresses to devices in another subnet (192.168.100.0/24).
To help you better understand what I was trying to achieve, I drew a quick diagram:
Basically to get this working I needed to configure my Cisco SG300–10 Layer 3 managed switch to be a DHCP relay so that I could get across subnet (or across VLAN) DHCP working.
What is a DHCP Relay Agent?
A DHCP relay agent is a small program that relays DHCP/BOOTP messages between clients and servers on different subnets. To support and use DHCP service across multiple subnets, the router(s) that connect each subnet must support DHCP/BOOTP relay agent capabilities.
DHCP Relay configuration on Cisco SG300 Managed Switch
Once I had configured my Microsoft DHCP server, I then needed to enable and configure the Cisco SG300 managed switch to be a DHCP relay. Here is how I did that:
1. From a browser, navigate to the Cisco SG300 switch IP address. Log in as a user with administrator privileges
2. From the main menu, navigate to IP Configuration >> DHCP Snooping/Relay >> Properties
3. From here enable the following and then click Apply
4. From the DHCP Relay Server Table section, click on Add. From the window that appears enter the IP address of the DHCP server (in this case 192.168.20.1) and then click Apply
5. From the main menu, navigate to IP Configuration >> DHCP Snooping/Relay >> Interface Settings. Click the Add button
6. From the window that appears, select the VLAN you want to allow DHCP for (in this case VLAN 100) and then enable DHCP Relay. Finally click Apply
7. Repeat steps 5 and 6 above for each VLAN that required DHCP access. In my case it was only one (VLAN 100)
8. Test to ensure you get an IP address from the DHCP server
Microsoft DHCP Server Configuration
Although this article is not about how to configure a Microsoft DHCP server, for completeness sake, I thought I would add a few screenshots of how I configured my DHCP scope for the 192.168.100.0/24 subnet: