Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Define the list of devices
- devices=("nodeA" "nodeB" "routerA" "routerB" "routerC")
- # Loop through devices and fetch interface details
- for device in "${devices[@]}"; do
- # Use SSH to fetch interface and IP details
- ssh $device "ip -brief address" | while read -r line; do
- interface=$(echo "$line" | awk '{print $1}')
- ip_address=$(echo "$line" | awk '{print $3}' | cut -d'/' -f1)
- if [[ $ip_address == 192.168.* ]]; then
- # Print space-separated info
- echo "$device $interface $ip_address"
- fi
- done
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement