Created
April 16, 2023 08:26
-
-
Save hatamiarash7/328adee511182c6b5a6810cf7fac0dc3 to your computer and use it in GitHub Desktop.
Update iLO IP
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
cdr2mask () | |
{ | |
# Number of args to shift, 255..255, first non-255 byte, zeroes | |
set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0 | |
[ $1 -gt 1 ] && shift $1 || shift | |
echo ${1-0}.${2-0}.${3-0}.${4-0} | |
} | |
IP=$(echo $1 | cut -d '/' -f 1) | |
CDR=$(echo $1 | cut -d '/' -f 2) | |
MASK=$(cdr2mask $CDR) | |
GATEWAY=$2 | |
cat >/tmp/ilo-ip.xml<<EOF | |
<RIBCL VERSION="2.0"> | |
<LOGIN USER_LOGIN="xxx" PASSWORD="xxx"> | |
<RIB_INFO MODE="WRITE" > | |
<MOD_NETWORK_SETTINGS> | |
<IP_ADDRESS VALUE = "$IP"/> | |
<SUBNET_MASK VALUE = "$MASK"/> | |
<GATEWAY_IP_ADDRESS VALUE = "$GATEWAY"/> | |
<PRIM_DNS_SERVER value = "0.0.0.0"/> | |
<DHCP_ENABLE VALUE = "N"/> | |
</MOD_NETWORK_SETTINGS> | |
</RIB_INFO> | |
</LOGIN> | |
</RIBCL> | |
EOF | |
hponcfg -f /tmp/ilo-ip.xml | |
rm /tmp/ilo-ip.xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment