virtual-vxlan/utils.go
2025-01-05 22:22:24 -06:00

21 lines
372 B
Go

package main
import (
"crypto/rand"
"net"
)
// Generate an random MAC in the locally administered OUI.
func generateRandomMAC() net.HardwareAddr {
// Start a new MAC address.
mac := make(net.HardwareAddr, 6)
// Just replace all bytes in MAC with random bytes.
rand.Read(mac)
// Set OUI to locally administered space.
mac[0] = 0x0a
mac[1] = 0x00
return mac
}