Question: 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

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

Step by Step Solution

3.59 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

bash binbash Find the IPv4 address of the default gateway defaultgatewayip route grep E default awk ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!