IBM AIX 5L V5 命令详解

ping 命令

用途

发送一个回送信号请求给网络主机。

语法

ping [ -d] [ -D ] [  -n ] [  -q ] [ -r] [ -v] [  -R ] [ -a addr_family ] [  -c Count ] [ -w timeout ] [  -f -i Wait ] [  -l Preload ] [  -p Pattern ] [  -s PacketSize ] [ -S hostname/IP addr ] [ -L ] [ - I a.b.c.d. ] [ -o interface ] [ -T ttl ] Host [  PacketSize ] [  Count ]

描述

/usr/sbin/ping 命令发送一个因特网控制报文协议 (ICMP) ECHO_REQUEST 去从主机或网关那里获得 ICMP ECHO_RESPONSE 信号。ping 命令用于:

  • 确定网络和各外部主机的状态。
  • 跟踪和隔离硬件和软件问题。
  • 测试、评估和管理网络。

如果主机正在运行并连在网上,它就对回送信号进行响应。每个回送信号请求包含一个因特网协议(IP)和 ICMP 头,后面紧跟一个 timeval 结构,以及来填写这个信息包的足够的字节。缺省情况是连续发送回送信号请求直到接收到中断信号(Ctrl-C)。

ping 命令每秒发送一个数据报并且为每个接收到的响应显示一行输出。ping 命令计算信号往返时间和(信息)包丢失情况的统计信息,并且在完成之后显示一个简要总结。ping 命令在程序超时或当接收到 SIGINT 信号时结束。Host 参数或者是一个有效的主机名或者是因特网地址。

缺省情况下,ping 命令将连续发送回送信号请求到显示器直到接收到中断信号 (Ctrl-C)。中断键可以使用 stty 命令来更改。

由于连续回送信号请求会对系统造成一定的负载,重复的请求信号应当主要用作问题隔离。

标志

 

-c Count指定要被发送(或接收)的回送信号请求的数目,由 Count 变量指出。
-w timeout这个选项仅和 -c 选项一起才能起作用。它使 ping 命令以最长的超时时间去等待应答(发送最后一个信息包后)。
-d开始套接字级别的调试。
-D这个选项引起 ICMP ECHO_REPLY 信息包向标准输出的十六进制转储。
-f指定 flood-ping 选项。-f 标志“倾倒”或输出信息包,在它们回来时或每秒 100 次,选择较快一个。每一次发送 ECHO_REQUEST,都显示一个句号,而每接收到一个 ECHO_REPLY 信号,就显示一个退格。这就提供了一种对多少信息包被丢弃的信息的快速显示。仅仅 root 用户可以使用这个选项。

 

注: 这在网络上将非常困难,必须小心使用。Flood ping 命令仅仅 root 用户可以使用。 -f 标志与 -i Wait 标志不兼容。
-I a.b.c.d指定被 a.b.c.d 标明的接口将被用于向外的 IPv4 多点广播。-I 标志是大写的 i。
-o interface指出 interface 将被用于向外的 IPv6 多点广播。接口以“en0”,“tr0”等的形式指定。
-i Wait在每个信息包发送之间等待被 Wait 变量指定的时间(秒数)。缺省值是在每个信息包发送之间等待 1 秒。这个选项与 -f 标志不兼容。
-L对多点广播 ping 命令禁用本地回送。
-l Preload在进入正常行为模式(每秒 1 个)前尽快发送 Preload 变量指定数量的信息包。-l 标志是小写的 L。
-n指定仅输出数字。不企图去查寻主机地址的符号名。
-p Pattern指定用多达 16 个“填充”字节去填充您发送的信息包。这有利于诊断网络上依赖数据的问题。例如,-p ff 全部用 1 填充信息包。
-q指定静默输出。除了在启动和结束时显示总结行外什么也不显示。
-r忽略路由表直接送到连接的网络上的主机上。如果 主机 不在一个直接连接的网络上,ping 命令将产生一个错误消息。这个选项可以被用来通过一个不再有路由经过的接口去 ping 一个本地主机。
-R指定记录路由选项。-R 标志包括 ECHO_REQUEST 信息包中的 RECORD_ROUTE 选项,并且显示返回信息包上的路由缓冲。

 

