Solved

Linux as a DHCP Server for multiple subnets ?

Posted on 1998-12-16
6
656 Views
Last Modified: 2008-03-17
Is it possible to configura a Linux machine to act as a DHCP server for multiple subnets ?
0
Comment
Question by:fbuys
6 Comments
 
LVL 5

Expert Comment

by:JBURGHARDT
Comment Utility
If you use separated network cards
0
 
LVL 2

Expert Comment

by:irp
Comment Utility
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.
0
 
LVL 1

Expert Comment

by:kathotia
Comment Utility
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.



0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:fbuys
Comment Utility
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
0
 
LVL 1

Accepted Solution

by:
axar earned 50 total points
Comment Utility
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 168.12.54.2 netmask 255.255.255.0 {
............
...........
.......
......
....
}

Thats all!
0
 

Author Comment

by:fbuys
Comment Utility
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
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now