[Lxc-users] How are pseudorandom MACs selected?

Nirmal Guhan vavatutu at gmail.com
Sat Feb 5 06:29:58 UTC 2011


On Wed, Feb 2, 2011 at 6:25 PM, Trent W. Buck <twb at cybersource.com.au> wrote:
> "Brian K. White" <brian at aljex.com> writes:
>
>> I just use 02:00:<ip address> which ends up being automatically unique
>> enough to not collide with anything else on your subnet assuming you
>> already know the ip's you want to use
>>
>> IP=192.168.0.50   # container nic IP
>> HA=`printf "02:00:%x:%x:%x:%x" ${IP//./ }` # generate a MAC from the IP
>
> I think I'll adopt a slight variation of this -- computing the MAC from
> the hostname, which are guaranteed by my site policy to be [a-z]{5}.
> Where 06 is an arbitrarily chosen local unicast range,
>
>    $ f () { python -c "print '06%010x' % int('$(LC_ALL=C tr <<<"$1" a-z 0-9a-p)',26)"; }
>    $ f zorba
>    060000b240be
>
> This allows my DHCP server to continue mapping MAC->IP, while actually
> getting it from a hostname (which policy says won't change).
>
> And I'll do this for all my containers, so that even containers that
> have automatically assigned IPs will be relatively persistent (because
> dnsmasq remembers MAC->IP leases and re-uses them preferentially).

Provided container's hostname are unique across different hosts?

~nirmal
>
>
> ------------------------------------------------------------------------------
> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
> Finally, a world-class log management solution at an even better price-free!
> Download using promo code Free_Logger_4_Dev2Dev. Offer expires
> February 28th, so secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsight-sfd2d
> _______________________________________________
> Lxc-users mailing list
> Lxc-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-users
>




More information about the lxc-users mailing list