Link to home
Start Free TrialLog in
Avatar of fbuys
fbuys

asked on

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 ?
Avatar of JBURGHARDT
JBURGHARDT

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.
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 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.250;
default-lease-time 86400;
max-lease-time 259200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1;
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 255.255.255.255 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;
fixed-address 192.168.1.20;
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.



Avatar of fbuys

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of axar
axar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fbuys

ASKER

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