This section describes how to bind an IP address to a MAC address using the CLI.
After this function is enabled, the device compares the packets that match the binding between the IP address and MAC address and filters out those that do not match the binding.
Configure IP-MAC binding.
firewall mac-binding ip-address mac-address [ vpn-instance vpn-instance-name ] [ vid vlan-id ] [ description description-text ]
When inserting an MAC-IP address binding entry, comply with the following principles:
If vid is in use during the configuration, you can associate the binding with the VLAN. Then the binding is available only for the VLAN. Identical IP address may be on different VLANs. To search for the correct entry, you should set the vid parameter to associate it with the corresponding VLAN in the following conditions:
For the interfaces that do not belong to the VLAN, you do not need to set the vid parameter for them.
Run the interface interface-type interface-number command to access the interface view.
The interfaces that can be configured with this function should be Layer-3 interfaces specified with IP addresses, including Ethernet interface and its subinterface, Eth-Trunk interface and its subinterface, and VLANIF interface.Run the ip-address ip-address { mask | mask-length } [ sub ] command to specify the interface IP address.
Run the arp scan [ start-ip-address to end-ip-address ] command to enable ARP automatic scanning on an interface so that the interface can send ARP Request packets to all interfaces whose IP addresses are in the same network segment with the IP address of the interface.
Run the gratuitous-arp send enable [ interval time-interval ] command to send gratuitous ARP packets through an interface to update the ARP table on the gateway.
Make sure that correct gateway MAC addresses are in ARP entries on the client.
Run the quit command to return to system view.
Run the firewall mac-binding interface interface-type interface-number command to bind all dynamic ARP packets to the specified interface.
In this example, to bind IP address 10.1.1.1 with MAC address 0001-0002-0003, run the following commands:
<sysname> system-view [sysname] firewall mac-binding enable [sysname] firewall mac-binding 10.1.1.1 0001-0002-0003
Enable ARP automatic probe on interface GigabitEthernet 0/0/1 and bind all ARP entries on the interface.
<sysname> system-view [sysname] firewall mac-binding enable [sysname] interface GigabitEthernet 0/0/1 [sysname-GigabitEthernet0/0/1] ip-address 10.1.1.2 24 [sysname-GigabitEthernet0/0/1] gratuitous-arp send enable interval 10 [sysname-GigabitEthernet0/0/1] quit [sysname] firewall mac-binding interface GigabitEthernet 0/0/1
To query whether the device checks whether the binding between the IP address and the MAC address on the device is correct, run the display firewall mac-binding enable command.
<sysname> display firewall mac-binding enable Mac-binding is enabled
In this example, the previous information shows that the IP address and MAC address binding function is already enabled. If Mac-binding is disabled is displayed, it indicates that the function is disabled in the current system.
To check the existing binding in the current system, run the display firewall mac-binding item command.
<sysname> display firewall mac-binding item Firewall Mac-binding items : Current items : 2 IP ADDRESS MAC ADDRESS VLAN-ID VPN-INSTANCE DESCRIPTION 192.168.1.1 00e0-fcff-0200 public 192.168.1.2 00e0-fcff-0100 public
In this example, the previous information shows that two binding entries exist on the device.
You can use the display firewall mac-binding item command and the ip-address parameter together to check the entries only related to the IP address. For example, if running the display firewall mac-binding item 192.168.1.2 command, you can only view the second entry. In this way, you can perform the rapid query in the case that there are a large number of entries.