[Bash] ping netstat & traceroute Command
Ping
ping is a utility used to test the reachability of a host on an IP network and to measure the round-trip time for messages sent from the originating host to a destination computer.
ping [options] destination
Common Options:
-c count: Stop after sending (and receiving) count ECHO_REQUEST packets.
-i interval: Wait interval seconds between sending each packet.
-t ttl: Set the IP Time to Live.
-q: Quiet output. Only summary lines are printed.
-s packetsize: Specify the number of data bytes to be sent.
# Ping a Host:
ping google.com
# Ping a Host a Specific Number of Times:
ping -c 4 google.com
# Ping with a Specific Interval:
ping -i 2 google.com
# Quiet Ping (Only Summary):
ping -c 4 -q google.com
# Ping with a Specific Packet Size:
ping -s 100 google.com
netstat
netstat is a powerful network utility that provides information and statistics about network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
netstat [options]
Common Options:
-a: Display all connections and listening ports.
-t: Display TCP connections.
-u: Display UDP connections.
-n: Show numerical addresses instead of resolving hostnames.
-r: Display the routing table.
-i: Display network interfaces.
# Display All Connections and Listening Ports:
netstat -a
# Display TCP Connections:
netstat -t
# Display UDP Connections:
netstat -u
# Display Numerical Addresses:
netstat -n
# Display Connections with Program Names:
netstat -r
# Display Network Interfaces:
netstat -i
traceroute
traceroute is a network diagnostic tool used to track the pathway taken by a packet on an IP network from source to destination. It helps identify routing paths and network issues.
traceroute [options] destination
Common Options:
-m max_ttl: Specifies the maximum number of hops (max Time-To-Live value).
-q nqueries: Sets the number of probe packets per hop.
-w waittime: Sets the time (in seconds) to wait for a response to a probe.
-I: Use ICMP ECHO for tracerouting (like Windows tracert).
# Basic Traceroute to a Host:
traceroute google.com
# Traceroute with a Maximum Number of Hops:
traceroute -m 15 google.com
# Traceroute with a Specific Number of Probes per Hop:
traceroute -q 5 google.com
# Traceroute with ICMP ECHO Requests:
traceroute -I google.com
# Traceroute with a Specific Wait Time:
traceroute -w 2 google.com

浙公网安备 33010602011771号