Hi, i have tried to find an rfc about this but have failed, instead, the only (serious/credible) documentation i could find was http://wiki.xen.org/xenwiki/XenNetworking#head-d5446face7e308f577e5aee1c72cf9d156903722 , so i updated the script accordingly, here is the updated patch. again, Signed-off-by: John Soros <joh...@r0x0r.me>
-- the router thinks its a printer. On Fri, 25 Feb 2011 09:03:55 +0100 Jäkel, Guido <g.jae...@dnb.de> wrote: > Dear John, > > > - generate random mac address for the guest so it gets always the > > same lease from a dhcp server > > You suggest doing this by > > macaddr=$(echo -n 00; hexdump -n 5 -v -e '/1 > ":%02X"' /dev/urandom) > > > > I think this is a "little bit to random". The german Wikipedia tells > at http://de.wikipedia.org/wiki/MAC-Adresse about a reserved MAC > range for private use (sorry, it's not in corresponding the English > article): > > ["Neben der OUI existiert auch ein kleiner Adressbereich (IAB > - Individual Address Block), der für Privatpersonen und kleine Firmen > und Organisationen vorgesehen ist, die nicht so viele Adressen > benötigen. Die Adresse beginnt mit 00-50-C2 und wird von drei > weiteren Hex-Ziffern gefolgt (12 Bits), die für jede Organisation > vergeben werden. Damit verbleibt der Adressbereich innerhalb der Bits > 11 bis 0 nutzbar wodurch 212 = 4096 individuelle Adressen möglich > sind."] > > > > Maybe we should take respect to this and we should use > > macaddr=$(echo -n "00:50:C2"; hexdump -n 3 -v -e '/1 > ":%02X"' /dev/urandom) > > for this. Another approach is to derive it from the designated name > of the container (i.e. $hostname in terms of the script). Because > there might be typical clustering naming schemes based on a name and > some digits, I suggest to select the first and the last two > characters of the hostname (filled by random for the unlikely case of > a hostname shorter than 3 chars) > > echo -n "00:50:C2"; echo "${hostname:0:1}${hostname: -2} > $(head -c 3 /dev/urandom) " | hexdump -n 3 -v -e '/1 ":%02X"' > > -> 00:50:C2:<first>:<nextlast>:<last> filled by random > > > > @Daniel: Because this will have a common use for all, it might be > included into the lxc-conf parser > > ["lxc.network.hwaddr: the interface mac address is > dynamically allocated by default to the virtual interface ...]" > > > We maybe should have a special keyword for a "derived" semi-static > MAC that would not change at every startup of the container but may > be calculated by the formula given above. > > > Guido > > > ------------------------------------------------------------------------------ > Free Software Download: Index, Search & Analyze Logs and other IT > data in Real-Time with Splunk. Collect, index and harness all the > fast moving IT data generated by your applications, servers and > devices whether physical, virtual or in the cloud. Deliver compliance > at lower cost and gain new business insights. > http://p.sf.net/sfu/splunk-dev2dev > _______________________________________________ Lxc-users mailing list > Lxc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/lxc-users
--- /usr/lib/lxc/templates/lxc-debian 2010-08-04 19:27:58.000000000 +0200 +++ lxc-debian 2011-03-01 18:15:12.895043450 +0100 @@ -66,10 +66,10 @@ # reconfigure some services if [ -z "$LANG" ]; then chroot $rootfs locale-gen en_US.UTF-8 - chroot $rootfs update-locale LANG=en_US.UTF-8 + chroot $rootfs update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 else chroot $rootfs locale-gen $LANG - chroot $rootfs update-locale LANG=$LANG + chroot $rootfs update-locale LANG=$LANG LC_ALL=$LANG fi # remove pointless services in a container @@ -77,6 +77,12 @@ chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh remove chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh remove + # do some adjustment for the final image + mknod -m 666 $rootfs/dev/tty1 c 4 1 + mknod -m 666 $rootfs/dev/tty2 c 4 2 + mknod -m 666 $rootfs/dev/tty3 c 4 3 + mknod -m 666 $rootfs/dev/tty4 c 4 4 + echo "root:root" | chroot $rootfs chpasswd echo "Root password is 'root', please change !" @@ -90,7 +96,7 @@ locales,\ libui-dialog-perl,\ dialog,\ -dhcp-client,\ +isc-dhcp-client,\ netbase,\ net-tools,\ iproute,\ @@ -110,7 +116,7 @@ echo "Downloading debian minimal ..." debootstrap --verbose --variant=minbase --arch=$arch \ --include $packages \ - lenny $cache/partial-$arch http://ftp.debian.org/debian + squeeze $cache/partial-$arch http://ftp.debian.org/debian if [ $? -ne 0 ]; then echo "Failed to download the rootfs, aborting." return 1 @@ -130,13 +136,13 @@ # make a local copy of the minidebian echo -n "Copying rootfs to $rootfs..." - cp -a $cache/rootfs-$arch $rootfs || return 1 + cp -a $cache/rootfs-$arch/* $rootfs || return 1 return 0 } install_debian() { - cache="/var/cache/lxc/debian" + cache="/var/cache/lxc/debian-squeeze" rootfs=$1 mkdir -p /var/lock/subsys/ ( @@ -182,8 +188,19 @@ path=$1 rootfs=$2 name=$3 + rndbit="" + while [[ $rndbit != "2" && $rndbit != "6" && $rndbit != "A" && $rndbit != "E" ]]; do + rndbit="$(hexdump -n 1 -v -e '/1 "%02X"' /dev/urandom |sed 's,^.,,g' |tr -d '\n')" + done + macaddr=$(echo -n "0${rndbit}"; hexdump -n 5 -v -e '/1 ":%02X"' /dev/urandom) cat <<EOF >> $path/config +lxc.network.type = veth +lxc.network.flags = up +lxc.network.link = br0 +lxc.network.ipv4 = 0.0.0.0 +lxc.network.hwaddr = $macaddr + lxc.tty = 4 lxc.pts = 1024 lxc.rootfs = $rootfs @@ -220,7 +237,7 @@ clean() { - cache="/var/cache/lxc/debian" + cache="/var/cache/lxc/debian-squeeze" if [ ! -e $cache ]; then exit 0 @@ -244,7 +261,7 @@ usage() { cat <<EOF -$1 -h|--help -p|--path=<path> --clean +$1 -h|--help -p|--path=<path> -n|--name=<hostname> --clean EOF return 0 } @@ -268,6 +285,12 @@ esac done +if [ -z $name ]; then + echo "No name given" + usage $0 + exit 1 +fi + if [ ! -z "$clean" -a -z "$path" ]; then clean || exit 1 exit 0
------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________ Lxc-users mailing list Lxc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-users