arping
arping有两个版本,一个是linux发行版提供的,一个是作者Thomas Habets <thomas@habets.se>
的,区别是后者支持ping mac获取IP地址。
操作环境
archalinux 2016.02.01
安装过程比较简单,注意解决缺失依赖包。
安装工具和依赖包
git/automake/autoconf/libnet/gcc
# 安装autoconf
➜ arping git:(c4bb02e) pacman -S autoconf
resolving dependencies...
looking for conflicting packages...
Packages (2) m4-1.4.17-1 autoconf-2.69-2
Total Download Size: 0.73 MiB
Total Installed Size: 2.33 MiB
:: Proceed with installation? [Y/n] y
:: Retrieving packages ...
m4-1.4.17-1-x86_64 165.8 KiB 638K/s 00:00 [############################] 100%
autoconf-2.69-2-any 583.7 KiB 978K/s 00:01 [############################] 100%
(2/2) checking keys in keyring [############################] 100%
(2/2) checking package integrity [############################] 100%
(2/2) loading package files [############################] 100%
(2/2) checking for file conflicts [############################] 100%
(2/2) checking available disk space [############################] 100%
:: Processing package changes...
(1/2) installing m4 [############################] 100%
(2/2) installing autoconf [############################] 100%
➜ arping git:(c4bb02e) which autoreconf
/usr/bin/autoreconf
# 安装automake
➜ arping git:(c4bb02e) pacman -Ss automake
core/automake 1.15-1 (base-devel)
A GNU tool for automatically creating Makefiles
➜ arping git:(c4bb02e) pacman -S automake
resolving dependencies...
looking for conflicting packages...
Packages (1) automake-1.15-1
Total Download Size: 0.57 MiB
Total Installed Size: 1.56 MiB
:: Proceed with installation? [Y/n] y
:: Retrieving packages ...
automake-1.15-1-any 585.2 KiB 1009K/s 00:01 [############################] 100%
(1/1) checking keys in keyring [############################] 100%
(1/1) checking package integrity [############################] 100%
(1/1) loading package files [############################] 100%
(1/1) checking for file conflicts [############################] 100%
(1/1) checking available disk space [############################] 100%
:: Processing package changes...
(1/1) installing automake [############################] 100%
# 安装libnet
➜ arping git:(c4bb02e) ✗ pacman -S libnet
resolving dependencies...
looking for conflicting packages...
Packages (1) libnet-1.1.6-2
Total Download Size: 0.09 MiB
Total Installed Size: 0.34 MiB
:: Proceed with installation? [Y/n] y
:: Retrieving packages ...
libnet-1.1.6-2-x86_64 89.0 KiB 622K/s 00:00 [############################] 100%
(1/1) checking keys in keyring [############################] 100%
(1/1) checking package integrity [############################] 100%
(1/1) loading package files [############################] 100%
(1/1) checking for file conflicts [############################] 100%
(1/1) checking available disk space [############################] 100%
:: Processing package changes...
(1/1) installing libnet [############################] 100%
下载arping源代码
从Github下载源代码
# 下载源代码
➜ ~ git clone https://github.com/ThomasHabets/arping.git
Cloning into 'arping'...
remote: Counting objects: 1612, done.
remote: Total 1612 (delta 0), reused 0 (delta 0), pack-reused 1612
Receiving objects: 100% (1612/1612), 584.81 KiB | 293.00 KiB/s, done.
Resolving deltas: 100% (962/962), done.
Checking connectivity... done.
# 切换到最新的release版本
➜ ~ cd arping
➜ arping git:(arping-2.x) ls
HACKING.md LICENSE Makefile.am.common bootstrap.sh doc src
INSTALL Makefile.am README configure.ac extra
➜ arping git:(arping-2.x) git status
On branch arping-2.x
Your branch is up-to-date with 'origin/arping-2.x'.
nothing to commit, working directory clean
➜ arping git:(arping-2.x) git tag
arping-2.06
arping-2.07
arping-2.08
arping-2.09
arping-2.10
arping-2.11
arping-2.12
arping-2.13
arping-2.14
arping-2.15
arping-2.16
➜ arping git:(arping-2.x) git checkout arping-2.16
Note: checking out 'arping-2.16'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at c4bb02e... Up version to 2.16.
编译安装
# 目录当前文件,bootstrap.sh为可执行文件
➜ arping git:(arping-2.x) ls
HACKING.md LICENSE Makefile.am.common bootstrap.sh doc src
INSTALL Makefile.am README configure.ac extra
# bootstrap.sh文件内容
➜ arping git:(c4bb02e) ✗ cat bootstrap.sh
#!/bin/sh
autoreconf -i
# 执行配置初始化
➜ arping git:(c4bb02e) ./bootstrap.sh
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/ at /usr/bin/automake line 3936.
configure.ac:14: installing './compile'
configure.ac:6: installing './config.guess'
configure.ac:6: installing './config.sub'
configure.ac:8: installing './install-sh'
configure.ac:8: installing './missing'
src/Makefile.am: installing './depcomp'
parallel-tests: installing './test-driver'
➜ arping git:(c4bb02e) ✗ ls
HACKING.md Makefile.am.common autom4te.cache config.h.in depcomp missing
INSTALL Makefile.in bootstrap.sh config.sub doc src
LICENSE README compile configure extra test-driver
Makefile.am aclocal.m4 config.guess configure.ac install-sh
# 可以在此处指定一些配置信息,如安装位置等
➜ arping git:(c4bb02e) ✗ ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking for sqrt in -lm... yes
checking for socket in -lsocket... no
checking for gethostbyname in -lnsl... yes
checking for cap_init in -lcap... yes
checking for clock_gettime in -lrt... yes
checking for libnet_name_resolve in -lnet... no
checking for libnet_init in -lnet... yes
checking for pcap_open_live in -lpcap... yes
checking for library containing clock_gettime... none required
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking for stdlib.h... (cached) yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking grp.h usability... yes
checking grp.h presence... yes
checking for grp.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for sys/types.h... (cached) yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/capability.h usability... yes
checking sys/capability.h presence... yes
checking for sys/capability.h... yes
checking for stdint.h... (cached) yes
checking libnet.h usability... yes
checking libnet.h presence... yes
checking for libnet.h... yes
checking win32/libnet.h usability... no
checking win32/libnet.h presence... no
checking for win32/libnet.h... no
checking net/bpf.h usability... yes
checking net/bpf.h presence... yes
checking for net/bpf.h... yes
checking pwd.h usability... yes
checking pwd.h presence... yes
checking for pwd.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
checking for working volatile... yes
checking for uint8_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking whether gcc needs -traditional... no
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking for sys/socket.h... (cached) yes
checking types of arguments for select... int,fd_set *,struct timeval *
checking return type of signal handlers... void
checking for gettimeofday... yes
checking for memset... yes
checking for select... yes
checking for strchr... yes
checking for strdup... yes
checking for strerror... yes
checking for strstr... yes
checking for getifaddrs... yes
checking for cap_init... yes
checking for pcap_create... yes
checking for pcap_list_tstamp_types... yes
checking for pcap_set_immediate_mode... yes
checking for libnet_init signature has const... yes
checking for libnet_name2addr4 signature has const... no
checking for CLOCK_MONOTONIC... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating doc/Makefile
config.status: creating config.h
config.status: executing depfiles commands
arping version 2.16
Prefix.........: /usr/local
Debug Build....:
C Compiler.....: gcc -g -O2
Linker.........: -lpcap -lnet -lrt -lcap -lnsl -lm
# 编译
➜ arping git:(c4bb02e) ✗ make
make all-recursive
make[1]: Entering directory '/root/arping'
Making all in src
make[2]: Entering directory '/root/arping/src'
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT arping.o -MD -MP -MF .deps/arping.Tpo -c -o arping.o arping.c
mv -f .deps/arping.Tpo .deps/arping.Po
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT arping_main.o -MD -MP -MF .deps/arping_main.Tpo -c -o arping_main.o arping_main.c
mv -f .deps/arping_main.Tpo .deps/arping_main.Po
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT unix.o -MD -MP -MF .deps/unix.Tpo -c -o unix.o unix.c
mv -f .deps/unix.Tpo .deps/unix.Po
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT findif_getifaddrs.o -MD -MP -MF .deps/findif_getifaddrs.Tpo -c -o findif_getifaddrs.o findif_getifaddrs.c
mv -f .deps/findif_getifaddrs.Tpo .deps/findif_getifaddrs.Po
gcc -g -O2 -o arping arping.o arping_main.o unix.o findif_getifaddrs.o -lpcap -lnet -lrt -lcap -lnsl -lm
make[2]: Leaving directory '/root/arping/src'
Making all in doc
make[2]: Entering directory '/root/arping/doc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/arping/doc'
make[2]: Entering directory '/root/arping'
make[2]: Leaving directory '/root/arping'
make[1]: Leaving directory '/root/arping'
# 安装
➜ arping git:(c4bb02e) ✗ make install
Making install in src
make[1]: Entering directory '/root/arping/src'
make[2]: Entering directory '/root/arping/src'
/usr/bin/mkdir -p '/usr/local/sbin'
/usr/bin/install -c arping '/usr/local/sbin'
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/root/arping/src'
make[1]: Leaving directory '/root/arping/src'
Making install in doc
make[1]: Entering directory '/root/arping/doc'
make[2]: Entering directory '/root/arping/doc'
make[2]: Nothing to be done for 'install-exec-am'.
/usr/bin/mkdir -p '/usr/local/share/man/man8'
/usr/bin/install -c -m 644 arping.8 '/usr/local/share/man/man8'
make[2]: Leaving directory '/root/arping/doc'
make[1]: Leaving directory '/root/arping/doc'
make[1]: Entering directory '/root/arping'
make[2]: Entering directory '/root/arping'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/root/arping'
make[1]: Leaving directory '/root/arping'
程序文件
程序默认安装在/usr/local/sbin/arping
➜ arping git:(c4bb02e) ✗ ls /usr/local/sbin/arping
/usr/local/sbin/arping
# 安装版本
➜ arping git:(c4bb02e) ✗ /usr/local/sbin/arping -v
ARPing 2.16, by Thomas Habets <thomas@habets.se>
usage: arping [ -0aAbdDeFpPqrRuUv ] [ -w <us> ] [ -W <sec> ] [ -S <host/ip> ]
[ -T <host/ip ] [ -s <MAC> ] [ -t <MAC> ] [ -c <count> ]
[ -C <count> ] [ -i <interface> ] [ -m <type> ]
[ -V <vlan> ] [ -Q <priority> ] <host/ip/MAC | -B>
For complete usage info, use --help or check the manpage.
# 系统自带版本
➜ arping git:(c4bb02e) ✗ /usr/usr/bin/arping -V
arping utility, iputils-s20140519