Advertisement
torbeneims

Rechnernetze Lab Interfaces

Nov 30th, 2024
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # Define the list of devices
  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 == 192.168.* ]]; then
  13.             # Print space-separated info
  14.             echo "$device $interface $ip_address"
  15.         fi
  16.     done
  17. done
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement