DHCP for specific range of mac addresses?

Discussion in 'Linux Networking' started by Tom Horsley, Feb 17, 2008.

  1. Tom Horsley

    Tom Horsley Guest

    I'd like to run a dhcp server that will only respond to dhcp
    requests from the virtual machines on my xen server box
    (all of which use 00:16:3e as a mac address prefix).

    This seemed like such a simple idea till I started reading
    the dhcpd.conf man page :).

    I see a dhcp-eval man page, I see a "hardware" operator, and
    then I run out of pointers. What the heck does the string
    generated by "hardware" look like? I can't find an example
    anywhere, so I can't tell what to look for in it to match
    only my virtual machines.

    Anyone know what "hardware" generates? Anyone have an example
    of already doing something like this?

    Thanks for any info you can provide...
     
    Tom Horsley, Feb 17, 2008
    #1
    1. Advertisements

  2. here is a section of my dhcpd.conf file where I assign IPs to my tivos
    based on their hardware / mac address. The hardware address is just a
    mac address.



    host tivodev {
    # FA120
    hardware ethernet 00:0f:b5:84:d0:23;
    fixed-address tivodev.private.net;
    }

    host tivoa {
    # FA120
    hardware ethernet 00:09:5b:e3:76:eb;
    #tivonet
    #hardware ethernet 00:0B:AD:77:68:43;
    fixed-address tivoa.private.net;
    }

    host tivob {
    # usb200m
    #hardware ethernet 00:10:60:25:f5:d1;
    hardware ethernet 00:12:0E:02:C7:6B;
    fixed-address tivob.private.net;
    }


    I don't know how to specify a hardware range... just individual mac
    addresses....

    why not hardcode your xen mac address in the xen profile and then use
    those same mac addresses in your dhcpd.conf file. That's what I do for
    my vmware stuff. I set the mac address on the virtual interface to
    something that I know what it is and put that in my dhcpd.conf file.

    --
    D.A.M. - Mothers Against Dyslexia

    see http://www.jacksnodgrass.com for my contact info.

    jack - Grapevine/Richardson
     
    Jack Snodgrass, Feb 17, 2008
    #2
    1. Advertisements

  3. Tom Horsley

    Tom Horsley Guest

    Because I have a lot more virtual machines than IP addrs, so I
    want to randomly assign them from a pool, but I don't want
    some unsuspecting person in the lab genning some real machine to
    wind up grabbing one of my virtual machine IPs from my dhcp
    server :).

    After much poking around, I found the "log" statement, which allowed
    me to experiment with the "hardware" statement, which finally allowed
    me to determine that the "hardware" "string" is binary data with a
    binary 1 byte if it is ethernet followed by the 6 bytes of the mac
    address, so with sufficient diddling around and use of the
    binary-to-ascii function, I think I'll be able to define an if
    expression that will restrict my server to responding only to
    my virtual machines, then I can hand out IPs from a random pool.

    Now I gotta go figure out how to hand out random host names
    as well as random IP addrs (but keep the same host with the
    same IP all the time to make ssh happy). Maybe I can derive
    the host name from the IP that gets assigned? I'll have to
    poke around more...
     
    Tom Horsley, Feb 17, 2008
    #3
  4. Tom Horsley

    Tom Horsley Guest

    Yea, looks like the "leased-address" string is the one I can
    extract more data from to build the hostname.
     
    Tom Horsley, Feb 17, 2008
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.