Jeremy's IT Lab
Day 50Security

DHCP Snooping

28m7 chapters118 cues13 cards1 lab
Day 50YT: qYYeg2kz1yE
00:00 / 28:23

Synchronized Transcript

118 cues indexed • Click dialogue or words to jump
Jeremy

Welcome to Jeremy’s IT Lab. This is a free, complete course for the CCNA. If you like these videos, please subscribe to follow along with the series.

Jeremy

Also, please like and leave a comment, and share the video to help spread this free series of videos. Thanks for your help. In this video we will talk about DHCP snooping.

Jeremy

DHCP snooping is a security feature available on Cisco switches which helps to protect against attacks which take advantage of DHCP. DHCP snooping is covered in exam topic 5.7, which says that you must be able to configure layer 2 security features including DHCP

Jeremy

snooping, dynamic ARP inspection, and port security. We already covered port security, and dynamic ARP inspection will be the next video. But for this video, let’s focus on DHCP snooping.

Jeremy

Here’s what we’ll cover in this video. Basically, it will be similar in structure to the previous video on port security. I’ll introduce what DHCP snooping is, how it works, what attacks it prevents, and how to configure it on Cisco switches.

Jeremy

And make sure to watch until the end of the video for a bonus practice question from Boson Software’s ExSim for CCNA, my recommended practice exams for the CCNA.

Jeremy

Okay, let’s take a look at the basics of DHCP snooping. DHCP snooping is a security feature of switches that is used to filter DHCP messages received on untrusted ports.

Jeremy

I’ll tell you more about untrusted ports in a minute. Note that DHCP snooping only filters DHCP messages. Any other non-DHCP messages aren’t affected.

Jeremy

All ports are untrusted by default. It’s then up to you to configure which ports will be trusted. Usually, uplink ports are configured as trusted ports, and downlink ports remain untrusted.

Jeremy

I’ll use this diagram to explain. So, R1 is either a DHCP server or a DHCP relay agent. The end hosts, the PCs, will use DHCP to receive an IP address from R1.

Jeremy

The downlink ports on the switches, the interfaces pointing towards the end hosts, should be untrusted. The network admin doesn’t have direct control over the end user devices.

Jeremy

A malicious user could initiate a DHCP-based attack from one of their devices, so it’s best to leave these ports in the default untrusted state.

Jeremy

So, which interfaces are downlink ports? These ones, because they point toward the end hosts. However the uplink ports point toward the network infrastructure, the devices the network admin has control over.

Jeremy

We can be pretty sure, for example, that R1 isn’t going to initiate some kind of DHCP-based attack. So, we can configure these interfaces as trusted ports.

Jeremy

DHCP snooping won’t inspect any messages on trusted ports, the switch will simply forward them as normal. So, which ports are uplink ports?

Jeremy

These ones, because they point away from the end hosts, toward the network infrastructure. DHCP snooping won’t inspect DHCP messages on these ports.

Jeremy

Now let’s look at an example of DHCP snooping. PC1 sends a DHCP message, for example a DISCOVER message.

Jeremy

SW1 receives the message on an untrusted port, so it inspects the message to see if it’s okay. It determines that the message is fine, so it forwards it as normal.

Jeremy

Then SW2 receives it, again on an untrusted interface. It checks the message and determines that it’s okay, so it forwards it to R1. R1 then sends the reply, and it goes straight back to PC1 without being inspected by SW2 or SW1.

Jeremy

Why don’t the switches inspect the message from R1? It’s because they received it on their trusted ports, so they assume the message is okay. No need to check it.

Jeremy

Now here’s another example. This time PC2 sends a DHCP message. SW1 receives it on an untrusted port, so it inspects the message.

Jeremy

However, this time it determines that the message is not OK, so it discards the message. Later in this video I’ll go over exactly how DHCP snooping determines if a message is OK or not, so I won’t get into the details now.

Jeremy

But perhaps the user of PC2 was trying to use a DHCP exploit, so SW1 decided to drop the message. Okay, next let’s look at a couple examples of DHCP-based attacks that DHCP snooping can protect against.

Jeremy

First up, let’s quickly review a type of attack you already know, the DHCP starvation, also called DHCP exhaustion, attack. In this attack, an attacker uses spoofed MAC addresses to flood DHCP Discover messages.

Jeremy

And what’s the purpose of that? The target server’s DHCP pool becomes full, resulting in a denial-of-service to other devices. They won’t be able to get an IP address from the server.

Jeremy

You already know this by now, but here’s a review. The attacker sends DHCP discover messages with false source MAC addresses. Now, something I didn’t mention before is that DHCP actually uses a field in the DHCP message, written as CHADDR, which stands for Client

Jeremy

Hardware Address, to indicate the MAC address of the client. Why is this field needed, when the server could just look at the source MAC address of the frame?

Jeremy

Well, in a network like this where the DHCP server is in the local network, that would work fine. But if the DHCP server is in a remote network and the DHCP messages are forwarded by a DHCP relay agent, when the server receives the frames from the client, the source MAC address of the

Jeremy

frame will not be the client’s MAC address. So, that’s why the client hardware address field is used to identify the client. Anyway, that’s just an aside.

Jeremy

The attacker sends countless fake DHCP Discover messages like this. Then, when the other devices in the network try to get IP addresses via DHCP, the server is not able to assign them addresses, resulting in a denial of service to those clients.

Jeremy

And here’s one more example of a DHCP-based attack. Similar to ARP poisoning, DHCP poisoning can be used to perform a man-in-the-middle attack.

Jeremy

A spurious DHCP server, that just mean an illegitimate DHCP server, replies to clients’ DHCP Discover messages and assigns them IP addresses.

Jeremy

But it makes the clients use the spurious DHCP server’s IP address as the default gateway. So, in the network below the attacker is running DHCP server software, it is the spurious DHCP server.

Jeremy

R1 is the legitimate DHCP server, and also the default gateway. Both of these DHCP servers will respond to clients’ Discover messages, but clients usually accept the first Offer message they receive.

Jeremy

Now, in a situation like this it’s hard to know which Offer message will reach the clients first, the attacker’s Offer or R1’s Offer. But, if the legitimate DHCP server is actually in a remote network and R1 is just acting as a DHCP relay agent, then it’s almost guaranteed that the attacker’s

Jeremy

Offer will reach the clients first, because it’s in the local network. No need to forward traffic to a remote network. So, if the clients use the attacker as their default gateway, when sending traffic to external networks they will send traffic to the attacker instead of the legitimate default gateway.

Jeremy

The attacker can then examine and/or modify the traffic before forwarding it to the legitimate default gateway. Let’s walk through that process. PC1 sends a DHCP Discover message and it is broadcast to all devices on the local network, including the attacker.

Jeremy

So, both the attacker and R1 send Offer messages for PC1. However, in this case the attacker’s Offer reaches PC1 first.

Jeremy

Because it arrives first, PC1 will choose to accept it, and not R1’s Offer. So, PC1 will send a DECLINE message to R1. I haven’t introduced this message type yet, but I think you can guess its purpose.

Jeremy

However, with the attacker it completes the DHCP D-O-R-A process, and now PC1 has an IP address, 172.16.1.10, and its default gateway is the attacker, 172.16.1.2.

Jeremy

So, if PC1 wants to send traffic to an external network, for example the Internet, it will send the traffic to the attacker. The attacker can then examine the traffic or even modify it, before finally forwarding it to the legitimate default gateway, which will send it to the external destination.

Jeremy

Because the traffic does reach its destination, PC1 probably won’t even notice that its traffic is being intercepted by the attacker. So those were two examples of DHCP-based attacks which DHCP snooping can protect against, DHCP starvation and DHCP poisoning.

Jeremy

Now let’s continue looking at DHCP snooping itself. Let’s review the DHCP message types you already know, and learn about a few more.

Jeremy

When DHCP snooping filters messages, it differentiates between DHCP server messages and DHCP client messages. DHCP server messages received on an untrusted port will always be discarded with no further checks.

Jeremy

DHCP client messages will be inspected, and then the switch will decide to forward or discard the frame. So, here are messages sent by DHCP servers.

Jeremy

OFFER and ACK you already know, they are used in the standard DHCP D-O-R-A exchange. NAK is a new one, it’s the opposite of ACK and is used to decline a DHCP client’s REQUEST message.

Jeremy

And here are messages sent by DHCP clients. You already know DISCOVER and REQUEST, again they are used in the D-O-R-A exchange.

Jeremy

RELEASE you already know too, I introduced it in the DHCP video. But for review, it’s used to tell the server that the client no longer needs its IP address.

Jeremy

And then there’s DECLINE, which I just showed earlier. It’s used to decline the IP address offered by a DHCP server. Make sure you learn which messages are sent by DHCP servers and which are sent by DHCP clients.

Jeremy

It’s an important part of understanding DHCP snooping. Next, I’ll give you an outline of DHCP snooping operations. By that I mean, how it works to filter DHCP messages.

Jeremy

First of all, if a DHCP message is received on a trusted port, forward it as normal without inspection. Messages received on trusted ports won’t be dropped.

Jeremy

But, if a DHCP message is received on an untrusted port, inspect it and act as follows. First, if it’s a DHCP server message, discard it.

Jeremy

DHCP servers should not be connected to untrusted ports, their ports should be trusted. So, any OFFER, ACK, or NAK messages that are received on an untrusted port will simply be discarded.

Jeremy

However, if the message is a DHCP client message, DISCOVER REQUEST RELEASE or DECLINE, perform the following checks. So, these checks depend on what kind of message it is.

Jeremy

First, for DISCOVER and REQUEST messages, the messages in the D-O-R-A exchange, check if the frame’s source MAC address and the DHCP message’s client hardware address fields match.

Jeremy

If they match, forward the frame. If they don’t discard it. This can protect against attacks when an attacker spoofs the client hardware address field of the DHCP message.

Jeremy

However it’s not perfect, because the attacker could just spoof the frame’s source MAC address too. Then, for RELEASE and DECLINE messages, check if the packet’s source IP address and the interface receiving the message match the entry in the DHCP snooping binding table.

Jeremy

If they match, forward the message. If they don’t, discard it. I haven’t mentioned the DHCP snooping binding table yet. When DHCP snooping is enabled, the switch will create a new entry in the DHCP snooping binding table when a client successfully leases an IP address

Jeremy

from a DHCP server. Let’s take a look at that in the next slide. So let’s go over some basic DHCP snooping configurations. First, on SW2 I used IP DHCP SNOOPING.

Jeremy

This enables DHCP snooping on the switch, but it’s not enough. I then used IP DHCP SNOOPING VLAN 1 to tell SW2 to enable it on VLAN 1.

Jeremy

So, you need to enable DHCP snooping globally, with IP DHCP SNOOPING, and then enable it on each VLAN necessary, with IP DHCP SNOOPING VLAN.

Jeremy

So, I enabled it for VLAN 1 because that’s the only VLAN in this network. Then I used NO IP DHCP SNOOPING INFORMATION OPTION.

Jeremy

I’m going to explain this later, so we’ll skip it for now. It’s not always necessary, but depending on the network design you might need it. Finally, I configure the G0/0 interface as a trusted port.

Jeremy

As I said before, by default all ports will be untrusted, so you will have to manually specify which ports to trust. G0/0 is connected to R1, which is the DHCP server in this network, so I trusted it.

Jeremy

Okay, that’s all for SW2. Then I did the exact same configurations on SW1. I configured SW1’s G0/0 as trusted, because it’s the interface pointing toward the DHCP server, R1.

Jeremy

Then I checked the DHCP snooping binding table with the command SHOW IP DHCP SNOOPING BINDING. As you can see, PC1, PC2, and PC3 were able to get IP addresses via DHCP.

Jeremy

This table logs their MAC addresses, IP addresses, lease times, VLAN numbers, and interface IDs. As I mentioned in the previous slide, RELEASE and DECLINE messages will be checked to make sure their IP address and interface ID match the entry in the DHCP snooping

Jeremy

table. This prevents attackers from sending these messages on behalf of other devices in the network, causing the DHCP server to believe that they don’t need their IP addresses anymore.

Jeremy

Okay, next up another function of DHCP snooping, that is rate-limiting. DHCP snooping can limit the rate at which DHCP messages are allowed to enter an interface.

Jeremy

If the rate of DHCP messages crosses the configured limit, the interface is err-disabled. Then, similar to port security, the interface can be manually re-enabled with SHUTDOWN and then NO SHUTDOWN, or automatically re-enabled with errdisable recovery.

Jeremy

Here’s how to configure DHCP rate limiting. I configured it on SW1’s G0/1, 2, and 3 with IP DHCP SNOOPING LIMIT RATE 1.

Jeremy

This limits DHCP messages to 1 per second. If the interface receives more than 1 DHCP message per second, it will be disabled.

Jeremy

Now, this is too low for a real network. If you set the limit to 1 DHCP message per second, your switch interfaces will definitely get disabled even by legitimate DHCP exchanges.

Jeremy

But, I set it to 1 so I could easily make SW1’s G0/1 become disabled. And that’s what happened. These log messages show that G0/1 received more DHCP messages than it’s allowed to, so it was err-disabled.

Jeremy

So, we could manually re-enable it, but let’s look at errdisable recovery again. Here’s how to enable errdisable recovery for DHCP rate limiting.

Jeremy

ERRDISABLE RECOVERY CAUSE DHCP-RATE-LIMIT. I then checked SHOW ERRDISABLE RECOVERY, and notice that recovery has been enabled for the DHCP-RATE-LIMIT cause.

Jeremy

Also notice at the bottom that G0/1 is waiting for the timer to count down so it can be re-enabled. So, what’s the purpose of rate-limiting DHCP messages?

Jeremy

Well, it can be very useful to protect against DHCP exhaustion attacks. Remember, attackers can spoof both the frame’s source MAC address and the DHCP message’s client hardware address field to bypass the DHCP snooping filtering of DISCOVER and REQUEST messages.

Jeremy

But, with rate limiting we can prevent them from exhausting the DHCP server with tons of illegitimate DHCP DISCOVER messages. If the attacker tries to flood the server with DISCOVER messages, the interface will just be disabled.

Jeremy

So, this is a very useful function of DHCP Snooping. Okay, let’s go over that command that I said I would explain earlier, NO IP DHCP SNOOPING INFORMATION OPTION.

Jeremy

First, what is the information option? Option 82, also known as the DHCP relay agent information option, is one of many DHCP options.

Jeremy

In the DHCP video of this course I mentioned that there are various DHCP options that provide different functionalities. Option 82 is one of them.

Jeremy

Option 82 provides additional information about which DHCP relay agent received the client’s message, on which interface, in which VLAN, etc.

Jeremy

DHCP relay agents can add Option 82 to messages they forward to the remote DHCP server. With DHCP snooping enabled, by default Cisco switches will add Option 82 to DHCP messages they receive from clients, even if the switch isn’t

Jeremy

acting as a DHCP relay agent. This can cause problems. Here’s one of them. By default, Cisco switches will drop DHCP messages with Option 82 that are received on an untrusted port.

Jeremy

Let me demonstrate. PC1 sends a DISCOVER message, and SW1 forwards it to SW2, adding Option 82.

Jeremy

Because SW2 receives it on an untrusted port, it drops the message. You can see the syslog message here, indicating that it dropped the message because it had option 82.

Jeremy

So, the default settings work well if the switch is a layer 3 switch acting as a DHCP relay agent, but in a network like this one it won’t work.

Jeremy

So, that’s why I used this command I showed earlier, NO IP DHCP SNOOPING INFORMATION OPTION. Let’s see what happens now.

Jeremy

PC1 sends a DISCOVER message, and SW1 forwards it to SW2. This time it doesn’t add Option 82. But let’s assume that I haven’t used the NO IP DHCP SNOOPING INFORMATION OPTION command on SW2 yet.

Jeremy

So SW2 will add Option 82 and forward it to R1. This will cause R1 to drop it. You can see R1’s log messages below.

Jeremy

Basically, it means that R1 dropped the message because it had option 82, but it wasn’t sent by a relay agent. That’s what ‘inconsistent relay information’ in the log message means.

Jeremy

If a DHCP message wasn’t sent by a relay agent, it shouldn’t have option 82. So, I added the command to SW2 also.

Jeremy

