Static MAC Generator for KVM

The following line will generate (pseudo-randomly) a static MAC address, suitable for use with a KVM virtual machine;

date +%s | md5sum | head -c 6 | sed -e 's/\([0-9A-Fa-f]\{2\}\)/\1:/g' -e 's/\(.*\):$/\1/' | sed -e 's/^/52:54:00:/'

Similar nonsense can be done with Hyper-V and VMware.

One thought on “Static MAC Generator for KVM”

  1. If you intend to generate more than one mac in a script, the problem will be that date+%s will generate the same mac. To circumvent this issue, use date +%s%N (nanoseconds).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.