回到手册索引

命令用途

arping 是一个用于向邻居主机发送 ARP 请求的命令,通常用于检查网络中某个设备是否在线,或者检测网络上的 MAC 地址是否响应。

常用用法示例

  1. 发送一个 ARP 请求到目标主机

    1
    2
    3
    arping 192.168.1.1
    ARPING 192.168.1.1 from 192.168.1.100
    60 bytes from 192.168.1.1 (00:11:22:33:44:55): icmp_seq=1 ttl=64 time=1.234 ms

    该命令向 IP 地址 192.168.1.1 发送 ARP 请求,并接收到来自该地址的 ARP 响应。

  2. 指定网络接口发送 ARP 请求

    1
    arping -I eth0 192.168.1.1

    同上,只是 ARP 请求通过 eth0 接口发送。

  3. 发送指定数量的 ARP 请求并退出

    1
    2
    3
    arping -c 5 192.168.1.1
    ARPING 192.168.1.1 from 192.168.1.100
    5 packets transmitted, 5 received, 0% packet loss

    发送 5 次 ARP 请求,并在收到 5 次响应后退出。

  4. 无声模式(不输出任何内容)

    1
    arping -q 192.168.1.1

    无任何输出,命令执行后无显示信息。

  5. 检测目标 IP 地址的 MAC 地址

    1
    2
    arping -A 192.168.1.1
    ARPING 192.168.1.1 from 192.168.1.100 (00:11:22:33:44:55) using eth0

    该命令发送 ARP 请求并使用 ARP 回复更新目标主机的缓存。

  6. 设置 ARP 请求的源 IP 地址

    1
    2
    arping -s 192.168.1.100 192.168.1.1
    ARPING 192.168.1.1 from 192.168.1.100 using eth0

    使用指定的源 IP 地址发送 ARP 请求。

  7. 执行重复地址检测(DAD)

    1
    2
    3
    arping -D 192.168.1.1
    ARPING 192.168.1.1 from 0.0.0.0 using eth0
    Duplicate address detected

    执行重复地址检测,检查目标 IP 是否已经被其他主机使用。

  8. 设置超时并限制发送次数

    1
    2
    3
    arping -w 10 -c 5 192.168.1.1
    ARPING 192.168.1.1 from 192.168.1.100
    5 packets transmitted, 5 received, 0% packet loss

    设置 10 秒超时,发送 5 次 ARP 请求,完成后退出。

常用参数选项

  • -A
    使用 ARP 回复包,而不是 ARP 请求包进行通信。

  • -b
    仅发送 MAC 层的广播,而非单播。

  • -c count
    指定发送的 ARP 请求次数,命令将执行指定次数的请求后退出。

  • -D
    启用重复地址检测模式(DAD),检查目标地址是否已被其他主机占用。

  • -f
    在收到第一个 ARP 回复后立即退出,适用于快速检测目标是否在线。

  • -I interface
    指定发送 ARP 请求的网络接口。

  • -h
    显示帮助信息并退出,提供命令的用法说明。

  • -q
    启用静默模式,执行命令时不会显示任何输出。

原厂文档

NAME

   arping - send ARP REQUEST to a neighbour host

SYNOPSIS

   arping [-AbDfhqUV] [-c count] [-w deadline] [-i interval]
          [-s source] [-I interface] {destination}

DESCRIPTION

   Ping destination on device interface by ARP packets, using source
   address source.

   arping supports IPv4 addresses only. For IPv6, see ndisc6(8).

OPTIONS

   -A
       The same as -U, but ARP REPLY packets used instead of ARP
       REQUEST.

   -b
       Send only MAC level broadcasts. Normally arping starts from
       sending broadcast, and switch to unicast after reply received.

   -c count
       Stop after sending count ARP REQUEST packets. With deadline
       option, instead wait for count ARP REPLY packets, or until the
       timeout expires.

   -D
       Duplicate address detection mode (DAD). See RFC2131, 4.4.1.
       Returns 0, if DAD succeeded i.e. no replies are received.

   -f
       Finish after the first reply confirming that target is alive.

   -I interface
       Name of network device where to send ARP REQUEST packets.

   -h
       Print help page and exit.

   -q
       Quiet output. Nothing is displayed.

   -s source
       IP source address to use in ARP packets. If this option is
       absent, source address is:

           • In DAD mode (with option -D) set to 0.0.0.0.

           • In Unsolicited ARP mode (with options -U or -A) set to
           destination.

           • Otherwise, it is calculated from routing tables.

   -U
       Unsolicited ARP mode to update neighbours' ARP caches. No
       replies are expected.

   -V
       Print version of the program and exit.

   -w deadline
       Specify a timeout, in seconds, before arping exits regardless
       of how many packets have been sent or received. If any replies
       are received, exit with status 0, otherwise status 1. When
       combined with the count option, exit with status 0 if count
       replies are received before the deadline expiration, otherwise
       status 1.

   -i interval
       Specify an interval, in seconds, between packets.

SEE ALSO

   ndisc6(8), ping(8), clockdiff(8), tracepath(8).

AUTHOR

   arping was written by Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>.

SECURITY

   arping requires CAP_NET_RAW capability to be executed. It is not
   recommended to be used as set-uid root, because it allows user to
   modify ARP caches of neighbour hosts.

AVAILABILITY

   arping is part of iputils package.

COLOPHON

   This page is part of the iputils (IP utilities) project.
   Information about the project can be found at 
   ⟨http://www.skbuff.net/iputils/⟩.  If you have a bug report for
   this manual page, send it to yoshfuji@skbuff.net,
   netdev@vger.kernel.org.  This page was obtained from the project's
   upstream Git repository ⟨https://github.com/iputils/iputils.git⟩
   on 2024-02-02.  (At that time, the date of the most recent commit
   that was found in the repository was 2024-01-13.)  If you discover
   any rendering problems in this HTML version of the page, or you
   believe there is a better or more up-to-date source for the page,
   or you have corrections or improvements to the information in this
   COLOPHON (which is not part of the original manual page), send a
   mail to man-pages@man7.org