1 Star 0 Fork 4.9K

丛林 / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
kernel-small-debug-shell-net-arp.md 7.02 KB
一键复制 编辑 原始数据 按行查看 历史
Annie_wang 提交于 2022-05-19 22:02 . update docs

arp

Command Function

Hosts on an Ethernet communicate with each other using MAC addresses. IP addresses must be converted into MAC addresses to enable communication between hosts on a LAN (Ethernet). To achieve this purpose, the host stores a table containing the mapping between IP addresses and MAC addresses. This table is called an Address Resolution Protocol (ARP) cache table. Before sending an IP packet to a LAN, the host looks up the destination MAC address in the ARP cache table. The ARP cache table is maintained by the TCP/IP stack. You can run the arp command to view and modify the ARP cache table.

Syntax

arp

arp [-i IF] -s IPADDR HWADDR

arp [-i IF] -d IPADDR

Parameters

Table 1 Parameter description

Parameter

Description

Value Range

No parameter

Queries the content of the ARP cache table.

N/A

-i IF

Specifies the network port. This parameter is optional.

N/A

-s IPADDR

HWADDR

Adds an ARP entry. The second parameter is the IP address and MAC address of the other host on the LAN.

N/A

-d IPADDR

Deletes an ARP entry.

N/A

Usage

  • The arp command is used to query and modify the ARP cache table of the TCP/IP stack. If ARP entries for IP addresses on different subnets are added, the protocol stack returns a failure message.
  • This command can be used only after the TCP/IP stack is enabled.

Example

Run the arp command.

ARP cache table:

OHOS # arp
Address                 HWaddress               Iface       Type
192.168.1.10            E6:2B:99:2C:4B:20       eth0        static

Table 2 Output description

Parameter

Description

Address

IPv4 address of a network device.

HWaddress

MAC address of a network device.

Iface

Name of the port used by the ARP entry.

Type

Indicates whether the ARP entry is dynamic or static. A dynamic ARP entry is automatically created by the protocol stack, and a static ARP entry is added by the user.

1
https://gitee.com/jungle8023/docs.git
git@gitee.com:jungle8023/docs.git
jungle8023
docs
docs
master

搜索帮助