Linux for network engineers lab 9 of 14
Bash for network tasks: loop over hosts and parse output
You turn a morning of manual checks into scripts: a parallel ping sweep, service checks, log statistics, a look at every router over SSH, and a report that cron runs for you.
Run this lab
It needs Lite: its 5 nodes are set to 5 vCPU and 3,072 MB in total. That fits the free demo too.
In your workspace: Shared, then Linux for network engineers guided labs, then 09 - Bash for network tasks - loop over hosts and parse output
- Level
- Intermediate
- Time
- About 75 minutes
- Nodes need
- 5 vCPU, 3,072 MB
- Smallest plan
- Lite
The scenario
Every morning at Barnsley, somebody pings the depot's kit by hand, logs in to two routers, and skims the firewall log. It takes half an hour and it's always skipped when things are busy, which is when it matters. Automate it on WS, one script at a time. The files you need are already in /root/lab.
| Device | Interface | Address | Role |
|---|---|---|---|
| WS | eth0 | 10.9.10.50/24 | your workstation; bash, ssh, awk and friends |
| R1, R2 | Gi0/0 | 10.9.10.1, 10.9.10.2 /24 | routers; user ops, SSH only |
| H1 | eth0 | 10.9.10.11/24 | web server on port 80, SSH |
| H2 | eth0 | 10.9.10.12/24 | SSH only |
| printer | 10.9.10.13 | switched off, so it never answers |
| Device | Runs | How to log in |
|---|---|---|
| WS | Ubuntu 22.04 desktop container | Its console is a remote desktop: root / eve. Open a terminal there. |
| H1, H2 | Alpine Linux 3.20 | root, no password. |
| R1, R2 | Cisco IOSv 15.9 | The console opens at >; enable has no password. |
What you’ll practise
- Loop over files of hosts with while read
- Run jobs in parallel with & and wait
- Test TCP services from Bash and use exit codes
- Parse text with grep, cut, awk, sort and uniq
- Collect output from routers over SSH keys
- Schedule a script with cron and allow for its environment
The tasks
- Start the Linux nodes
- Sweep the network
- Check services, not just hosts
- Pull facts out of logs
- Ask the routers
- Put it on a schedule
The Lab Tasks pane has the scenario, these tasks, the checks to run, hints and the full solution.
Topology and devices
The network as it opens in EVE-NG, drawn from the lab’s own canvas, and the image each node runs.
Every link, as text
- WS
eth0to LAN (network) - H1
eth0to LAN (network) - H2
eth0to LAN (network) - R1
Gi0/0to LAN (network) - R2
Gi0/0to LAN (network)
| Node | Device | Image in Add Node | Set to |
|---|---|---|---|
| WS | EVE-NG GUI server (Docker) | eve-gui-server:latest | 1 vCPU, 1,024 MB |
| H1 | Alpine Linux | clbalpinebase-alpine-base-3-20-3 | 1 vCPU, 512 MB |
| H2 | Alpine Linux | clbalpinebase-alpine-base-3-20-3 | 1 vCPU, 512 MB |
| R1 | Cisco IOSv | vios-adventerprisek9-m.spa.159-3.m9 | 1 vCPU, 512 MB |
| R2 | Cisco IOSv | vios-adventerprisek9-m.spa.159-3.m9 | 1 vCPU, 512 MB |
How to open this lab
Sign in to your workspace at
lab.cloudlabbox.com.In File Manager, open Shared, then the folder
Linux for network engineers guided labs.Open
09 - Bash for network tasks - loop over hosts and parse outputand start its nodes, then open Lab Tasks for the scenario and the steps.
The lab is read-only. You can start the nodes and configure the devices, but changes to the topology can’t be saved. To change it, rebuild it in your own folder.
More Linux for network engineers labs
All Linux for network engineers labs
Related labs in other courses
CloudLabBox is independent of Cisco, CompTIA, the Linux Foundation and the Linux Professional Institute. The lab follows exam topics and isn’t vendor training material; vendor names identify the exams and the images in the workspace.