DHCP Server ConfigurationNext Previous Contents

3. Step Two

I'm not going to explain what a DHCP is, because I think most people know what it is (in essence), but I'm going to explain *why* you should use one: "There are several compelling reasons to go to DHCP, especially if you have a large department. No more IP block management required. (Except for servers...i.e. minimal) No more DNS registrations needed. You will be providing "generic" DNS addresses for DHCP blocks. No need to change DNS resolver information or WINS server addresses if there are changes required. All updates happen automatically from server to client. No need for users to know about their IP address, subnet mask, gateway, etc. Once setup, the client simply turns on the machine, and all configuration happens. This also means that there are less things to potentially misconfigure for the client computer." In all it's simplicity, you want a DHCP server because if you want to change IP addressing scheme's, or change anything from IP addresses to gateways to subnet masks, you only have to change it on *one* place.You certainly are not required to convert to DHCP, but for client environments, it has the potential to reduce client machine configuration after the initial setup and registration.

3.1 Installing the DHCP Server

Go to where ever you downloaded the dhcp-x.rpm file (where x is the version you obtained, lastest should be here)

rpm -ivh dhcp*

If you get some message about how it is an *older* version than what you have, then don't worry! That means you have it installed already, and you're doing great.. continue :)

3.2 Deciding on how you want it setup

(right_click, choose "Save link as..." I believe) download dhcpd.conf (http://www.fandelem.com/configfiles/dhcpd.conf), and copy it to /etc

Keep in mind you need to edit this file to change the IP addresses, subnets, and fixed computer names to whateveryou would like to have them setup to be. The file as is will result in DHCP servergiving a client an IP address from the range 192.168.1.10 through 192.168.1.200 with fixed addresses (which will only work in my network, so you *will* need to find out our own computer's MAC addresses, because MAC addresses are unique for each network card) of .2,.3,.4,.10. Don't misunderstand me, this file will work as is, but you might want to change some things around, just make sure you make a backup copy before you want to test anything out.

These are Class C IP addresses. Feel free to change them accordingly(Don't forget to alter the subnet mask too!!). I have included some fixed-addressesin this file. This can be useful for a number of reasons, but the main reasonfor doing something like this is that the DHCP server will always assignthe given fixed-IP-address to that certain computer on your network, andif any of your friends want to come over, it will just assign them a sequentialnumber (starting at .10 and working up to .200 eventually). Note:You *WILL* need to change the hardware ethernet to each of your networkcards (this is done in windows by clicking start -> run -> winipcfg,then select your ethernet card and write down the number that looks similarto in the file (such as: 00:50:ba:d1:fb:07). If you don't want to bother with this right now, or if itseems too overwhelming, just erase the every host entry at the bottom of this file.

3.3 Additional DHCP tricks

Add a route for picky DHCP clients (ie. all Windows clients). Type:

route add -host 255.255.255.255 dev eth0

The option domain-name-servers 64.65.1.112, 64.65.21.85; line, will definitely slow down your DNS queries down, because this is pointing to my DNS server. A simple way to solve this is connect to the internet, then type:

cat /etc/resolv.conf

and you should see two *almost* identical numbers (not identical to my numbers, but identical to each other). Write these down, and insert them *instead* of the two IP addresses I have listed in my dhcpd.conf file.

3.4 Testing it out

Okay, you're two steps away from getting your server up and running!First type:

touch /var/state/dhcp/dhcpd.leases

This is used as a "jump-start" to allow DHCPd to store information about current leases.

Now you can invoke the DHCP server. Simply type:

/usr/sbin/dhcpd -d -f &

Which puts the server in the foreground (but the & lets you type othercommands after it's initiated) so you can see the debugging and assignment of IP addresses. NOTE: this is *ONLY* for first-time debugging purposes! If you wish to make your DHCP server run at boot-time, see here. If you want to see the assignment of IP addresses, login and simply type tail -f /var/log/messages & and it will "monitor" the log files in the background. Note: It is always good practice to have at least one root account logged on in the event that you really mess something up (ie. change the root password from another account), which happens a lot in linux, hell, in almost any environment that you are still learning.

Popular Q/A:

"I don't understand.. if I have a DHCP server, how does it get its *own* IP address?" Answer: You need to go back to step one (2.1) and add the ifconfig statement to "bring up and assign" your ethernet card its address. Then go to step seven (8.3) where I explain how to add it so it saves it after you reboot your computer. Oh, right, back to the answer.. your DHCP server *usually* will have a STATIC IP address assigned by you (or the network administrator). It *is* possible to "daisy-chain" DHCP servers together in requesting IP addresses, but that gets very messy (with subnetting and whatnot), so forget I even mentioned it :)

"What's the difference between dhcpd and dhcpcd?" Answer: DHCP(d) is the server side, whereas DHCP(cd) is the client side. Put it this way: About 70% of all the major ISP's use DHCP(d) because it is so convenient, reliable, and the requires the least overall management once setup. The way you get an IP address on a windows box is a similar program to DHCP(cd) - which basically sends out a broadcast MAC address (all F's) in search for the DHCP(d) which is waiting for the broadcast continuously. It might take a while to sink in, but the easiest way I remember it is that when I just see a d at the end of a program, I recognize it as a daemon - which is described by the dictionary as: Unix systems run many daemons, chiefly to handle requests for services from other hosts on a network. Most of these are now started as required by a single real daemon, inetd, rather than running continuously. Examples are crond (local timed command execution), rshd (remote command execution), rlogind and telnetd (remote login), ftpd, nfsd (file transfer), lpd (printing). Notice the d's on the end..?

"How long of lease time should I set?" Answer: Here is what the man pages have to say: 600 seconds (ten minutes), 7200 seconds (two hours). Other common values would be 86400 (one day), 604800 (one week) and 2592000 (30 days). If you wanted to specify two months max lease time and one month guaranteed lease time for example, in your dhcpd.conf file, you would have a line saying default-lease-time 2592000 and another line saying max-lease-time 5184000

"Why isn't my DHCP server assigning an address to "such and such" computer?" Answer: A DHCP server only works on the network segment / subnet you are on. Havoc sometimes can occur if you have two DHCP servers on the same subnet (I've heard stories about students playing "pranks" on network administrators at certain colleges where they would install a DHCP server on a local computer that would give out bogus addresses to make it conflict with the real DHCP server.. the fastest server to respond with the reply wins, so it's really a tossup, but it will ultimately result in a disaster).

"If the server were to crash would we need to restart the clients in order to obtain a good IP or is it fine like it is?" Answer: a couple things happen here. while the server was up, any IP address that was given, will be good for the lease time set in your dhcpd.conf file, regardless if your DHCP server goes down. As long as you bring up the DHCP server before that lease time expires (it keeps a dhcp.lease file that keeps track of this stuff) then you will be fine and no one will notice a thing (providing your DHCP server is not your internet connection as well, *grin*). However, any computer trying to request an IP address while the server is down, will obviously not receive one.

3.5 Configuring the Windows side

This is actually extremely easy. Go under TCP/IP settings and click ObtainIP Address Automatically and reboot the computer. Imagine if you had 200 computers to setup. Would you rather go to each individual computer and enter in all the IP information or would you just like to have it obtain it automatically? Especially in a "ghosted" environment you just have the tcp/ip settings set to Obtain Automatically and you never have to worry about changing a thing.

3.6 Getting DHCP working with two nics (Still under testing) :-}

First off, I would like to say that I only use a 56k modem at the current time - I have only helped people try to install ADSL modems and I'm going to document my experiences working with them. I will be explaining how to use pppoe which is a protocol used by many ADSL Internet Service Providers as a means of authenticating with the end user (ie. you). I started writing this section with the intent to help all you ADSL and cable modem fellows, but I just feel like I can't do much of a service by reading about it and trying to write it all easy-to-read - I don't have first hand experience.. but I do have tons of experience working with DHCP servers, so, I decided to change this section on how to configure a DHCP server - I will leave whatever ADSL information I have already written - but there's no guarantee on that stuff until some nice guy comes through.. :) This document (as of 12/9/2000) really only covers how to setup a DHCP server with two ethernet cards. I apologize for how short this is, but it's a start. If anyone has tried anything here and gotten a problem - EMAIL (fandelem@hotmail.com) me and I will fix it and try to help you out! If anyone wants to take a stab at documenting how they got their ADSL/Cable modem working, please email me if you are thinking about it, and I'll link you right up or put it in here and give you mucho credit. You can even just write it in a text file and I'll do all the formatting and everything :)