This time, neither SW1 or SW2 will add option 82 to the DISCOVER message. So, R1 trusts the message and responds as normal.

Jeremy

I’m not sure if you’ll get any questions about option 82 on the CCNA exam, but it’s good to know about because it can cause problems for you in your DHCP snooping labs if you don’t know about it.

Jeremy

Okay, here’s a review of the new commands we covered in this video. If you don’t remember any of these commands, go back in the video to review them.

Jeremy

Before moving on to the quiz, let’s review what we covered in this video. I first introduced what DHCP snooping is. It’s a security feature of switches that allows them to filter DHCP messages.

Jeremy

It works by inspecting DHCP messages that arrive on untrusted ports and then deciding to discard or forward them. It can also control the rate at which DHCP messages are allowed to enter an interface.

Jeremy

It can prevent attacks like DHCP exhaustion and DHCP poisoning. We also looked at how to configure DHCP snooping on Cisco switches.

Jeremy

Remember to enable it globally, enable it per VLAN, and then configure the appropriate interfaces as trusted. Also keep option 82 in mind, you may need to use NO IP DHCP SNOOPING INFORMATION OPTION to disable it.

Jeremy

As always, watch until the end of the quiz for a bonus practice question from Boson Software’s ExSim, my recommended practice exams for the CCNA. Okay, let’s go to question 1 of the quiz.

Jeremy

Which of the following DHCP message types will always be discarded if received on a DHCP snooping untrusted interface? (select three) Okay, pause the video now to select the correct answers.

Jeremy

The answers are C, NAK. D, OFFER. And G, ACK. These DHCP message types will always be discarded if received on a DHCP snooping untrusted interface because they are sent from DHCP servers.

Jeremy

DHCP servers should not be connected to untrusted interfaces. Okay, let’s go to question 2.

Jeremy

Which of the following is NOT stored in the DHCP snooping binding database? Pause the video now to select the correct answer. Okay, the answer is D, default gateway.

Jeremy

Here you can see what the DHCP snooping binding database looks like on a switch. The default gateway is not displayed. Okay, let’s go to question 3.

Jeremy

Which of the following are functions of DHCP snooping? (select two) Pause the video now to select the best answers.

Jeremy

Okay, the answers are A, limiting the rate of DHCP messages, and C, filtering messages on untrusted ports.

Jeremy

DHCP snooping won’t filter messages on trusted ports, and it also won’t filter ALL DHCP messages. It will only filter those that are received on untrusted ports.

Jeremy

Okay, let’s go to question 4. When DHCP snooping inspects a DHCP DISCOVER message that arrives on an untrusted interface, what does it check?

Jeremy

(select the two best answers) Pause the video now to select the best answers. Okay, the answers are A, source MAC address, and B, client hardware address.

Jeremy

Source MAC address refers to the source MAC field of the Ethernet frame, and client hardware address is a field in the DHCP message itself.

Jeremy

If the two match, DHCP snooping permits the message. If they don’t match, the message will be discarded. Okay, let’s go to question 5.

Jeremy

DHCP snooping rate-limiting is configured on SW1’s G0/1 interface. What happens if DHCP messages are received on G0/1 at a rate faster than the configured limit?

Jeremy

Pause the video now to select the best answer. The answer is B, the interface will be disabled.

Jeremy

To re-enable it, you can either SHUTDOWN and then NO SHUTDOWN the interface, or you can configure errdisable recovery for the dhcp-rate-limit cause. Okay, that’s all for the quiz.

Jeremy

Now let’s take a look at a bonus question from Boson Software’s ExSim for

Jeremy

CCNA.

Keyboard shortcuts

Shortcuts are ignored while you are typing in a search box, note field, or the scratchpad.

Playback

SpaceK
Play or pause
←→
Seek 5 seconds
JL
Seek 10 seconds
C
Toggle in-video captions

Scrubber (when focused)

←→
Seek 5 seconds
Shift←/→
Seek 10 seconds
Page UpPage Down
Seek 30 seconds
HomeEnd
Jump to start or end

Flashcards

Space
Reveal the answer
1234
Grade Again / Hard / Good / Easy

Navigation

←→
Move between study-mode tabs
HomeEnd
First or last study-mode tab
?
Open or close this sheet