Can ONE dhcp server serve 2+ network ip range

I have only One dhcp server which has only one interface with ip address 10.0.0.1/24. The dhcpd.conf are like:

subnet 10.0.0.0 netmask 255.255.255.0 {                 <-------working
   host yyy {
         hardware ethernet BB:BB:BB:BB:BB:BB;
         fixed-address 10.0.0.53;
   }
}

subnet 192.168.0.0 netmask 255.255.255.0 {              <--------not working, why?
     host xxx {
         hardware ethernet AA:AA:AA:AA:AA;
         fixed-address 192.168.0.53;
     }
}

When the host xxx try to request a dhcp, the dhcp server shows error: DHCPDISCOVER from AA:AA:AA:AA:AA via eth0: network 10.0.0.1/24: no free leases.

But when the host yyy ask for a ip address, the dhcp server do give out a DHCP offer.

Can I assign 192.168.0.0/24 address within a dhcp server only have 10.0.0.0/24 interface? How can I configure to make it work?


Solution 1:

Welcome to serverfault!
Yes, you can issue IP Addresses for subnets on which the server itself does not have an interface.

When a client tries to obtain an IP Address, it sends a broadcast looking for a DHCP server. When there is no DHCP server available on the local network, a router can be configured as a DHCP helper such that when it receives a DHCP broadcast, it will create a unicast packet destined for the DHCP server with the original client's information (mac, network). Using the network information, the DHCP server can determine from which scope to issue a lease to the client. It sends this info back to the router which sends it back to the client.

If you move your additional clients to another vlan or on another network segment and setup a router with an interface in each subnet, then configure the router's DHCP helper with the IP of your DHCP server, you should be in business.

Solution 2:

Your problem here is that you don't have any free leases, as indicated by "no free leases".

That means that your DHCP scope on the 10.0.0.0 network is completely exhausted. You didn't include the IP ranges in your post, but can you post that information? If not, just see if you can expand the IP range to provide more room for the host you're trying to configure. After you make that change, restart the DHCP daemon and check to see if your client can obtain an IP.

Solution 3:

It can serve as many network ranges as you need to serve. :)

But in your problem, perhaps the IP Address 192.168.0.53 which you wish to lease to the xxx host is already leased to another client as you said:

When the host xxx try to request a dhcp, the dhcp server shows error: DHCPDISCOVER from AA:AA:AA:AA:AA via eth0: network 10.0.0.1/24: no free leases.

"No free leases" means what it means :).
Human translation here is: Via eth0 interface 10.0.0.1/24 I have received a DHCPDISCOVER FROM a client AA:AA:AA:AA:AA but I DON'T have any free address to lease to it!

Try to select different address for the host that hasn't been leased already ex: 192.168.0.250 may work. Alternatively you can add an excluded range of addresses in a DHCP and assign the IP address to the host manually.

NOTE:
Also be advised that on some DHCP servers, if the host already has the address (in your case 192.168.0.53) and you add the same address as a fixed address in the server YOU WILL GET THE ERROR MESSAGE. From a point of view the server is correct IT CAN NOT lease an already leased address!
So you may want to free the IP address first from the pool and try the procedure again.
ipconfig /release on the client may do the trick :)