# Deny dhcp assignment on certain subnets, fixed address on others?



## `Orum (Feb 25, 2017)

I've been poring over the dhcpd.conf(5) man page, trying to figure out what is the correct way to give a client a fixed address when it connects to one or more subnet(s), and ignore any lease requests if it's on any other subnet.  Based on what I've read, I _think_ this is the correct configuration, but I'm hoping someone else can weigh in before testing, as I really hate breaking DHCP:

```
# dhcpd.conf
authoritative;

subnet 10.0.0.0 netmask 255.255.255.0 {
        range 10.0.0.1 10.0.0.200;

        option routers 10.0.0.254;
        option subnet-mask 255.255.255.0;
        option domain-name-servers 8.8.8.8;
}

subnet 10.0.1.0 netmask 255.255.255.0 {
        range 10.0.1.1 10.0.1.200;

        option routers 10.0.1.254;
        option subnet-mask 255.255.255.0;
        option domain-name-servers 8.8.8.8;
}

subnet 10.0.2.0 netmask 255.255.255.0 {
        range 10.0.2.1 10.0.2.200;

        option routers 10.0.2.254;
        option subnet-mask 255.255.255.0;
        option domain-name-servers 8.8.8.8;
}

# ...

host foo { # host foo should be allowed with a fixed address on 10.0.0/24 and 10.0.1/24...
        hardware ethernet 00:11:22:33:44:55;
        fixed-address 10.0.0.201, 10.0.1.201;
}

host foo { # ...but not on 10.0.2/24 (or any other subnet this server might service)
        hardware ethernet 00:11:22:33:44:55;
        ignore booting;
}
```
Does anyone have any experience with this, and if so, is this the correct way to configure it?


----------

