Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Linux as a DHCP Server for multiple subnets ?

Posted on 1998-12-16
Medium Priority
Last Modified: 2008-03-17
Is it possible to configura a Linux machine to act as a DHCP server for multiple subnets ?
Question by:fbuys
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 1587927
If you use separated network cards

Expert Comment

ID: 1587928
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.

Expert Comment

ID: 1587929
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 "abc.com";
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.


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 1587930
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

Accepted Solution

axar earned 100 total points
ID: 1587931
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!

Author Comment

ID: 1587932
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

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question