IPMITOOL工具使用詳解(待驗證)

[root@localhost ~]# yum install -y ipmitool #安裝這個包

#service ipmi start
#ipmitool -I open shell
#### 可以直接進入本地BMC sh

[root@localhost ~]# ipmitool -h
ipmitool version 1.8.18

usage: ipmitool [options...] <command>

       -h             This help
       -V             Show version information
       -v             Verbose (can use multiple times)
       -c             Display output in comma separated format
       -d N           Specify a /dev/ipmiN device to use (default=0)
       -I intf        Interface to use
       -H hostname    Remote host name for LAN interface
       -p port        Remote RMCP port [default=623]
       -U username    Remote session username
       -f file        Read remote session password from file
       -z size        Change Size of Communication Channel (OEM)
       -S sdr         Use local file for remote SDR cache
       -D tty:b[:s]   Specify the serial device, baud rate to use
                      and, optionally, specify that interface is the system one
       -4             Use only IPv4
       -6             Use only IPv6
       -a             Prompt for remote password
       -Y             Prompt for the Kg key for IPMIv2 authentication
       -e char        Set SOL escape character
       -C ciphersuite Cipher suite to be used by lanplus interface
       -k key         Use Kg key for IPMIv2 authentication
       -y hex_key     Use hexadecimal-encoded Kg key for IPMIv2 authentication
       -L level       Remote session privilege level [default=ADMINISTRATOR]
                      Append a '+' to use name/privilege lookup in RAKP1
       -A authtype    Force use of auth type NONE, PASSWORD, MD2, MD5 or OEM
       -P password    Remote session password
       -E             Read password from IPMI_PASSWORD environment variable
       -K             Read kgkey from IPMI_KGKEY environment variable
       -m address     Set local IPMB address
       -b channel     Set destination channel for bridged request
       -t address     Bridge request to remote target address
       -B channel     Set transit channel for bridged request (dual bridge)
       -T address     Set transit address for bridge request (dual bridge)
       -l lun         Set destination lun for raw commands
       -o oemtype     Setup for OEM (use 'list' to see available OEM types)
       -O seloem      Use file for OEM SEL event descriptions
       -N seconds     Specify timeout for lan [default=2] / lanplus [default=1] interface
       -R retry       Set the number of retries for lan/lanplus interface [default=4]

Interfaces:
        open          Linux OpenIPMI Interface [default]
        imb           Intel IMB Interface
        lan           IPMI v1.5 LAN Interface
        lanplus       IPMI v2.0 RMCP+ LAN Interface
        serial-terminal  Serial Interface, Terminal Mode
        serial-basic  Serial Interface, Basic Mode
        usb           IPMI USB Interface(OEM Interface for AMI Devices)

Commands:
        raw           Send a RAW IPMI request and print response
        i2c           Send an I2C Master Write-Read command and print response
        spd           Print SPD info from remote I2C device
        lan           Configure LAN Channels
        chassis       Get chassis status and set power state
        power         Shortcut to chassis power commands
        event         Send pre-defined events to MC
        mc            Management Controller status and global enables
        sdr           Print Sensor Data Repository entries and readings
        sensor        Print detailed sensor information
        fru           Print built-in FRU and scan SDR for FRU locators
        gendev        Read/Write Device associated with Generic Device locators sdr
        sel           Print System Event Log (SEL)
        pef           Configure Platform Event Filtering (PEF)
        sol           Configure and connect IPMIv2.0 Serial-over-LAN
        tsol          Configure and connect with Tyan IPMIv1.5 Serial-over-LAN
        isol          Configure IPMIv1.5 Serial-over-LAN
        user          Configure Management Controller users
        channel       Configure Management Controller channels
        session       Print session information
        dcmi          Data Center Management Interface
        nm            Node Manager Interface
        sunoem        OEM Commands for Sun servers
        kontronoem    OEM Commands for Kontron devices
        picmg         Run a PICMG/ATCA extended cmd
        fwum          Update IPMC using Kontron OEM Firmware Update Manager
        firewall      Configure Firmware Firewall
        delloem       OEM Commands for Dell systems
        shell         Launch interactive IPMI shell
        exec          Run list of commands from file
        set           Set runtime variable for shell and exec
        hpm           Update HPM components using PICMG HPM.1 file
        ekanalyzer    run FRU-Ekeying analyzer using FRU files
        ime           Update Intel Manageability Engine Firmware
        vita          Run a VITA 46.11 extended cmd
        lan6          Configure IPv6 LAN Channels

一、開關機,重啓

1. 查看開關機狀態:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) power status

2. 開機:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) power on

3. 關機:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) power off

