Package: xen-tools
Version: 4.5-1
Severity: normal
Tags: patch
xen-create-image derives its generated MAC addresses from the hostname, IP
address configuration and distribution of the domU to be installed (see: sub
generateMACAddress). This behavior leads to a MAC address collisions when
multiple domU's with the same configuration and hostname are created on the
same network on different dom0's.
I've written a patch to add an option (--randommac) to generate a random MAC.
-- System Information:
Debian Release: 8.7
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_CH.UTF-8, LC_CTYPE=de_CH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages xen-tools depends on:
ii debootstrap 1.0.67
ii libconfig-inifiles-perl 2.83-3
ii libdata-validate-domain-perl 0.10-1
ii libdata-validate-ip-perl 0.24-1
ii libdata-validate-uri-perl 0.06-1
ii libfile-slurp-perl 9999.19-4
ii libfile-which-perl 1.09-1
ii libterm-ui-perl 0.42-1
ii libtext-template-perl 1.46-1
ii openssh-client 1:6.7p1-5+deb8u3
ii perl 5.20.2-3+deb8u6
Versions of packages xen-tools recommends:
ii libexpect-perl 1.21-1
ii rinse 3.0.9
ii xen-hypervisor-4.4-amd64 [xen-hypervisor-amd64] 4.4.1-9+deb8u8
ii xen-utils-4.4 [xen-utils] 4.4.1-9+deb8u8
Versions of packages xen-tools suggests:
pn btrfs-tools <none>
pn cfengine2 <none>
pn reiserfsprogs <none>
pn xfsprogs <none>
-- no debconf information
302a303,304
>
> --randommac Creates random MAC address
1569a1572
> "randommac", \$CONFIG{ 'randommac' },
2026a2030
> # If randommac is specified, generate random MAC.
2030,2031c2034,2042
< $CONFIG{ 'mac' } = generateMACAddress();
< }
---
> if ( $CONFIG{ 'randommac' } )
> {
> $CONFIG{ 'mac' } = generateRandomMACAddress();
> }
> else
> {
> $CONFIG{ 'mac' } = generateMACAddress();
> }
> }
2134a2146,2156
> =begin doc
>
> Generate a MAC address based on the Xen prefix and a random local part
>
> =end doc
>
> =cut
>
>
> sub generateRandomMACAddress
> {
2135a2158,2172
> #
> # Start with the xen prefix
> #
> my $mac = '00:16:3E';
>
> #
> # Generate random local part and append to $mac
> #
> for ( my $count=0; $count < 3; $count++ )
> {
> $mac = $mac . ":" . sprintf("%02X", int(rand(255)));
> }
>
> return ( $mac );
> }