Linux as a DHCP Server for multiple subnets ?

Is it possible to configura a Linux machine to act as a DHCP server for multiple subnets ?
Who is Participating?
Manual copying is a lamers act, but actually he handed you  the solution. And you should have seen the solution too, it's very simple.

If you machine is acting as a router for the 2 subnets just add another entry for the other subnet like:

subnet netmask {

Thats all!
If you use separated network cards
If the Linux box is not acting as the router between the seperate subnets, you would need to enable DHCP relay/forwarding on the routers.
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Setting up DHCP on Red Hat

If your network has a large number of clients, manually configuring every machine with a static IP address is a tough job. The Dynamic Host Configuration Protocol (DHCP) lets you automatically assign an IP address to a machine on the network from a pool or range of IP addresses it has.

To configure a DHCP server on your Linux machine, you need to create a file called dhcpd.conf in the /etc directory. This file contains all the information that the daemon needs while starting up. This file is in the following format (the line numbers are not part of the file, they’re for the explanation that follows):

subnet netmask {
default-lease-time 86400;
max-lease-time 259200;
option subnet-mask;
option broadcast-address;
option routers;
option domain-name-servers;
option domain-name "";
Lets look at these lines a bit more closely. The first line specifies the (sub)network that the DHCP server is to manage or maintain. Within this network, we have to configure different parameters (written within the curly braces).

The next line contains the range from which the server picks up IP addresses to allocate. The starting and ending IP addresses are entered here. Line 3 contains the default lease time. A lease is the amount of time that a particular machine can hold an IP address before having to renew the lease with the server. The value is given in number of seconds, so 86400 stands for one day. The next line, max-lease-time, specifies the maximum amount of time that a machine can hold on to a specific IP address.

Then come other options that will also be transmitted to the machine. These include the subnet mask, the router, the domain name server, and the domain name.

Once this is done, you need to create a file called dhcpd.leases, also in the /etc/ directory, which will contain information about which IP address has been allocated to which machine. Since all this will be done by the server, all you need to do is create a 0 byte file with the command, touch /etc/dhcpd.leases.

The next step requires you to add a broadcast route. Do this by appending the line /sbin/route add –host dev eth0 to /etc/rc.d/rc.local.

Finally, make sure DHCP is started at bootup. You can do this by running Setup, choosing ntsysv, and enabling dhcpd. Restart the machine, by giving the command sync, followed by reboot.

Your DHCP server will be up and running after the machine starts up. Any machine that logs on the network will receive an IP address and all other parameters automatically. If it’s a Win 95 client, you can check all the settings by running winipcfg in the Run dialog box.

There may be cases when you need to assign a particular machine the same IP address always. You can either hardwire the information in the computer or add the following lines to the dhcpd.conf file.

host mynotebook {
hardware ethernet 00:80:C8:85:B5:D2;
option host-name "mynotebook";

This specifies the ethernet address, which will be unique, the IP address that will always be allocated to that machine, and a host name.

fbuysAuthor Commented:
Don't copy the answer from a manual !!!
And if you do copy it, give a correct answer !
This doesn't answer my question, I know how to configure DHCP, I want to know how to confiure it for multiple subnets
fbuysAuthor Commented:
The Linux box will not be acting as a router, It will be connected to 1 subnet, all other subnets are connected to this subnet with Cisco routers, they will have an ip helper adrees configured so that they will do dhcp-relay. What I'm looking for is a way to have my Linux box to supply a DHCP address pool for all the clients that are on the subnets behind the cisco routers
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.