Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
cat << 'EOF' > ~/findip.sh
#!/bin/bash
#FreeSoftwareServers.com

echo "Finding All Active IP's in Network via single Ping"
sleep 2s

fping -a -g 192.168.1.0/24 >/dev/null 2>&1 &
#nmap -sn 192.168.1.0/24 >/dev/null 2>&1 &

echo "Please Enter the Exact Name of the VM Guest:"

read guestname

arp -na | awk -v mac=$(virsh domiflist $guestname | awk '$2=="bridge"{print $NF}') '$0 ~ " at " mac {gsub("[()]", "", $2); print $2}'
EOF
chmod +x ~/findip.sh
sudo sh -c 'echo "alias findguestip=~/findip.sh" >> ~/.bashrc'
source ~/.bashrc
findguestip

...

No Format
cat << 'EOF' > ~/findallips.sh
#!/bin/bash
#FreeSoftwareServers.com

echo "Finding All Active IP's in Network via single Ping"
sleep 2s

fping -a -g 192.168.1.0/24 >/dev/null 2>&1 &
#nmap -sn 192.168.1.0/24 >/dev/null 2>&1 &

domainlog=/tmp/domain.log

virsh list --all | grep running |  cut -c 8- >> "$domainlog"

sed -i 's/running*//g' "$domainlog"

readarray domain < "$domainlog"

for i in "${domain[@]}"
do
ip="$(arp -na | awk -v mac=$(virsh domiflist $i | awk '$2=="bridge"{print $NF}') '$0 ~ " at " mac {gsub("[()]", "", $2); print $2}')"
echo "Hostname : $i IP : $ip"
done
rm "$domainlog"
EOF
chmod +x ~/findallips.sh
sudo sh -c 'echo "alias findallips=~/findallips.sh" >> ~/.bashrc'
source ~/.bashrc
findallips

...