Created
August 13, 2021 17:52
-
-
Save larsks/05b3f30948569c60489b61824c18949d to your computer and use it in GitHub Desktop.
idrac-set-dhcp.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ipaddr=192.168.0.120 | |
macaddrs=( $( grep '10\.3\.3\.' /etc/dnsmasq.conf | cut -d, -f2 ) ) | |
user=root | |
password=calvin | |
tmpfile=$(mktemp sshXXXXXX) | |
trap "rm -f $tmpfile" EXIT | |
cat > $tmpfile <<EOF | |
Host * | |
StrictHostkeyChecking no | |
UserKnownHostsFile /dev/null | |
EOF | |
arp -d $ipaddr | |
for macaddr in "${macaddrs[@]}"; do | |
echo === $macaddr === | |
arp -s $ipaddr $macaddr | |
sshpass -p"$password" ssh -F $tmpfile -l $user $ipaddr racadm setniccfg -d | |
sshpass -p"$password" ssh -F $tmpfile -l $user $ipaddr racadm getniccfg | |
arp -d $ipaddr | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment