Client in two subnets. In one it should get an fixed address.

Glenn Satchell Glenn.Satchell at uniq.com.au
Thu Sep 11 12:14:33 UTC 2008


>Date: Thu, 11 Sep 2008 12:38:40 +0100
>To: dhcp-users at isc.org
>From: Simon Hobson <dhcp1 at thehobsons.co.uk>
>Subject: Re: Client in two subnets. In one it should get an fixed address.
>
>Marc Muehlfeld wrote:
>
>>How can I configure a fixed address for one host if it is connected 
>>in the first subnet and when it is connected to the second, it get 
>>one out of the pool?
>>
>>Currently when I connect PC-02 to the first subnet, it gets an IP 
>>out of the 10.1.0.241 10.1.0.254 range instead out of 10.1.0.100 
>>10.1.0.200. In the second subnet it gets the configured fixed 
>>address, like wanted.
>>
>
>
>
>>subnet 10.1.0.0 netmask 255.255.255.0 {
>>
>>  option broadcast-address 10.1.0.255;
>>  option routers 10.1.0.5;
>>
>>  # Hosts with fix IPs via DHCP
>>  pool {
>>   range 10.1.0.241 10.1.0.254;
                      ^^^^^^^^^^
                      
You have assigned a fixed address that is included within a dynamic
range. This is bad, because the server could legitimately hand out that
address to a dynamic client while your PC was on the other subnet, say.
Then your PC won't get it's fixed address because ot clashes with an
already assigned PC. The range should not include any fixed addresses.
Same thing in the other subnets.

In fact, looking at your definitions, you could just delete the pools
you have defined for fixed-ips, as by definition they are known hosts,
and put the hosts statements in the global scope, ie outside the subnet
definitions.

You could also remove all the allow/deny unknown clients, as these
statements are implied anyway - a fixed-address will always be used if
the client is in the proper subnet for it to be valid, and a dynamic ip
at other times. This will simplify your config a great deal - you are
making it harder than it has  to be.

>>   deny unknown-clients;
>>   host PC-01 { hardware ethernet AA:AA:AA:AA:AA:AA; fixed-address 
10.1.0.254;}
>
>   ^^^^^^^^^^
>
>This is your problem, even if this device is in another subnet, it 
>still inherits options from this subnet and pool - you've told the 
>server to do this by putting the host declaration inside the pool & 
>subnet.
>
>The answer is to put all your host statements in the global scope.
>
>The standard statement here is "all host statements are global in 
>scope", which is a slight simplification. You have found out why we 
>tell people to always put their host statements in the global scope 
>unless they are doing something advanced. In almost every case when 
>it's come up, the user did NOT want the 'wrong' options inherited 
>from another scope.
>
>

So your config could be reduced to something like this, based on the
information supplied so far:

host PC-01 { hardware ethernet AA:AA:AA:AA:AA:AA; fixed-address 10.1.0.254;}
host PRT-1 { hardware ethernet 11:11:11:11:11:11; fixed-address 10.1.0.18;}
host PC-02 { hardware ethernet BB:BB:BB:BB:BB:BB; fixed-address 10.1.1.254;}
host PRT-2 { hardware ethernet 22:22:22:22:22:22; fixed-address 10.1.1.18;}

subnet 10.1.0.0 netmask 255.255.255.0 {
  option broadcast-address 10.1.0.255;
  option routers 10.1.0.5;
  # All other DHCP clients
  range 10.1.0.100 10.1.0.200;
}

subnet 10.1.1.0 netmask 255.255.255.0 {
  option broadcast-address 10.1.1.255;
  option routers 10.1.1.5;
  # All other DHCP clients
  range 10.1.1.100 10.1.1.200;
}


HTH.

regards,
-glenn



More information about the dhcp-users mailing list