注: IP 头仅仅大到适合 9 个这样的路由。而且,许多主机和网关忽略这个选项。
-a addr_family映射 ICMP 信息包的目的地址到 IPv6 格式,如果 addr_family 等于“inet6”的话。
-s PacketSize指定要发送数据的字节数。缺省值是 56,当和 8 字节的 ICMP 头数据合并时被转换成 64 字节的 ICMP 数据。
-S hostname/IP addr将 IP 地址用作发出的 ping 信息包中的源地址。在具有不止一个 IP 地址的主机上,可以使用 -S 标志来强制源地址为除了软件包在其上发送的接口的 IP 地址外的任何地址。如果 IP 地址不是以下机器接口地址之一,则返回错误并且不进行任何发送。
-T ttl指定多点广播信息包的生存时间为 ttl 秒。
-v请求详细输出,其中列出了除回送信号响应外接收到的 ICMP 信息。

参数

 

PacketSize指定了要发送数据的字节数。缺省值是 56,当和 8 字节的 ICMP 头数据合并时被转换成 64 字节的 ICMP 数据。包含这个参数是为了和以前的 ping 命令版本相兼容。
Count指定了要发送(接收)的回送信号请求的数目。包含这个参数是为了和以前的 ping 命令版本相兼容。

示例

  1. 要检查网络和主机 canopus 的连接性,并且指定要发送的回送信号请求的数目,请输入:
    ping  -c 5 canopus
    或者
    ping canopus  56  5
    类似下列的信息将被显示:

     

    PING canopus.austin.century.com: (128.116.1.5): 56 data bytes
    64 bytes from 128.116.1.5: icmp_seq=0 ttl=255 time=2 ms
    64 bytes from 128.116.1.5: icmp_seq=1 ttl=255 time=2 ms
    64 bytes from 128.116.1.5: icmp_seq=2 ttl=255 time=3 ms
    64 bytes from 128.116.1.5: icmp_seq=3 ttl=255 time=2 ms
    64 bytes from 128.116.1.5: icmp_seq=4 ttl=255 time=2 ms
    
    ----canopus.austin.century.com PING Statistics----
    5 packets transmitted, 5 packets received, 0% packet loss
    round-trip min/avg/max = 2/2/3 ms
  2. 要想获取有关主机 lear 的信息,并且启动套接字级别的调试,请输入:
    ping  -d lear
    类似下列的信息将被显示:

     

    PING lear.austin.century.com: (128.114.4.18) 56 data bytes
    64 bytes from 128.114.4.18: icmp_seq=0 ttl=255 time=6 ms
    64 bytes from 128.114.4.18: icmp_seq=1 ttl=255 time=17 ms
    64 bytes from 128.114.4.18: icmp_seq=2 ttl=255 time=6 ms
    64 bytes from 128.114.4.18: icmp_seq=3 ttl=255 time=6 ms
    64 bytes from 128.114.4.18: icmp_seq=4 ttl=255 time=6 ms
    ^C
    ----lear.austin.century.com PING Statistics ----
    5 packets transmitted, 5 packets received, 0% packet loss
    round-trip min/avg/max = 6/8/17 ms

     

    注:输出将一直重复直到接收到中断信号(Ctrl-C)。
  3. 要获取有关主机 opus 的信息,并且指定要发送的字节数,请输入:
    ping  -s 2000 opus
    或者
    ping opus  2000
    类似下列的信息将被显示:

     

    PING opus.austin.century.com: (129.35.34.234): 2000 data bytes
    2008 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=20 ms
    2008 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=19 ms
    2008 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=20 ms
    2008 bytes from 129.35.34.234: icmp_seq=3 ttl=255 time=20 ms
    2008 bytes from 129.35.34.234: icmp_seq=4 ttl=255 time=20 ms
    2008 bytes from 129.35.34.234: icmp_seq=5 ttl=255 time=19 ms
    2008 bytes from 129.35.34.234: icmp_seq=6 ttl=255 time=19 ms
    ^C
    ----opus.austin.century.com PING Statistics----
    7 packets transmitted, 7 packets received, 0% packet loss
    round-trip min/avg/max = 19/19/20 ms

     

    注:输出将一直重复直到接收到中断信号(Ctrl-C)。
  4. 要调用 flood-ping 选项给主机 stlopnor,请输入:
    ping  -f stlopnor
    类似下列的信息将被显示:

     

    Ping stlopnor.austin.century.com: (129.35.34.234): 56 data bytes
    .^C
    ----stlopnor.austin.century.com PING Statistics ----
    1098 packets transmitted, 1097 packets received, 0% packet loss
    round-trip min/avg/max = 4/4/11

     

    注:flood-ping 命令的输出将一直重复,直到接收到中断信号(Ctrl-C)。
  5. 要指定发送到主机 opus 信息包的发送时间间隔为 5 秒,请输入:
    ping  -i5 opus
    类似下列的信息将被显示:

     

    PING opus.austin.century.com: (129.35.34.234): 56 data bytes
    64 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=5 ms
    64 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=5 ms
    64 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=6 ms
    ^C
    ----opus.austin.century.com PING Statistics----
    3 packets transmitted, 3 packets received, 0% packet loss
    round-trip min/avg/max = 5/5/6 ms

     

    注:输出将一直重复,直到接收到中断信号(Ctrl-C)。
  6. 在进入正常行为模式前尽快发送 Preload 变量指定的数量的信息包到主机 opus,请输入:
    ping  -l 10 opus
    类似下列的信息将被显示:

     

    PING opus.austin.century.com: (129.35.34.234): 56 data bytes
    64 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=9 ms
    64 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=11 ms
    64 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=16 ms
    64 bytes from 129.35.34.234: icmp_seq=3 ttl=255 time=22 ms
    64 bytes from 129.35.34.234: icmp_seq=4 ttl=255 time=26 ms
    64 bytes from 129.35.34.234: icmp_seq=5 ttl=255 time=27 ms
    64 bytes from 129.35.34.234: icmp_seq=6 ttl=255 time=30 ms
    64 bytes from 129.35.34.234: icmp_seq=7 ttl=255 time=31 ms
    64 bytes from 129.35.34.234: icmp_seq=8 ttl=255 time=33 ms
    64 bytes from 129.35.34.234: icmp_seq=9 ttl=255 time=35 ms
    64 bytes from 129.35.34.234: icmp_seq=10 ttl=255 time=36 ms
    64 bytes from 129.35.34.234: icmp_seq=11 ttl=255 time=6 ms
    64 bytes from 129.35.34.234: icmp_seq=12 ttl=255 time=6 ms
    64 bytes from 129.35.34.234: icmp_seq=13 ttl=255 time=6 ms
    64 bytes from 129.35.34.234: icmp_seq=14 ttl=255 time=7 ms
    64 bytes from 129.35.34.234: icmp_seq=15 ttl=255 time=6 ms
    ^C
    ----opus.austin.century.com PING Statistics----
    16 packets transmitted, 16 packets received, 0% packet loss
    round-trip min/avg/max = 6/19/36 ms

     

    注:输出将一直重复,直到接收到中断信号(Ctrl-C)。
  7. 要诊断网络上依赖数据的问题,请输入:
    ping  -p ff opus
    这个命令用全为 1 的填充模式发送信息包给主机 opus。类似下列的信息将被显示:

     

    PATTERN: 0xff
    PING opus.austin.century.com: (129.35.34.234): 56 data bytes
    64 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=5 ms
    64 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=5 ms
    64 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=5 ms
    64 bytes from 129.35.34.234: icmp_seq=3 ttl=255 time=6 ms
    64 bytes from 129.35.34.234: icmp_seq=4 ttl=255 time=5 ms
    ^C
    ----opus.austin.century.com PING Statistics----
    5 packets transmitted, 5 packets received, 0% packet loss
    round-trip min/avg/max = 5/5/6 ms

     

    注:输出将一直重复,直到接收到中断信号(Ctrl-C)。
  8. 要指定静默输出,请输入:
    ping  -q bach
    仅仅类似下列的总结信息将被显示:

     

    PING bach.austin.century.com: (129.35.34.234): 56 data bytes
    ^C
    ----bach.austin.century.com PING Statistics----
    5 packets transmitted, 5 packets received, 0% packet loss
    round-trip min/avg/max = 5/5/8 ms

     

    注:虽然没有显示,信息包的输出将一直继续,直到接收到中断信号(Ctrl-C)。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值