ipmitool配置指南
前置:管理口(mgnt)和网卡1连接至内网,并分配静态IP
确保以下条件:
网络连接:管理口(mgnt)和网卡1连接至同一内网。
IP分配:确保mgnt口和网卡1分配静态IP地址。
1. 安装ipmitool
根据操作系统选择安装命令:
Debian/Ubuntu
sudo apt-get update
sudo apt-get install ipmitool
CentOS/RHEL
sudo yum install ipmitool
验证安装: 运行以下命令确保安装成功:
ipmitool version
输出示例:
ipmitool version 4.1.0
2. 配置BMC的IP地址
查看当前IPMI配置
ipmitool lan print 1
输出示例:
Current configuration for LAN 1 (channel 1):
Link status: Link UP
IP address: xx.xx.xx.xx
Subnet mask: 255.255.255.0
Gateway IP: xx.xx.xx.xx
Floating IP: none
Port: 0
Anti-rollback support: Enabled
IPMI over LAN: Disabled
设置ID 1为静态IP地址
ipmitool lan set 1 ipsrc static
配置IPMI地址
ipmitool lan set 1 ipaddr xx.xx.xx.xx
配置IPMI子网掩码
ipmitool lan set 1 netmask 255.255.255.0
设置IPMI网关
ipmitool lan set 1 defgw ipaddr xx.xx.xx.xx
3. 脚本示例
host=192.168.1.2 user=admin passwd=Password@_ # 配置BMC myipmitool lan print 1 myipmitool lan set 1 ipsrc static myipmitool lan set 1 ipaddr 10.1.254.51 myipmitool lan set 1 netmask 255.255.255.0 myipmitool lan set 1 defgw ipaddr 10.1.254.2 myipmitool lan set 1 access on # 远程设备 dehost=192.168.1.2 host=10.1.254.52 user=admin passwd=Password@_ # 配置远程设备 ipmitool -I lanplus -H $dehost -U $user -P $passwd lan print 1 ipmitool -I lanplus -H $dehost -U $user -P $passwd lan set <channel> ipsrc static ipmitool -I lanplus -H $dehost -U $user -P $passwd lan set <channel> ipaddr $host ipmitool -I lanplus -H $dehost -U $user -P $passwd lan set <channel> netmask <subnet_mask> ipmitool -I lanplus -H $dehost -U $user -P $passwd lan set <channel> defgw ipaddr <gateway_ip_address> ipmitool -I lanplus -H $dehost -U $user -P $passwd lan set <channel> access on
4. 配置BMC用户登录账户
查看用户列表
ipmitool user list 1
输出示例:
Users on LAN 1 (channel 1): User ID: 1 UserName: admin UserPrivilege: 4 (Administrator) Enabled: yes Auth Type: None Password: * Max Login Attempts: 3 Lockout on Fail: yes Last Login: Never
修改用户密码
ipmitool user set password <id> <new_password>
启用用户账户
ipmitool user enable <id>
5. 查看BMC配置信息
网络配置
sudo ipmitool lan print 1
BMC状态
sudo ipmitool bmc info
输出示例:
BMC Info: Version: 1.40.2 IP Address: 10.1.254.1 State: Online Vendor ID: 12345678 Power Management: Enabled Mainboards Discovered: 1 CPUs: 2 Memory: 2048MB Storage: 256GB (SAMSUNG)
6. 启用IPMI-over-LAN功能
检查状态
ipmitool channel info <channel_number>
启用指定通道
ipmitool channel setaccess <channel_number> 2 ipmi=on auth=off link=on privilege=4
7. 远程连接到BMC
ipmitool -H <bmc_ip> -U <username> -P <password> -I lanplus <command>
示例:获取传感器信息
ipmitool -H 10.1.254.1 -U admin -P Password@_ -I lanplus sensor list
8. 重置BMC
通过ipmitool raw
命令
ipmitool raw 0x32 0x22
冷重启方式
ipmitool mc reset cold
注意事项
IP地址配置:确保所有设备的IP地址在同一子网中,可通过
ping
测试连接性。单线连接:电脑与服务器通过mgnt口连接,服务器断开网线,电脑和BMC设置同一IP段即可访问。
安全性:远程连接时,确保用户名和密码安全,避免被未授权访问。