Configuring Defense Against Man-in-the-Middle Attacks and IP/MAC Address Spoofing
This section describes how to configure the IP/MAC address binding and Option 82 functions to prevent man-in-the-middle attacks and IP/MAC address spoofing.
Applicable Environment
In man-in-the-middle attacks and IP/MAC address spoofing, attackers pretend to be servers and clients. The servers consider that all packets are sent from and destined for the clients, and so do the clients. Actually these packets are second-hand information from man-in-the-middle, and in this manner attackers can obtain the data on the servers and clients.
To prevent man-in-the-middle attacks and IP/MAC address spoofing, enable the Dynamic Host Configuration Protocol (DHCP) snooping function on a device so that the device forwards a packet only if the packet info matches an entry in the DHCP snooping binding table. If a packet does not match any entry in the DHCP snooping binding table, the device discards the packet.
- Enabling DHCP Snooping
To configure Dynamic Host Configuration Protocol (DHCP) snooping functions, enable DHCP snooping first. - Enabling DHCP Request Packet Check
To prevent man-in-the-middle attacks and IP/MAC address spoofing, enable Dynamic Host Configuration Protocol (DHCP) request packet check. After packet check is enabled on a device, the device checks the received Address Resolution Protocol (ARP) or IP packets to see whether the combination of source IP addresses and source MAC addresses in the packets match entries in the DHCP snooping binding table. - (Optional) Configuring the DHCP Snooping Binding Table
Dynamic entries in the DHCP snooping binding table are automatically generated when DHCP snooping is enabled. Static entries in the DHCP snooping binding table must be manually configured. - (Optional) Configuring Option 82 Field Insertion
After the Option 82 function is enabled on a device, the device can record the location information of the DHCP client or create binding entries with accurate interface information based on the Option 82 information. - (Optional) Configuring the Alarm Function for Discarded Man-in-the-Middle
Attack and IP/MAC Address Spoofing Packets
By configuring the function described in this chapter, you can have an alarm generated when a specified number of man-in-the-middle attack and IP/MAC address spoofing packets are discarded. - Verifying the Configuration of Defense Against Man-in-the-Middle
Attacks and IP/MAC Address Spoofing
This section describes how to check the configuration of defense against man-in-the-middle attacks and IP/MAC address spoofing.
Enabling DHCP Snooping
Enabling DHCP Request Packet Check
To prevent man-in-the-middle attacks and IP/MAC address spoofing, enable Dynamic Host Configuration Protocol (DHCP) request packet check. After packet check is enabled on a device, the device checks the received Address Resolution Protocol (ARP) or IP packets to see whether the combination of source IP addresses and source MAC addresses in the packets match entries in the DHCP snooping binding table.
(Optional) Configuring the DHCP Snooping Binding Table
Dynamic entries in the DHCP snooping binding table are automatically generated when DHCP snooping is enabled. Static entries in the DHCP snooping binding table must be manually configured.
Context
The static IP address and the IP address allocated to a user in static mode are the IP addresses that are manually configured on the client. Static users are those who use static IP addresses.
If the IP addresses allocated to users are static IP addresses, static binding entries can be configured for these IP addresses, ensuring static IP address anti-embezzlement. If there are a large number of static users, static binding entries must be configured for each static IP address; otherwise, unauthorized users who attempt to embezzle static IP addresses cannot be isolated.
Dynamic entries in the DHCP snooping binding table do not need to be configured. They are automatically generated when DHCP snooping is enabled. However, static entries in the DHCP snooping binding table must be configured by running commands.
- For the IP addresses dynamically allocated to users, devices automatically learn the MAC addresses of users and create a binding relationship table. The table does not need to be configured manually.
- For the IP addresses statically allocated to users, devices cannot create a binding relationship table. The table must be created manually.
If the binding relationship table for static users is not created manually, the following situations occur:
- If packets that do not match any entry in the binding relationship table are configured to be forwarded, the packets of all static users are forwarded. All static users can access the DHCP server normally. This is the default condition of the devices.
- If packets that do not match any entry in the binding relationship table are configured to be discarded, the packets of all static users are discarded. All static users cannot access the DHCP server.
If the created binding table must contain interface information, the Option82 function must be enabled. If the Option82 function is not enabled and DHCP snooping is enabled on the VLANIF interface, entries in the created DHCP snooping binding table do not contain interface information. For details, see the description of how to configure the Option82 function.
When an interface receives an Address Resolution Protocol (ARP) or IP packet, the interface matches the source IP address and source MAC address of the ARP or IP packet with entries in the DHCP snooping binding table. The interface checks the MAC address, IP address, interface, and virtual local area network (VLAN) information. Based on this check, the interface performs the following actions:
- The ARP or IP packet is discarded if its source IP address and source MAC address do not match any entry in the DHCP snooping binding table.
- The ARP or IP packet is forwarded if its source IP address and source MAC address match an entry in the DHCP snooping binding table.
When an interface receives an ARP or IP packet, the interface matches the source IP address and source MAC address of the ARP or IP packet with entries in the DHCP snooping binding table. The ARP or IP packet is forwarded if its source IP address and source MAC address match an entry in the DHCP snooping binding table, or is discarded if its source IP address and source MAC address do not match any entry in the DHCP snooping binding table.
(Optional) Configuring Option 82 Field Insertion
After the Option 82 function is enabled on a device, the device can record the location information of the DHCP client or create binding entries with accurate interface information based on the Option 82 information.
Context
The Option 82 field contains the location information of Dynamic Host Configuration Protocol (DHCP) hosts, such as information about the login interface, virtual local area network (VLAN), and address. After the Option 82 field insertion function is configured, the device can set up dynamic binding entries with accurate interface information. Based on the Option 82 field, the DHCP server assigns IP addresses and policies for DHCP clients.
Procedure
- Configure Option 82 field insertion in a VLAN view.
- Configure
Option 82 field insertion in the BD view.
- Configure Option 82 field insertion for an interface.
Follow-up Procedure
After Option 82 field insertion is enabled, you can configure the formats of the Option 82 field and sub-option 9 in the Option 82 field as required. You can configure the format of the Option 82 field in a VLAN view or an interface view.
- Configure the
format of the Option 82 field in a VLAN view.
- Run system-view
The system view is displayed.
- Run vlan vlan-id
The VLAN view is displayed.
- Run dhcp option82 format { type1 | type2 | self-define self-define | cn-telecom } interface interface-type interface-number
The format of the Option 82 field is configured for the VLAN.
- Run commit
The configuration is committed.
- Run system-view
- Configure the format of the Option 82 field for an interface.
- Run system-view
The system view is displayed.
- Run interface interface-type interface-number
The interface view is displayed.
Run
dhcp option82 format { self-define extendtex | type1 | type2 | cn-telecom }Or dhcp option82 { circuit-id | remote-id } format self-define extendtex
The format of the Option 82 field is configured for the interface.
- Run commit
The configuration is committed.
- Run system-view
(Optional) Configuring the Alarm Function for Discarded Man-in-the-Middle Attack and IP/MAC Address Spoofing Packets
By configuring the function described in this chapter, you can have an alarm generated when a specified number of man-in-the-middle attack and IP/MAC address spoofing packets are discarded.
Context
After packet check is enabled, if a received Address Resolution Protocol (ARP) or IP packet of a man-in-the-middle attack or IP/MAC address spoofing does not match any entry in the Dynamic Host Configuration Protocol (DHCP) snooping binding table, the device discards the ARP or IP packet. With the function described in this section configured, when the number of discarded packets reaches a specified threshold, an alarm is generated.
Configure the alarm function for discarded man-in-the-middle attack and IP/MAC address spoofing packets in a VLAN, BD, or interface view.
Procedure
- Configure the alarm function for discarded man-in-the-middle
attack and IP/MAC address spoofing packets in a VLAN view.
- Configure the alarm function for discarded
man-in-the-middle attack and IP/MAC address spoofing packets in a
BD view.
- Configure the alarm function for discarded man-in-the-middle
attack and IP/MAC address spoofing packets in an interface view.
Verifying the Configuration of Defense Against Man-in-the-Middle Attacks and IP/MAC Address Spoofing
This section describes how to check the configuration of defense against man-in-the-middle attacks and IP/MAC address spoofing.
Prerequisites
Procedure
- Run the display dhcp snooping global command to check the global DHCP snooping information.
- Run the display dhcp snooping bind-table { all | dynamic | interface interface-type interface-number | ip-address ip-address | mac-address mac-address | static | vlan vlan-id [interface interface-type interface-number ] | vsi vsi-name | bridge-domain bd-id } command to check the information about the Dynamic Host Configuration Protocol (DHCP) snooping binding table.
- Run the display dhcp snooping { interface interface-type interface-number | vlan vlan-id [ interface interface-type interface-number ] | bridge-domain bd-id } command to check the DHCP snooping configuration.
- Run the display dhcp option82 configuration [ interface interface-type interface-number | vlan vlan-id | bridge-domain bd-id ] command to check the Option 82 configuration.
Example
<HUAWEI> display dhcp snooping global
dhcp snooping enable
<HUAWEI> display dhcp snooping global
bind-table:
ifname vrf/vsi/bdid p/cvlan mac-address ip-address tp lease
-------------------------------------------------------------------------------
-- -- 0010/0000 - 010.010.010.001 S 0
-- -- 0010/0000 - 010.010.010.002 S 0
-------------------------------------------------------------------------------
binditem count: 2 binditem total count: 2
<HUAWEI> display dhcp snooping vlan 10
dhcp snooping enable
dhcp snooping check arp enable
dhcp snooping alarm arp enable
dhcp snooping alarm arp threshold 100
dhcp snooping check ip enable
dhcp snooping alarm ip enable
dhcp snooping alarm ip threshold 205
dhcp check chaddr enable
dhcp snooping alarm dhcp-chaddr enable
dhcp snooping alarm dhcp-chaddr threshold 200
dhcp snooping alarm dhcp-request enable
dhcp snooping alarm dhcp-request threshold 300
dhcp snooping max-user-number 100
arp total 0
ip total 0
dhcp-request total 0
chaddr&src mac total 0
dhcp-reply total 0
Run the display dhcp option82 configuration interface Gigabitethernet 0/1/0 command to check the Option 82 configuration of the GE0/1/0 interface.
<HUAWEI> display dhcp option82 configuration interface Gigabitethernet 0/1/0 # interface Gigabitethernet0/1/0 dhcp option82 insert enable #