This section describes how to prevent an attacker connected to a Layer-3 interface from launching man-in-the-middle or IP/MAC spoofing attacks.
Before preventing the man-in-the-middle and IP/MAC spoofing attacks on a Layer-3 Interfaces, complete the following tasks:
Configure a DHCP server.
Configure a DHCP relay agent.
If an IP address is dynamically assigned to a client, a device automatically learns the MAC address of the client and generates an IP and MAC binding entry. This binding table requires no configuration.
If an IP address is statically assigned to a client, a device cannot automatically learn the MAC address of the client or generate an IP and MAC binding entry. You need to create IP and MAC binding table manually.
If the device is configured to forward packets without matching entries, packets from all static IP addresses are forwarded, and all static clients can access the DHCP server properly. By default, the device forwards mismatching packets.
If the device is configured to discard packets without matching entries, packets from all static IP addresses are discarded, and no static clients can access the DHCP server.
If they do not match, the packet is discarded.
If they totally match, the packet is forwarded.
system-view
dhcp snooping enable
Enable DHCP snooping globally before enabling DHCP snooping on a Layer-3 interface.
interface interface-type interface-number
DHCP snooping can be enabled on the following Layer-3 interfaces:
Ethernet interfaces
Ethernet sub-interfaces
VlanIf interfaces
Eth-Trunk interfaces
dhcp snooping enable
dhcp snooping check { arp | ip | dhcp-chaddr | dhcp-request } enable
dhcp snooping bind-table static ip-address ip-address mac-address mac-address
dhcp option82 insert enable interface interface-type interface-numberIf the original message does not carry Option 82, Option 82 is appended to DHCP messages. If the message carries Option 82, Sub-option 9 is added to DHCP messages.
dhcp option82 rebuild enable interface interface-type interface-number
Option 82 is appended to DHCP messages if the original DHCP message is not appended with Option 82. If the original DHCP message is appended with Option 82, the original Option 82 is forcibly removed, and new Option 82 is appended.
A binding table with accurate interface information can be created after Option 82 is enabled.
If there is no matching entry for a packet in the DHCP snooping binding table, the device processes the packet using a user-defined method.
DHCP snooping is enabled in both the system and interface views.
Option 82 is enabled on the interface.
Statistics about the discarded ARP, IP, and DHCP packets are displayed.
Interface names and the matching MAC and IP addresses in the DHCP snooping binding table are displayed.
<sysname> display dhcp snooping interface GigabitEthernet 0/0/1
dhcp snooping enable
dhcp snooping trusted
dhcp snooping check arp enable
arp total 0
ip total 0
dhcp-request total 0
chaddr&src mac total 0
dhcp-reply total 0