0
0
Linux CLIscripting~15 mins

ping for connectivity testing in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Ping for Connectivity Testing
📖 Scenario: You are a network technician who needs to check if certain devices on your network are reachable. You will use the ping command to test connectivity to these devices.
🎯 Goal: Build a simple script that stores a list of IP addresses, sets a count for ping attempts, runs the ping command on each IP, and displays the results.
📋 What You'll Learn
Create a list of IP addresses to test
Set a variable for the number of ping attempts
Use a loop to ping each IP address the set number of times
Display the ping results for each IP
💡 Why This Matters
🌍 Real World
Network administrators often need to check if devices are reachable to troubleshoot connectivity issues.
💼 Career
Knowing how to automate ping tests helps in monitoring network health and diagnosing problems quickly.
Progress0 / 4 steps
1
Create the list of IP addresses
Create a variable called ip_addresses that is a list containing these exact IP addresses as strings: '8.8.8.8', '8.8.4.4', and '1.1.1.1'.
Linux CLI
Need a hint?

Use parentheses to create a list of strings in bash.

2
Set the ping count variable
Create a variable called ping_count and set it to 3 to specify the number of ping attempts per IP.
Linux CLI
Need a hint?

Assign the number 3 to the variable ping_count without spaces around the equals sign.

3
Ping each IP address
Use a for loop with the variable ip to iterate over ip_addresses. Inside the loop, run the command ping -c $ping_count $ip to ping each IP the set number of times.
Linux CLI
Need a hint?

Use "${ip_addresses[@]}" to loop over all IPs in the list.

4
Display the ping results
Add a echo statement inside the loop to print "Pinging $ip:" before running the ping command. This will label the output for each IP address.
Linux CLI
Need a hint?

Use echo "Pinging $ip:" to show which IP is being pinged.