[GH-ISSUE #473] Clone - new MAC #354

Closed
opened 2026-02-27 16:38:58 +03:00 by kerem · 7 comments
Owner

Originally created by @aafanasyev on GitHub (Nov 12, 2014).
Original GitHub issue: https://github.com/retspen/webvirtmgr/issues/473

I using webvirtmgr for couple of days and found some missing future.
Mostly I create a base image and later I clone it to a test/production image. Like this:

US14.04LTSbase - Base server image

clone<
srv10.dot.lan - Samba DC image

However, during cloning, if I use bridge mode, I need to create a new MAC address randomly. According this doc:
http://www.linux-kvm.org/page/Networking

I do it like this:

Generate a MAC address, either manually or using: 
#!/bin/bash
# generate a random mac address for the qemu nic
printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))

It will be much user friendly if I can create it immediately in interface just like in Virtual Box:
New random MAC address

Thank you.

Originally created by @aafanasyev on GitHub (Nov 12, 2014). Original GitHub issue: https://github.com/retspen/webvirtmgr/issues/473 I using webvirtmgr for couple of days and found some missing future. Mostly I create a base image and later I clone it to a test/production image. Like this: US14.04LTSbase - Base server image > clone< > srv10.dot.lan - Samba DC image However, during cloning, if I use bridge mode, I need to create a new MAC address randomly. According this doc: http://www.linux-kvm.org/page/Networking I do it like this: ``` Generate a MAC address, either manually or using: #!/bin/bash # generate a random mac address for the qemu nic printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256)) ``` It will be much user friendly if I can create it immediately in interface just like in Virtual Box: ![New random MAC address](http://www.lab128.com/rac_installation_using_vb/vb_adapter_mac_address.png) Thank you.
kerem closed this issue 2026-02-27 16:38:58 +03:00
Author
Owner

@aafanasyev commented on GitHub (Nov 12, 2014):

A bit of research leads me to:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/sect-Virtualization-Tips_and_tricks-Generating_a_new_unique_MAC_address.html

And this code:

#!/usr/bin/python
# macgen.py script to generate a MAC address for guest virtual machines
#
import random
#
def randomMAC():
    mac = [ 0x00, 0x16, 0x3e,
        random.randint(0x00, 0x7f),
        random.randint(0x00, 0xff),
        random.randint(0x00, 0xff) ]
    return ':'.join(map(lambda x: "%02x" % x, mac))
#
print randomMAC()

I hope it will be useful...

<!-- gh-comment-id:62709367 --> @aafanasyev commented on GitHub (Nov 12, 2014): A bit of research leads me to: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/sect-Virtualization-Tips_and_tricks-Generating_a_new_unique_MAC_address.html And this code: ``` #!/usr/bin/python # macgen.py script to generate a MAC address for guest virtual machines # import random # def randomMAC(): mac = [ 0x00, 0x16, 0x3e, random.randint(0x00, 0x7f), random.randint(0x00, 0xff), random.randint(0x00, 0xff) ] return ':'.join(map(lambda x: "%02x" % x, mac)) # print randomMAC() ``` I hope it will be useful...
Author
Owner

@daniviga commented on GitHub (Nov 12, 2014):

WebVirtMgr already generates a random MAC address when you clone an image using its interface.

<!-- gh-comment-id:62709847 --> @daniviga commented on GitHub (Nov 12, 2014): WebVirtMgr already generates a random MAC address when you clone an image using its interface.
Author
Owner

@aafanasyev commented on GitHub (Nov 12, 2014):

Strange I am getting always the same mac in a bridge mode:
52:54:00:18:5f:c4

<!-- gh-comment-id:62710151 --> @aafanasyev commented on GitHub (Nov 12, 2014): Strange I am getting always the same mac in a bridge mode: 52:54:00:18:5f:c4
Author
Owner

@daniviga commented on GitHub (Nov 12, 2014):

Yes, sorry you're right!

<!-- gh-comment-id:62710292 --> @daniviga commented on GitHub (Nov 12, 2014): Yes, sorry you're right!
Author
Owner

@aafanasyev commented on GitHub (Nov 12, 2014):

No problem :) webvirtmgr is very promising peace of software, but it miss a lot of useful futures of kvm,
Like dynamic HDD, IPtables management, Securing the web interface (I mentioned it ones) and etc...

<!-- gh-comment-id:62711265 --> @aafanasyev commented on GitHub (Nov 12, 2014): No problem :) webvirtmgr is very promising peace of software, but it miss a lot of useful futures of kvm, Like dynamic HDD, IPtables management, Securing the web interface (I mentioned it ones) and etc...
Author
Owner

@daniviga commented on GitHub (Nov 14, 2014):

See https://github.com/retspen/webvirtmgr/pull/474

<!-- gh-comment-id:63076624 --> @daniviga commented on GitHub (Nov 14, 2014): See https://github.com/retspen/webvirtmgr/pull/474
Author
Owner

@aafanasyev commented on GitHub (Nov 14, 2014):

Thanks It looks nice I just put a small comment... Maybe it will be useful.

<!-- gh-comment-id:63078165 --> @aafanasyev commented on GitHub (Nov 14, 2014): Thanks It looks nice I just put a small comment... Maybe it will be useful.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/webvirtmgr#354
No description provided.