4. 重啓:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) power reset

二、用戶管理

說明:[ChannelNo] 字段是可選的,ChannoNo爲1或者8;BMC默認有2個用戶:user id爲1的匿名用戶,user id爲2的ADMIN用戶;<>字段爲必選內容;<privilege level>:2爲user權限,3爲Operator權限,4爲Administrator權限;

1. 查看用戶信息:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) user list [ChannelNo]

2. 增加用戶:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) user set name <user id> <username>

3. 設置密碼:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) user set password <user id> <password>

4. 設置用戶權限:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) user priv <user id> <privilege level> [ChannelNo]

5. 啓用/禁用用戶:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) user enable/disable <user id>

三、IP網絡設置

說明:[ChannelNo] 字段是可選的,ChannoNo爲1(Share Nic網絡)或者8(BMC獨立管理網絡);設置網絡參數,必須首先設置IP爲靜態,然後再進行其他設置;

1. 查看網絡信息:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) lan print [ChannelNo]

2. 修改IP爲靜態還是DHCP模式:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) lan set <ChannelNo> ipsrc <static/dhcp>

3. 修改IP地址:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) lan set <ChannelNo> ipaddr <IPAddress>

4. 修改子網掩碼:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) lan set <ChannelNo> netmask <NetMask>

5. 修改默認網關:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) lan set <ChannelNo> defgw ipaddr <默認網關>

四、SOL功能

說明:<9.6/19.2/38.4/57.6/115.2>其中115.2代表115200,即*1000是表示的波特率。

1. 設置SOL串口波特率:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) sol set volatile-bit-rate <9.6/19.2/38.4/57.6/115.2>

2. 打開SOL功能:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) sol activate

3. 關閉SOL功能:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) sol deactivate

五、SEL日誌查看

1. 查看SEL日誌:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) sel list

六、FRU信息查看

1. 查看FRU信息:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) fru list

七、SDR,Sensor信息查看

1. 查看SDR Sensor信息:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) sdr

2. 查看Sensor信息:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) sensor list

八、mc(管理單元BMC)狀態和控制

1. 重啓動BMC:

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) mc reset <warm/cold>

九、設置BMC的iptables防火牆

1. 設置某一段IP可以訪問BMC

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) raw 0x32 0x76 0x01 0x01 ip1(0xa 0xa 0xa 0xa) ip2(0xb 0xb 0xb 0xb)

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) raw 0x32 0x76 0x09

2. 設置某個IP可以訪問BMC

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) raw 0x32 0x76 0x00 0x01 ip1(0xa 0xa 0xa 0xa)

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) raw 0x32 0x76 0x09

3. 取消設置

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) raw 0x32 0x76 0x08

4.獲取防火牆設置

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) raw 0x32 0x77 0x01 0x00

5. 阻止/開啓某個端口

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) raw 0x32 0x76 0x02 0x00/0x01 0x00 (portno)0x22 0x00

6. 取消某個端口的設置(6是5的對應取消操作)

ipmitool -H (BMC的管理IP地址) -I lanplus -U (BMC登錄用戶名) -P (BMC 登錄用戶名的密碼) raw 0x32 0x76 0x06 0x00/0x01 0x00 (portno)0x22 0x00

