# DHCP Snooping Configuration

#### In this How To we will cover how to configure DHCP Snooping with the L3 device in our network as the DHCP server. First thing we will have to do is configure the baselines for all devices. SW1, SW2, and SW3 will have VLANs 10,20 created, and all trunks links configured. The Router will have a DHCP pool configured and sub-interfaces.

#### This How To assumes you already know how to configure these technologies. If you do not know how to configure refer to the other How To's.

<figure><img src="https://2373667134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8zF1bBBRr6t1PCyfuXHu%2Fuploads%2FrcgKz49OFrJzr0XoayYd%2Flayer_2_security_network_diagram.png?alt=media&#x26;token=9b445e23-b4bc-4301-8671-e1b200afa4cc" alt=""><figcaption><p>Layer 2 Network Security Diagram</p></figcaption></figure>

## Configuration

#### First we will have to determine the **"trusted"** and **"untrusted"** interfaces in the network. **"trusted"** ports will be the links that are receiving the DHCP server messages. \[SW2--Eth0/2], \[SW3--Eth0/0], \[SW1--Eth0/1]. The **"untrusted"** ports will be all the ports that receive incoming DHCP client messages. Now let's start are basic configuration.

`SW1(config)#ip dhcp snooping` # This command will enable **"DHCP Snooping"** globally on our switch

`SW1(config)#ip dhcp snooping vlan 10,20` # This command will enable DHCP snooping to be enabled for the specified VLANs.

`SW1(config)#interface eth0/2` # This command will bring us into the sub-configuration mode for the interface we want to configure

`SW1(config-if)#ip dhcp snooping trusted` # This command will specify the interfaces that can receive incoming DHCP server messages. \*\*\* _**IMPORTANT NOTE**_ \*\*\* The trusted interfaces will add DHCP option 82 to onto the DHCPDiscover message. This option will cause DHCP relay's to drop the DHCP packet.

#### The full configuration is shown below.

<figure><img src="https://2373667134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8zF1bBBRr6t1PCyfuXHu%2Fuploads%2FRpT52vp1ccL0vMZyd2iR%2Fdhcp_snooping_basic_config.png?alt=media&#x26;token=b4363a9f-dbf5-4a32-a73a-58d2b3c4336b" alt=""><figcaption><p>ip dhcp snooping command/configuration</p></figcaption></figure>

#### Now let's try to pull a DHCP address. We will show a wireshark capture and a debug message from SW2 that shows the packet being dropped because of the DHCP option 82 being inserted.

`SW2#debug ip dhcp snooping packets` # This debug command will show us the steps of the DHCP snooping process.

<figure><img src="https://2373667134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8zF1bBBRr6t1PCyfuXHu%2Fuploads%2FOcyX6F478dLOmj2v8FQx%2F82_option_capture.png?alt=media&#x26;token=db0f2b0d-ef87-46c6-a40a-a0fd8836561e" alt=""><figcaption><p>Wireshark Capture of the DHCP 82 Option Being Added</p></figcaption></figure>

<figure><img src="https://2373667134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8zF1bBBRr6t1PCyfuXHu%2Fuploads%2FLwCDeAe5bKIIi86QpXVL%2Fdebug_snooping_82_option.png?alt=media&#x26;token=3e98f502-5a7c-42dc-b534-b10d85c6e8c7" alt=""><figcaption><p>debug ip dhcp snooping packets command and ouput. Shows How 82 Option Drops DHCP packets</p></figcaption></figure>

#### Although output is limited essentially what is happening here is the DHCP packet is getting dropped before it even makes it to the DHCP server. Because at the next hop at SW3 that 82 option will make the switch believe it is a relay message, which it is not. It is a DHCP broadcast message. To fix we must a command to both our switches and a command for our router.

`SW2(config)#no ip dhcp snooping information option` # This command will stop the DHCP option 82 from being inserted onto the DHCP packet.

`R1(config)#ip dhcp relay information trust-all` # By default, if the gateway address is set to all zeros in the DHCP packet and the relay agent information option is already present in the packet, the DHCP relay agent will discard the packet. Use the ip dhcp relay information trust-all command to override this behavior and accept the packets.

#### with these two commands configured we will now be able to receive an IP address via DHCP.

#### Below we have our PC completing the DORA process, and then a packet capture of the link between SW3 and the DHCP server. And also our DHCP snooping verification command.

<figure><img src="https://2373667134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8zF1bBBRr6t1PCyfuXHu%2Fuploads%2FgGPiKskKaR8L27lbsLKr%2FPC_DHCP.png?alt=media&#x26;token=7161976e-79b8-40f7-a629-bbc745ea8547" alt=""><figcaption><p>PC Performing a DHCP Request (DORA)</p></figcaption></figure>

<figure><img src="https://2373667134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8zF1bBBRr6t1PCyfuXHu%2Fuploads%2FDZd18RRsmZ1yLx5ntsYJ%2Fdhcp_snooping_capture.png?alt=media&#x26;token=54aa7899-f450-4bf4-8622-6180087e0505" alt=""><figcaption><p>Wireshark Capture of DORA Process Working Now With the Two Commands We Configured on the Router and Switch</p></figcaption></figure>

<figure><img src="https://2373667134-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8zF1bBBRr6t1PCyfuXHu%2Fuploads%2FSlZUPt1AdWjnqmZaATo3%2Fshow_ip_dhcp_snooping_binding.png?alt=media&#x26;token=364ddbbd-3715-4a8e-93c8-c265af4d3523" alt=""><figcaption><p>show ip dhcp snooping command and output</p></figcaption></figure>

