本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名原文链接~~~

服务器设置 BMC IP 脚本

微信搜索 zze_coding 或扫描 👉 二维码关注我的微信公众号获取更多资源推送:


安装 ipmi 包:

$ apt install ipmitool

编写脚本 set_bmc.sh 内容如下:

#!/bin/bash
ipsrc=$1
ipaddr=$2
netmask=$3
gateway=$4
set_ipsrc(){
	echo -e "*****************"
	ipmitool lan set 1 ipsrc $ipsrc
}
set_ip(){
	echo -e "*****************"
	ipmitool lan set 1 ipaddr $ipaddr
}
set_netmask(){
	echo -e "*****************"
	ipmitool lan set 1 netmask $netmask
}
set_gateway(){
	echo -e "*****************"
	ipmitool lan set 1 defgw ipaddr $gateway
}

set_ipsrc
if [ $? -eq 0 ];then
	echo -e "set ipsource to static===>\033[42;37m Pass \033[0m\n"
else
	echo -e "\033[41;37m Error code:1 \033[0m"
	exit 1
fi
sleep 10
set_ip
if [ $? -eq 0 ];then
        echo -e "set static ip===>\033[42;37m Pass \033[0m\n"
else
        echo -e "\033[41;37m Error code:2 \033[0m"
        exit 2
fi
sleep 10
set_netmask
if [ $? -eq 0 ];then
        echo -e "set static netmask===>\033[42;37m Pass \033[0m\n"
else
        echo -e "\033[41;37m Error code:3 \033[0m"
        exit 3
fi
sleep 10
set_gateway
if [ $? -eq 0 ];then
        echo -e "set static default gateway===>\033[42;37m Pass \033[0m\n"
else
        echo -e "\033[41;37m Error code:4 \033[0m"
        exit 4
fi
sleep 10

使用方法:

$ ./set_bmc.sh static 192.168.1.10 255.255.255.0 192.168.1.1
# Linux 杂项  

如果这篇文章对您有帮助,可点击下方链接分享给你的朋友们😋,如果遇到问题欢迎评论、留言~~~😇

评论

公众号:zze_coding

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×