#service ipmi start
#ipmitool -I open shell
#### 可以直接進入本地BMC shell
#ipmitool -I lan -H -U shell
#### 輸入password,進入IPMI交互模式,當然這裏也可以把shell直接換成bmc命令 , 另外ipmitool支持端口,所以是否可以先做DNAT,然後遠程直接管理內網機器.
#### ipmitool提供的功能要比windows下ipmish提供的功能多得多,用法相對複雜一些
參考下面轉摘的文章來詳細瞭解命令
引用
Ipmitool本地監控使用命令:ipmitool –I open command,其中-I open表示使用OpenIPMI接口,command有以下項:
a) raw:發送一個原始的IPMI請求,並且打印回覆信息。
b) Lan:配置網絡(lan)信道(channel)
c) chassis :查看底盤的狀態和設置電源
d) event:向BMC發送一個已經定義的事件(event),可用於測試配置的SNMP是否成功
e) mc: 查看MC(Management Contollor)狀態和各種允許的項
f) sdr:打印傳感器倉庫中的所有監控項和從傳感器讀取到的值。
g) Sensor:打印詳細的傳感器信息。
h) Fru:打印內建的Field Replaceable Unit (FRU)信息
i) Sel: 打印 System Event Log (SEL)
j) Pef: 設置 Platform Event Filtering (PEF),事件過濾平臺用於在監控系統發現有event時候,用PEF中的策略進行事件過濾,然後看是否需要報警。
k) Sol/isol:用於配置通過串口的Lan進行監控
l) User:設置BMC中用戶的信息 。
m) Channel:設置Management Controller信道。
Ipmitool –I open sensor list命令可以獲取傳感器中的各種監測值和該值的監測閾值,包括(CPU溫度,電壓,風扇轉速,電源調製模塊溫度,電源電壓等信息)
Ipmitool –I open sensor get “CPU0Temp”可以獲取ID爲CPU0Temp監測值,CPU0Temp是sensor的ID,服務器不同,ID表示也不同。
Ipmitool –I open sensor thresh 設置ID值等於id的監測項的各種限制值。
Ipmitool –I open chassis status查看底盤狀態,其中包括了底盤電源信息,底盤工作狀態等
Ipmitool –I open chassis restart_cause查看上次系統重啓的原因
Ipmitool –I open chassis policy list 查看支持的底盤電源相關策略。
Ipmitool –I open chassis power on啓動底盤,用此命令可以遠程開機
Ipmitool –I open chassis power off關閉底盤,用此命令可以遠程開機
Ipmitool –I open chassis power reset實現硬重啓,用此命令可以遠程開機
Ipmi還可以設置系統啓動boot的設備,具體見ipmitool幫助文檔。
Ipmitool –I open mc reset 使BMC重新硬啓動
Ipmitool –I open mc info 查看BMC硬件信息
Ipmitool –I open mc getenables 列出BMC所有允許的選項
Ipmitool –I open mc setenables =[on|off],設置bmc相應的允許/禁止選項。
Ipmitool-I open event 1 發送一個溫度過高的消息到System Event Log中,可以發送的Event有:
1 Temperature: Upper Critical: Going High
2 Voltage Threshold: Lower Critical: Going Low
3 Memory: Correctable ECC Error Detected
Ipmitool-I open event命令可以用測試配置的IPMI中的snmp功能是否成功。
Ipmitool -I open lan print 1 打印現咱channel 1的信息 。
Ipmitool -I open lan set 1 ipaddr 10.10.113.95設置channel 1 的地址爲10.10.113.95
Ipmitool -I open lan set 1 snmp public設置channel 1 上snmp的community爲public。
Ipmitool -I open lan set 1 access on設置channel 1允許訪問。
Ipmitool -I open pef info打印Platform Event Filtering (pef)信息
Ipmitool -I open pef status查看Platform Event Filtering (pef)狀態
Ipmitool -I open pef policy查看Platform Event Filtering (pef)策略設置
Ipmitool -I open sdr list fru 讀取fru信息並顯示。

 

[root@localhost ~]# yum install -y ipmitool #安裝這個包

 

電源相關:

 

#開啓電源

ipmitool -I lanplus -H 10.41.1.41 -U root -P root power on

 

#關閉電源

ipmitool -I lanplus -H 10.41.1.41 -U root -P root power off

 

#重啓電源

ipmitool -I lanplus -H 10.41.1.41 -U root -P root power reset

 

#查看電源狀態

ipmitool -I lanplus -H 10.41.1.41 -U root -P root power status

 

啓動項相關:

 

#設置爲BIOS啓動

ipmitool -I lanplus -H 10.41.1.41 -U root -P root chassis bootparam set bootflag force_bios

 

#設置爲pxe啓動

 

ipmitool -I lanplus -H 10.41.1.41 -U root -P root chassis bootparam set bootflag force_pxe

 

#設置爲光盤啓動

ipmitool -I lanplus -H 10.41.1.41 -U root -P root chassis bootparam set bootflag force_cdrom

 

#設置爲硬盤啓動

ipmitool -I lanplus -H 10.41.1.41 -U root -P root chassis bootparam set bootflag force_disk

 

#重啓BMC

ipmitool -I lanplus -H 10.41.1.41 -U root -P root mc reset cold

 

#修改BMC密碼

ipmitool -I lanplus -H 10.41.1.41 -U root -P root user set password 2 new_password #new_password 這個是新密碼

 

#遠程文本重定向 重啓服務器就能看到畫面

ipmitool -I lanplus-H 10.41.1.41 -U root -P root sol activate

 

#當有這個錯誤時 Info: SOL payload already active on another session

ipmitool -I lanplus-H 10.41.1.41 -U root -P root sol deactivate #這命令是踢出其他的人會話

 

#獲取mac地址 有些機型不準 我這個是dell的服務器 華爲服務器也可以使用

"""ipmitool -I lanplus -H 10.41.1.41 -U root -P root lan print |grep "MAC Address"|awk '{print $NF}'"""

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章