Linux command
ping 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Ping a host
ping [host]
Ping a host
ping -c [5] [host]
Ping with a specific interval
ping -i [0.5] [host]
Ping with a specific packet size
ping -s [1024] [host]
Ping with a specific TTL
ping -t [64] [host]
Ping and show only summary
ping -q -c [10] [host]
Ping using IPv6
ping6 [host]
Ping with audible alert
ping -a [host]
说明
ping uses ICMP ECHO_REQUEST packets to test network connectivity to a host. It measures round-trip time (RTT) and packet loss, making it essential for network troubleshooting and monitoring. Each response shows the sequence number, TTL, and time in milliseconds. The TTL value indicates how many router hops occurred (starting from the remote host's initial TTL, typically 64 or 255). Statistics at the end show packets transmitted/received, loss percentage, and RTT min/avg/max/mdev. The command requires network access and may need root privileges for some options like flood ping. On many systems, ping6 or ping -6 is used for IPv6 targets.
参数
- -c _COUNT_
- Stop after sending COUNT packets
- -i _INTERVAL_
- Wait INTERVAL seconds between packets (default: 1)
- -s _SIZE_
- Packet data size in bytes (default: 56, total 64 with ICMP header)
- -t _TTL_
- Set IP Time To Live
- -w _DEADLINE_
- Exit after DEADLINE seconds regardless of packets
- -W _TIMEOUT_
- Wait TIMEOUT seconds for each response
- -q
- Quiet output; only show summary
- -v
- Verbose output
- -a
- Audible ping (beep on reply)
- -f
- Flood ping; send packets as fast as possible (root only)
- -n
- Numeric output only; don't resolve hostnames
- -4
- Use IPv4 only
- -6
- Use IPv6 only
- -I _INTERFACE_
- Use specified network interface or address
- -R
- Record route (IPv4, may be ignored by hosts)
- -D
- Print timestamps
- -Q _TOS_
- Set Quality of Service bits
- -p _PATTERN_
- Fill packet with specified pattern bytes
FAQ
What is the ping command used for?
ping uses ICMP ECHO_REQUEST packets to test network connectivity to a host. It measures round-trip time (RTT) and packet loss, making it essential for network troubleshooting and monitoring. Each response shows the sequence number, TTL, and time in milliseconds. The TTL value indicates how many router hops occurred (starting from the remote host's initial TTL, typically 64 or 255). Statistics at the end show packets transmitted/received, loss percentage, and RTT min/avg/max/mdev. The command requires network access and may need root privileges for some options like flood ping. On many systems, ping6 or ping -6 is used for IPv6 targets.
How do I run a basic ping example?
Run `ping [host]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c _COUNT_ do in ping?
Stop after sending COUNT packets