ping6 Command in Linux



The ping6 command in Linux sends the ICMPv6 ECHO_REQUEST packets to network hosts to test the network connectivity for IPv6. ECHO_REQUESTS are ICMP (Internet Control Message Protocol) packets used for network diagnostics. They are sent by the ping6 command to test connectivity between devices. For IPv6, they are ICMPv6 Type 128 messages. A destination device responds with an ECHO_REPLY if it is reachable and allowed to respond.

Table of Contents

Here is a comprehensive guide to the options available with the ping6 command −

Syntax of ping6 Command

The syntax of the ping6 command in Linux is as follows −

ping6 [options] [destination]

In the above syntax, the [options] field is used to specify various options to change the output response. The [destination] field is used to specify the IP address or hostname.

ping6 Command Options

The following are the available options for the ping6 command −

Option Description
-a Audible ping.
-A Adaptive ping adjusts interval based on round-trip time.
-b Allow pinging broadcast addresses.
-B Prevents the source address from changing.
-c count Stop after sending the specified number of packets.
-D Print timestamps.
-d Enable socket debug option (Linux only).
-e identifier Define identifier for ping session (default random for SOCK_RAW).
-F flow label Set a 20-bit flow label on packets (IPv6 only).
-f Flood ping, sending packets as fast as possible.
-h Display help.
-H Force reverse DNS name resolution.
-i interval Set the interval between packets (default: 1s).
-I interface Specify the network interface or source address.
-l preload Send a specified number of packets before waiting for replies.
-L Suppress loopback of multicast packets.
-n Numeric output only, no hostname resolution.
-p pattern Define a custom packet payload pattern (up to 16 bytes).
-q Quiet mode, showing only summary output.
-r Bypass routing tables, sending directly to a host.
-s packetsize Set the number of data bytes in each packet.
-S sndbuf Set the socket to send buffer size.
-t ttl Set Time-to-Live (TTL) for packets.
-T timestamp Set timestamp options (tsonly, tsandaddr, tsprespec).
-M hint Set Path MTU Discovery strategy (do, want, dont).
-v Verbose output.
-V Show version information and exit.
-w deadline Set a timeout for ping to exit, in seconds.
-W timeout Time to wait for a response before timing out.

Examples ping6 Command in Linux

This section provides examples of how to use the ping6 command in Linux.

Pinging an IPv6

To ping an IPv6 address, use the ping6 command in the following way −

ping6 2404:6800:4003:c05::66
ping6 Command in Linux1

Pinging a Hostname

To ping an IPv6-enabled domain, use the following command −

ping6 google.com
ping6 Command in Linux2

Sending a Specific Number of Packets

To send a specific number of packets, use the -c option. For example, to send 3 packets, use the following command −

ping6 -c 3 2404:6800:4003:c05::66
ping6 Command in Linux3

Sending Packets after a Specific Interval

To send packets after a specific interval, use the -i option. For example, to send a packet after every 2 seconds, use the following command −

ping6 -i 2 2404:6800:4003:c05::66

Executing Flood Ping

To flood the packets as fast as possible, use the -f option −

sudo ping6 -f 2404:6800:4003:c05::66
ping6 Command in Linux4

Executing the above command requires superuser access.

Pinging in a Quiet Mode

To ping in the quiet mode, use the -q option −

ping6 -q -c 3 2404:6800:4003:c05::66
ping6 Command in Linux5

The above command will display the result summary only.

Specifying the Packet Size

To specify the payload size, use the -s option. For example, to send a payload of 128 bytes, use the ping6 command in the following way −

ping6 -s 128 2404:6800:4003:c05::66

Setting Timeout

To set a time after which the ping stops, use the -w option. For example, to stop pinging after 5 seconds, use the following command −

ping6 -w 5 2404:6800:4003:c05::66
ping6 Command in Linux6

Setting Wait Time for Response

To set the waiting time for response, use the -W option.

ping6 -c 3 -W 3 2031:db8::1
ping6 Command in Linux7

The above command waits up to 3 seconds for a reply before considering it lost.

Displaying Usage Help

To display the usage help of the ping6 command, use the -h option −

ping6 -h

Note − The ping6 command has been deprecated in some distributions, and ping -6 is preferred.

Conclusion

The ping6 command in Linux is used to test network connectivity for IPv6 by sending ICMPv6 ECHO_REQUEST packets. A reachable destination responds with an ECHO_REPLY, confirming connectivity.

The ping6 command includes various options to control behavior, such as setting packet size, adjusting intervals, limiting the number of packets, and enabling quiet mode. Examples demonstrate how to use ping6 for different purposes, including pinging IPv6 addresses, hostnames, and setting timeouts.

Advertisements