0

Is it possible to calculate ip address based on mac address for isc-dhcp server?

For example: 'aa:aa:aa:aa:aa:x' => '10.10.10.x'

I have following in dhcpd.conf:

subnet 10.10.10.0 netmask 255.255.255.0 {

  class "v" {
    match if substring (hardware, 0, 14) = "AA:AA:AA:AA:AA";
    }

  pool {
    range 10.10.10.101 10.10.10.200;
    deny unknown-clients;
    allow members of "v";
    fixed-address = concat('10.10.10.', substring (hardware, 15, 2));
    }
}

fixed-address directive is misplaced (have to be in host closure only), so I have error. Any workarounds exists?

kakabomba
  • 113
  • 3
  • There is no guarantee that there won't be any collisions for this method (it you can configure dhcpd to do this at all). Having collisions is even quite likely (see http://en.wikipedia.org/wiki/Birthday_problem). – Sven Apr 18 '15 at 07:43
  • mac addresses are generated for virtual machines. And i have guarantee that no collisions appear – kakabomba Apr 18 '15 at 11:54

1 Answers1

0

I don't think there's a way to do this with ISC dhcpd (since fixed-address can only appear within a host clause).

Couldn't you get the same behaviour by generating a sequence of host clauses with the required MAC and IP addresses? I admit that I'm struggling to imagine a situation where this setup would be useful though.

Paul Haldane
  • 4,457
  • 1
  • 20
  • 31