ARP Address Resolution Protocol

What is ARP?

ARP【Address Resolution Protocol】, the Address Resolution Protocol, is responsible for resolving the IP address of the destination host into the destination MAC address. After the sender knows the IP address of the destination host, he can use this IP address to resolve the MAC address of the other party.

Why do you need ARP?

When the sender sends data to other network devices, it is sent in the form of data frames, and the data frames are parsed by the network card into electrical or optical signals and transmitted to the peer.

A data frame is composed of a source MAC address and a destination MAC address. If the sender only knows the IP address of the destination host but does not know the MAC address of the destination host, it cannot convert the data packet into a data frame and send it away. The ARP protocol is Responsible for address resolution, use the IP address of the destination host to resolve the MAC address of the other party.

If the sender and receiver are on the same network, arp resolves the receiver’s MAC address.

If the sender and receiver are not in the same network, what arp resolves is the interface MAC address of the gateway in this network.

arp workflow

There will be an ARP cache table in the network device. This cache table records the mapping relationship between the IP address and the MAC address. You can use arp -a on the device terminal to view the cache information of the local arp cache table.

The role of the arp protocol is to form this arp cache table

So, how does the switch form this cache table?

When the device needs to resolve an IP address, it will send a broadcast frame of an arp request message. The destination MAC address in the layer 2 message is all F. After receiving the ARP request message, the destination device will send a unicast frame to the source device. frame, the unicast frame is an ARP response packet, and the response packet contains the MAC address of the destination device.

Let’s analyze it:

The ARP request and response process in the same network is as follows:

PC 1 only knows that the IP address of PC3 is 10.1.1.3, but does not know the MAC address of PC3, and now wants to obtain the MAC address of PC3:

1. Sender PC1: PC 1 will send a broadcast frame. The source IP and source MAC are PC1, the destination IP is PC3, and the destination MAC is FF-FF-FF-FF-FF-FF. This frame is sent by broadcast. All hosts in the network will receive it. The payload of this message is an ARP request message, which means that my MAC address is MAC1, and I want to send data to 10.1.1.3. Who is 10.1.1.3, please reply me.

2. Non-destination host PC2: Since all hosts in the network can receive this broadcast frame, PC2 receives this frame, extracts the IP address, and finds that the IP address it is looking for is 10.1.1.3, and my IP address is 10.1.1.2 , This data packet is not sent to me, it is discarded and no reply is made.

3. Destination host PC3: After PC 3 receives the broadcast data frame, it disassembles the data frame, extracts the IP address, and finds that it is the same as my local IP address. This data packet is sent to me, and then disassembles to extract the report After the article, I learned that the other party wanted to request my own MAC address, and then packaged an ARP response message. The source IP and source MAC are both my own, and the destination IP and destination MAC are the other party’s, and the unicast is sent to the receiver. , so that PC1 has the MAC address of PC3.

03

Proxy ARP

If the two hosts are not in the same network and are isolated by Layer 3 devices, how can they communicate?

The destination IP address and the local IP address are located in different networks. Since host A does not have a gateway configured, it will send an ARP Request message in broadcast form to request the MAC address of host B. However, the broadcast message cannot be forwarded by the router, so host B cannot receive the ARP request message from host A, and of course it cannot respond.

This problem can be solved by enabling the proxy ARP function on the router.

After proxy ARP is enabled, host A resolves the gateway MAC address process:

1. Host A sends arp request gateway MAC: The gateway address must be configured on the computer host first, and host A sends data to host B, and it is found that it is a data communication of a different network segment, and I do not have this ARP mapping relationship about B locally. An arp request message will be sent to resolve the gateway MAC address. The source IP and source MAC address are both host A, the destination IP is the gateway IP address, and the destination MAC address is all 0.

2. The gateway replies with its own MAC address: After receiving the arp request message, the gateway checks whether the destination host is reachable, and if it is reachable, it will reply its own MAC address to host A with an arp reply message, and the destination host is unreachable Do not reply.

3: Host A sends data to host B: Host A will add the gateway MAC and IP address of the gateway into the arp table after receiving the arp response message. If A wants to send data to host B, it needs to analyze the MAC address of B first. Send an arp request message, the source IP and source MAC are the information of A, the destination IP address is the IP address of B, and the destination MAC is the gateway MAC.

4: Processing after the gateway receives the data packet: the gateway will search the routing table after receiving such a request. If there is a routing table entry for host B, the router will use the MAC address of its own G0/0/0 interface to respond to the ARP request. After host A receives the ARP reply, it forwards data using the router’s G0/0/0 interface MAC address as the destination MAC address.

Experiment:

Experiment 1: Configuring Static ARP

Check the result: display arp all

Command: [Huawei]arp static 10.1.1.4 AA-BB-CC

Experiment 2: Configure proxy arp on switch S5700

Experimental environment: Create VLAN10 and VLAN20 on the S5700 switch, put these two PCs into different VLANs, and then use vlanif to configure IP and proxy arp functions

The topology is as follows:

Next configure:

[SW1]display current-configuration
#
sysname SW1
#
vlan batch 10 20 create VLAN
interface Vlanif10 Enter the gateway interface of this VLAN
ip address 10.1.1.254 255.255.255.0
#
interfaceVlanif20
ip address 10.1.2.254 255.255.255.0
arp-proxy enable
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 10
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 20

View the effect

1. Do not enable the arp proxy first, PC1 pings PC2, and finds that it is unreachable

2. Enter the two vlanif interfaces respectively, and enable the proxy arp function

3. Check the effect and find that PC 1 and PC2 can communicate.

4. Then enter vlnif 10, close the proxy arp function,

Use arp -d on PC1 and PC2 to clear the local cached ARP table and check connectivity.

It can be found that after the arp proxy is turned off, the host cannot resolve the MAC address table of the other party, and the communication cannot be completed, and the inspection effect can be verified multiple times.

The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge Network skill tree Protocols supporting applicationsThe role of the application layer 28,800 people are studying systematically