DHCP for specific range of mac addresses? - Networking
This is a discussion on DHCP for specific range of mac addresses? - Networking ; 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 ...
-
DHCP for specific range of mac addresses?
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...
-
Re: DHCP for specific range of mac addresses?
On Sat, 16 Feb 2008 18:58:34 -0600, Tom Horsley wrote:
> 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...
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
-
Re: DHCP for specific range of mac addresses?
On Sun, 17 Feb 2008 01:45:48 +0000, Jack Snodgrass wrote:
> 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.
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...
-
Re: DHCP for specific range of mac addresses?
On Sat, 16 Feb 2008 21:04:30 -0600, Tom Horsley wrote:
> Maybe I can derive
> the host name from the IP that gets assigned? I'll have to poke around
> more...
Yea, looks like the "leased-address" string is the one I can
extract more data from to build the hostname.
-
Re: DHCP for specific range of mac addresses?

Originally Posted by
Tom Horsley
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).
...
Anyone know what "hardware" generates? Anyone have an example
of already doing something like this?
This works for me:
if binary-to-ascii (16, 8, "-", substring (hardware, 0, 4)) = "1-0-16-3e" {
max-lease-time 600;
}
"hardware" operator obviously generates binary garbage, which must be converted to ASCII before matching. In light of this we can also see that conditional expression binary-to-ascii (16, 32, "", substring (hardware, 0, 4)) = "100163e" should do the job as well.
See also log() statement in dhcp-eval manpage - it's useful for debugging - log (debug, binary-to-ascii (16, 8, "-", hardware));