Hi, I like Xen''s feature of autogenerating those values if they are not supplied in a config file, but for sake of persistency I want to inherit the once-generated values and reuse them after the first creation of a domU. I found it possible to query the values at runtime using xm list --long but I''m not sure I''m going the most elegant route with that, it would mean either wrapping around xm create or hacking a script to be executed after domU creation to edit the configfile. This sounds messy to me. How are You handling this? Thanks! Florian -- ''Sie brauchen sich um Ihre Zukunft keine Gedanken zu machen'' _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
On Sun, 2007-02-18 at 04:09 +0100, Florian Heigl wrote:> Hi, > > I like Xen''s feature of autogenerating those values if they are not supplied in > a config file, but for sake of persistency I want to inherit the once-generated > values and reuse them after the first creation of a domU. > > I found it possible to query the values at runtime using xm list > --long but I''m not sure I''m going the most elegant route with that, it > would mean either wrapping around xm create or hacking a script to be > executed after domU creation to edit the configfile. This sounds messy > to me. > > How are You handling this? > > Thanks! > Florian >I use the following shell function to generate macs. The following is my own code which I''m hereby donating to the public domain. It may be used for any purpose without credit to the author. This code is not copyrighted and comes with no warranty. # Sets a global _MAC , usage : # makemac # echo ${_MAC} makemac() { local prefix="00:00:6d" local hextet[3]="" local hextet[4]="" local hextet[5]="" local tmp="" local i=3; local digi=''0a1b2c3d4e5f6789h'' local offset=$((${#digi} - 1)) _MAC="$prefix" while [ "$i" -le 5 ]; do tmp[1]="${digi:$(($RANDOM%${offset})):1}" tmp[2]="${digi:$(($RANDOM%${offset})):1}" hextet[$i]="${tmp[1]}${tmp[2]}" _MAC="${_MAC}:${hextet[i]}" let "i += 1" done unset octet unset tmp unset prefix unset i } Change $prefix to match what you want, I believe that is the prefix Xen was granted to indicate a ''virtual'' nic. This should be used when creating the guest, so that it keeps its mac. Hope this helps. Best, --Tim _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Kraska, Joe A \(US SSA\)
2007-Feb-19 16:44 UTC
RE: [Xen-users] handling mac addresses and guid''s
Xen''s allocated OUI "prefix" is 00:16:3e There are probably lots of prefixes that will work insofar as you can be sure that you know your LAN. Myself, I''d recommend keeping a master table somewhere and incrementally choosing from MAC addresses for the last tuple, particularly if the deployment is large. One might mutate this code a little to do that rather than pick a random number. Joe.> -----Original Message----- > From: xen-users-bounces@lists.xensource.com [mailto:xen-users- > bounces@lists.xensource.com] On Behalf Of Tim Post > Sent: Sunday, February 18, 2007 5:36 PM > To: Florian Heigl > Cc: xen-users@lists.xensource.com > Subject: Re: [Xen-users] handling mac addresses and guid''s > > On Sun, 2007-02-18 at 04:09 +0100, Florian Heigl wrote: > > Hi, > > > > I like Xen''s feature of autogenerating those values if they are notsupplied> in > > a config file, but for sake of persistency I want to inherit theonce-> generated > > values and reuse them after the first creation of a domU. > > > > I found it possible to query the values at runtime using xm list > > --long but I''m not sure I''m going the most elegant route with that,it> > would mean either wrapping around xm create or hacking a script tobe> > executed after domU creation to edit the configfile. This soundsmessy> > to me. > > > > How are You handling this? > > > > Thanks! > > Florian > > > > I use the following shell function to generate macs. The following ismy> own code which I''m hereby donating to the public domain. It may beused> for any purpose without credit to the author. This code is not > copyrighted and comes with no warranty. > > # Sets a global _MAC , usage : > # makemac > # echo ${_MAC} > > makemac() > { > local prefix="00:00:6d" > local hextet[3]="" > local hextet[4]="" > local hextet[5]="" > local tmp="" > local i=3; > local digi=''0a1b2c3d4e5f6789h'' > local offset=$((${#digi} - 1)) > > _MAC="$prefix" > > while [ "$i" -le 5 ]; do > tmp[1]="${digi:$(($RANDOM%${offset})):1}" > tmp[2]="${digi:$(($RANDOM%${offset})):1}" > hextet[$i]="${tmp[1]}${tmp[2]}" > _MAC="${_MAC}:${hextet[i]}" > let "i += 1" > done > > unset octet > unset tmp > unset prefix > unset i > } > > Change $prefix to match what you want, I believe that is the prefixXen> was granted to indicate a ''virtual'' nic. > > This should be used when creating the guest, so that it keeps its mac. > > Hope this helps. > > Best, > --Tim > > > _______________________________________________ > Xen-users mailing list > Xen-users@lists.xensource.com > http://lists.xensource.com/xen-users_______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
On Mon, 2007-02-19 at 08:44 -0800, Kraska, Joe A (US SSA) wrote:> Xen''s allocated OUI "prefix" is 00:16:3eNoted.> > There are probably lots of prefixes that will work insofar as you can be > sure that you know your LAN.I''ve never had any not work, but its good form and practice to either clone the manufacturer prefix of the ported ethernet device, or use Xen''s.> Myself, I''d recommend keeping a master table somewhere and incrementally > choosing from MAC addresses for the last tuple, particularly if the > deployment is large. One might mutate this code a little to do that > rather than pick a random number.Most web based DHCP ''helpers'' will do this for you, however the original poster noted he liked the random-ness of how Xen does it, just need to know what the random mac will be prior to the dom-u getting it so that it can be saved and applied to the guest again. Looks like he just wants to avoid ARP lag upstream every time a guest is rebooted and gets a new mac. Its been years since I looked at Webmin, but I think they had the foundations of a nice DHCP control system when I last saw it. I can only imagine that since that time its progressed to something rather useful, worth checking out anyway. A central table is the best way to go, and I should also note you should at least keep a list of macs in use if going random so that (however unlikely) the same mac is not put in use twice. This really doesn''t effect much unless using something like AoE, but still good to follow proper form.> > Joe. >Best, --Tim> > -----Original Message----- > > From: xen-users-bounces@lists.xensource.com [mailto:xen-users- > > bounces@lists.xensource.com] On Behalf Of Tim Post > > Sent: Sunday, February 18, 2007 5:36 PM > > To: Florian Heigl > > Cc: xen-users@lists.xensource.com > > Subject: Re: [Xen-users] handling mac addresses and guid''s > > > > On Sun, 2007-02-18 at 04:09 +0100, Florian Heigl wrote: > > > Hi, > > > > > > I like Xen''s feature of autogenerating those values if they are not > supplied > > in > > > a config file, but for sake of persistency I want to inherit the > once- > > generated > > > values and reuse them after the first creation of a domU. > > > > > > I found it possible to query the values at runtime using xm list > > > --long but I''m not sure I''m going the most elegant route with that, > it > > > would mean either wrapping around xm create or hacking a script to > be > > > executed after domU creation to edit the configfile. This sounds > messy > > > to me. > > > > > > How are You handling this? > > > > > > Thanks! > > > Florian > > > > > > > I use the following shell function to generate macs. The following is > my > > own code which I''m hereby donating to the public domain. It may be > used > > for any purpose without credit to the author. This code is not > > copyrighted and comes with no warranty. > > > > # Sets a global _MAC , usage : > > # makemac > > # echo ${_MAC} > > > > makemac() > > { > > local prefix="00:00:6d" > > local hextet[3]="" > > local hextet[4]="" > > local hextet[5]="" > > local tmp="" > > local i=3; > > local digi=''0a1b2c3d4e5f6789h'' > > local offset=$((${#digi} - 1)) > > > > _MAC="$prefix" > > > > while [ "$i" -le 5 ]; do > > tmp[1]="${digi:$(($RANDOM%${offset})):1}" > > tmp[2]="${digi:$(($RANDOM%${offset})):1}" > > hextet[$i]="${tmp[1]}${tmp[2]}" > > _MAC="${_MAC}:${hextet[i]}" > > let "i += 1" > > done > > > > unset octet > > unset tmp > > unset prefix > > unset i > > } > > > > Change $prefix to match what you want, I believe that is the prefix > Xen > > was granted to indicate a ''virtual'' nic. > > > > This should be used when creating the guest, so that it keeps its mac. > > > > Hope this helps. > > > > Best, > > --Tim > > > > > > _______________________________________________ > > Xen-users mailing list > > Xen-users@lists.xensource.com > > http://lists.xensource.com/xen-users > > > _______________________________________________ > Xen-users mailing list > Xen-users@lists.xensource.com > http://lists.xensource.com/xen-users_______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users