Advertisement
torbeneims

Rechnernetze Lab Interfaces

Nov 16th, 2024
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.60 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Define the list of devices
  4. devices=("sender1" "sender2" "router1" "router2" "receiver1" "receiver2")
  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
  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