Dynamic Host Configuration Protocol (DHCP) is a service that runs at the application layer of the Transmission Control Protocol/Internet Protocol (TCP/IP) stack to dynamically assign IP addresses to DHCP clients, and to allocate TCP/IP configuration information to DHCP clients. DHCP relay is a feature that is used by a switch, also known as the relay agent, to allow DHCP communication between hosts and remote DHCP servers that are not on the same network. When a client sends out a DHCP broadcast for an IP address, the relay agent forwards the request to the subnet at which the remote DHCP server resides.
Configuring DHCP relay properties on a switch allows you to enable DHCP relay globally and establish a connection between the switch and a remote DHCP server. Once the feature is enabled, the switch will include information about itself when it sends DHCP packets to and from clients to a DHCP server. This will add more security to the DHCP process by thoroughly identifying the connection. You can also enable DHCP relay to be applied on specified interfaces.
This article provides instructions on how to configure DHCP Properties through the Command Line Interface (CLI) of your switch.
Note: To learn how to configure the DHCP properties of your switch through the web-based utility, click here. To know how to configure the DHCP snooping settings on your switch, click here.
1.4.7.05 — Sx300, Sx500
188.8.131.52 — Sx350, SG350X, Sx550X
Configure DHCP Relay on the Switch through the CLI
Configure Global IP DHCP Relay
Step 1. Log in to the switch console. The default username and password is cisco/cisco. If you have configured a new username or password, enter the credentials instead.
Note: The available commands or options may vary depending on the exact model of your device. In this example, the SG350X switch is accessed through Telnet.
Note: In this example, the switch is accessed through Telnet.
Step 2. In the Privileged EXEC mode of the switch, enter the Global Configuration context by entering the following:
Step 3. The DHCP relay feature is disabled by default. To globally enable the DHCP relay feature on the switch, enter the following:
Step 4. (Optional) To globally disable the DHCP relay feature, enter the following:
Step 5. To specify the DHCP server or servers available for the DHCP relay, enter the following:
ip-address — Specifies the DHCP server IP address. You can define up to eight DHCP servers.
Note: In this example, the IP addresses of the servers are 184.108.40.206 and 220.127.116.11.
Step 6. (Optional) To remove a DHCP server from the list, enter the following:
Step 7. (Optional) To enable the DHCP Option 82 data insertion on the switch, enter the following:
Note: Option 82 is used to protect the switch from attacks such as IP and Media Access Control (MAC) address spoofing. It provides information about the location of the DHCP client through the insertion of the circuit ID (interface name at which the DHCP client is connected and the Virtual Local Area Network (VLAN) name that corresponds to the interface) and the remote ID (MAC address of the switch) in the packet header of the DHCP packet. The DHCP server then uses this information to assign an IP address. DHCP Option 82 can only be enabled if DHCP relay or DHCP snooping is enabled.
Step 8. (Optional) To disable the DHCP Option 82 data insertion, enter the following:
Step 9. Enter the exit command to go back to the Privileged EXEC mode of the switch.
Step 10. (Optional) In the Privileged EXEC mode of the switch, save the configured settings to the startup configuration file by entering the following:
Step 11. (Optional) Press Y for Yes or N for No on your keyboard once the Overwrite file [startup-config]… prompt appears.
You should now have successfully configured the global IP DHCP Relay settings on your switch through the CLI.
Step 1. In the Privileged EXEC mode of the switch, enter the following to display the global DHCP Relay settings:
Note: In this example, DHCP relay and Option 82 are both globally enabled. DHCP relay is enabled on ports Gigabit Ethernet 1/0/5 and Ten Gigabit Ethernet 1/0/3, and VLANs 40 and 50. The DHCP servers are 18.104.22.168 and 22.214.171.124.
Step 2. To display the DHCP Option 82 configuration, enter the following:
Note: In this example, Option 82 is enabled.
You should now have verified the configured DHCP Relay settings on your switch through the CLI.