Skip to contentSkip to conversation

default mac address issue

RFC Bruce Rogers 3 participants 4 messages May 10, 2010 – May 11, 2010

lore
Share & tools
lore
#0 lore raw

I know this behavior has worked this way all along, but I wanted to bring up the following concern and float a few ideas about possible solutions. Please provide your perspective, opinion, etc.

qemu (or qemu-kvm) users can easily get into trouble when they don't specifying the mac address for their vm's nic and don't realize that multiple vm's running this way on the same network segment are colliding, since they all get a default mac address that is the same. They may be under the assumption that a random mac would be the default, as in many higher level tools for vm creation.

Does it make sense to do any of the following:

1) have qemu print a warning to stdout/stderr that the default mac address is being used and that it will interfere with other vms running the same way on a common network segment

2) what about changing the default behavior to randomizing the mac, and provide the legacy behavior with "-net nic,macaddr=default" or just "-use-default-mac"

(or, as a flip side to #2):

3) to at least make it easy for people to get around the problem, and just
use qem directly (without additional tools to launch qemu), add an option such as "-net nic,macaddr=randomize" or "-use-random-mac" which randomizes the mac for you each time the machine is brought up, and hence avoids possible collisions.

Of course having the same vm come up with a different mac each time is an issue for some guest os's, but for some usages, that is not a problem.

I imagine the concensus would be that the current behavior is appropriate, and it's up to management tools to do the randomization, but I think there is perhaps a place for randomization within qemu itself. I'm interested to hear what you think.

Bruce

#1 lore raw

Hi Bruce,

Quoted 4 lines · Bruce Rogers

I know this behavior has worked this way all along, but I wanted to bring up the following concern and float a few ideas about possible solutions. Please provide your perspective, opinion, etc.

qemu (or qemu-kvm) users can easily get into trouble when they don't specifying the mac address for their vm's nic and don't realize that multiple vm's running this way on the same network segment are colliding, since they all get a default mac address that is the same. They may be under the assumption that a random mac would be the default, as in many higher level tools for vm creation

This is certainly an important issue but it's one that's difficult to resolve.

Quoted 4 lines

Does it make sense to do any of the following:

1) have qemu print a warning to stdout/stderr that the default mac address is being used and that it will interfere with other vms running the same way on a common network segment

This is definitely reasonable.

Quoted 8 lines

2) what about changing the default behavior to randomizing the mac, and provide the legacy behavior with "-net nic,macaddr=default" or just "-use-default-mac"

(or, as a flip side to #2):

3) to at least make it easy for people to get around the problem, and just
use qem directly (without additional tools to launch qemu), add an option such as "-net nic,macaddr=randomize" or "-use-random-mac" which randomizes the mac for you each time the machine is brought up, and hence avoids possible collisions.

A random mac address is almost always wrong. If you run a guest twice with this option, it's usually enough to trigger a new network detection which which rename the network device to ethN + 1. The result would be broken networking for naive users since distros don't bother configuring interfaces that weren't present during installation.

Regards,

Anthony Liguori

Quoted 9 lines

Of course having the same vm come up with a different mac each time is an issue for some guest os's, but for some usages, that is not a problem.

I imagine the concensus would be that the current behavior is appropriate, and it's up to management tools to do the randomization, but I think there is perhaps a place for randomization within qemu itself. I'm interested to hear what you think.

Bruce

#2 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line · Anthony Liguori

...

Quoted 6 lines
Quoted 1 line

1) have qemu print a warning to stdout/stderr that the default mac address

is being used and that it will interfere with other vms running the same way on a common network segment

Quoted 1 line

This is definitely reasonable.

I'll cook up a patch then. Thanks for the feedback.

Bruce

#3 lore raw
In reply to Anthony Liguori
Quoted 40 lines · Anthony Liguori

Hi Bruce,

Quoted 11 lines · Bruce Rogers

I know this behavior has worked this way all along, but I wanted to bring up the following concern and float a few ideas about possible solutions. Please provide your perspective, opinion, etc.

qemu (or qemu-kvm) users can easily get into trouble when they don't specifying the mac address for their vm's nic and don't realize that multiple vm's running this way on the same network segment are colliding, since they all get a default mac address that is the same. They may be under the assumption that a random mac would be the default, as in many higher level tools for vm creation

This is certainly an important issue but it's one that's difficult to resolve.

Quoted 6 lines

Does it make sense to do any of the following:

1) have qemu print a warning to stdout/stderr that the default mac address is being used and that it will interfere with other vms running the same way on a common network segment

This is definitely reasonable.

Quoted 4 lines

2) what about changing the default behavior to randomizing the mac, and provide the legacy behavior with "-net nic,macaddr=default" or just "-use-default-mac"

Quoted 8 lines

(or, as a flip side to #2):

3) to at least make it easy for people to get around the problem, and just use qem directly (without additional tools to launch qemu), add an option such as "-net nic,macaddr=randomize" or "-use-random-mac" which randomizes the mac for you
each time the machine is brought up, and hence avoids possible collisions.

Quoted 5 lines

A random mac address is almost always wrong. If you run a guest twice with this option, it's usually enough to trigger a new network detection which which rename the network device to ethN + 1. The result would be broken networking for naive users since distros don't bother configuring interfaces that weren't present during installation.

Yes, I've seen this when moving disk images between (real) motherboards. In the good old days it Just Worked.

Now, current distros using udev remember the MAC from the old board, so the new board gets an interface called "eth1" instead of "eth0".

That's fine, but rather stupidly they've configured a useful default for "eth0" which is DHCP, but the default for "eth1" etc. is to leave it down. Result: Disk moved to a replacement motherboard, and the machine no longer responds to network connections. Quite annoying if it's a headless box, or one which boots up as a kiosk or something with no console access.

Anyway, Anthony's right: Changing the MAC address of a guest each time it is run (with the same disk image) is likely to be annoying.

It might be a good idea to store the chosen MAC in the qcow2 metadata, if qcow2 is used?

For my Perl-managed qemu/kvm VMs, I find I need a small config file, and a small state file which records run time state that survives reboots (like the MAC address, and things like which CD and floppy images were loaded).

(Perhaps in the search for a holy grail of a qemu config file format, it might also be worth a mention that it's handy to store non-config state somewhere too.)

-- Jamie