Created
May 1, 2013 19:07
-
-
Save pmbuko/5497551 to your computer and use it in GitHub Desktop.
This script sets up a RHEL(-like) host's ipmi interface with a static address based on eth0's ip address. It uses 'cut' because our eth0 ip addresses are all the same length. It requires ipmitool to be installed. We get it via the 'OpenIPMI' package.
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/bash | |
eth0addr=$(/sbin/ip addr show eth0 | /bin/awk '/inet/{gsub("/.+","");print $2}') | |
ipone=$(/bin/echo $eth0addr | /bin/cut -c1-9) | |
iptwo=$(/bin/echo $eth0addr | /bin/cut -c11-12) | |
ipnet=$(/bin/echo $eth0addr | /bin/cut -c1-5) | |
/usr/bin/ipmitool lan set 1 ipsrc static && \ | |
/usr/bin/ipmitool lan set 1 ipaddr ${ipone}.2${iptwo} && \ | |
/usr/bin/ipmitool lan set 1 defgw ipaddr ${ipnet}.0.1 && \ | |
/usr/bin/ipmitool lan set 1 netmask 255.255.0.0 && \ | |
/usr/bin/ipmitool user set password 2 PASSWORD_GOES_HERE && \ | |
/bin/touch /root/.ipmisetupdone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment