Write a network diagnostics bash script that does the following: Finds the IPv4 address of the default gateway on your
Write a network diagnostics bash script that does the following:
- Finds the IPv4 address of the default gateway on your machine (one way to get this is the 'default' entry, also shown as 0.0.0.0, in the output of 'ip route') and runs a ping (with a count of 5 pings) to it.
- Runs another count of 5 pings to the site example.com.
- Outputs a 1-line summary of interfaces on your machine, not including the loopback address (lo).
- Outputs a 1-line summary of how many TCP ports are open (in state LISTEN)
The output of your script should look exactly like this (different numbers are OK). For the ping times output, use the 'avg' number from the ping command. This is the average that is calculated for you -- no need to calculate it in your script.
Ping time to default gateway: 0.348 ms Ping time to example.com: 24.807 ms Interface count: 2, and 2/2 are up There are 7 TCP ports in the LISTEN state