I'm assuming that you have two ethernet cards that linux recognizes. Once this is true, here is how we will design our setup: eth0 will be plugged into the DSL modem, and out to the internet from there. Don't worry about anything dealing with eth0 besides knowing that linux recognized it (DO NOT assign an IP address to eth0). eth1 will be connected to the hub, and act as the DHCP server for your internal network. We will talk about eth0 shortly. Let's quickly setup our dhcp server for eth1:

(get it here and install if you haven't already) rpm -i dhcp*

See Section 3.2 on how to configure it.

Running your DHCP server:

First type:

touch /var/state/dhcp/dhcpd.leases

This is used as a "jump-start" to allow DHCPd to store information about current leases.

Now you can invoke the DHCP server on eth1. Simply type:

/usr/sbin/dhcpd -d -f eth1 &

Which puts the server in the foreground (but the & lets you type other commands after it's initiated) so you can see the debugging and assignment of IP addresses. NOTE: this is *ONLY* for first-time debugging purposes! If you wish to make your DHCP server run at boot-time, you will need to add it to /etc/rc.d/rc.local (boot-up script) with: /usr/sbin/dhcpd eth1 . If you want to see the assignment of IP addresses, login and simply type tail -f /var/log/messages & and it will "monitor" the log files in the background.

Okay, now for eth0. This is very VARIABLE on what type of connection you have. I will cover PPPoE first, which is used by most ADSL carriers. It is typically *not* used by cable ISPs. If you have cable, go here.

Setting your ADSL connection up:


Alright, first go to Step One and configure your eth0 card.

Now let's grab the rpm here (or visit their website http://www.roaringpenguin.com/pppoe/). Let's install it and start configuring it:

rpm -ivh rp-pppoe*
/usr/sbin/adsl-setup

This will go through a setup asking you various questions that your ISP should have provided you.
Here is a logfile of mine if you have any questions.

Once you are finished going through this configure script, issue the command:

adsl-start

At this point, you will either succeed, or not. If you don't, I will not repeat all the things this other person has wrote on problems that may arise, so go here (link: http://www.roaringpenguin.com/pppoe/how-to-connect.txt) to see if you are having similar problems.

Setting your cable connection up:


This is rather easy. You need to grab the latest dhcpcd program, which is the *client* portion of DHCP. You can find it
here (as of 12/19/2000).

Install it by issuing the command:

rpm -ivh dhcpcd*

Now, as root, type dhcpcd eth0 and you should be on the internet. To test it, try pinging somewhere.



Next Previous Contents