Skip to content

Instantly share code, notes, and snippets.

@ncode
Forked from ebraminio/MacFromIPMI.go
Created June 19, 2017 19:06
Show Gist options
  • Save ncode/a77dbfd4fc1bea8b67d0d0a40ce19c12 to your computer and use it in GitHub Desktop.
Save ncode/a77dbfd4fc1bea8b67d0d0a40ce19c12 to your computer and use it in GitHub Desktop.
// https://gist.github.com/DavidWittman/b7a509632ed92fccf237 (SuperMicro)
package main
import (
"fmt"
"net"
"github.com/vmware/goipmi"
)
type macAddrResponse struct {
ipmi.CompletionCode
_ [4]byte
Mac [6]byte
}
func main() {
ipmiReq := &ipmi.Request{
NetworkFunction: ipmi.NetworkFunction(0x30),
Command: ipmi.Command(0x21),
Data: []byte{},
}
ipmiRes := &macAddrResponse{}
conn := &ipmi.Connection{
Hostname: "IP",
Port: 623,
Username: "USER",
Password: "PASS",
Interface: "lanplus",
}
client, err := ipmi.NewClient(conn)
if err != nil {
fmt.Println(err)
return
}
err = client.Send(ipmiReq, ipmiRes)
if err != nil {
fmt.Println(err)
return
}
var mac net.HardwareAddr
mac = ipmiRes.Mac[:]
fmt.Println(mac.String())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment