View difference between Paste ID: AaPqYz2K and fqfEQ5z6
SHOW: | | - or go back to the newest paste.
1
#!/bin/bash
2
3
# Define the list of devices
4-
devices=("sender1" "sender2" "router1" "router2" "receiver1" "receiver2")
4+
devices=("nodeA" "nodeB" "routerA" "routerB" "routerC")
5
6
# Loop through devices and fetch interface details
7
for device in "${devices[@]}"; do
8
    # Use SSH to fetch interface and IP details
9
    ssh $device "ip -brief address" | while read -r line; do
10
        interface=$(echo "$line" | awk '{print $1}')
11
        ip_address=$(echo "$line" | awk '{print $3}' | cut -d'/' -f1)
12-
        if [[ $ip_address == 10.* ]]; then
12+
        if [[ $ip_address == 192.168.* ]]; then
13
            # Print space-separated info
14
            echo "$device $interface $ip_address"
15
        fi
16
    done
17
done
18