Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
CARE

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents

· Introduction to Operating Systems
· Linux Basics
· Working with the System
· Shells and Utilities
· Editing Files
· Basic Administration
· The Operating System
· The X Windowing System
· The Computer Itself
· Networking
· System Monitoring
· Solving Problems
· Security
· Installing and Upgrading
· Linux and Windows

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Surveys

Features
HOWTOs
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 69 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  

HOWTO Home

Current HOWTO: DHCP


DHCP Server Setup

4. DHCP Server Setup

4.1. DHCP server for UNIX

There are several DHCP servers available for U*X-like OSes, both commercial and free. One of the more popular free DHCP servers is Paul Vixie/ISC DHCPd. Currently the latest version is 2.0 (suggested for most users) but 3.0 is in beta testing. You can get them from

ftp://ftp.isc.org/isc/dhcp/

Some of the distributions provide binary packages for dhcpd so skip the following section if you got it installed that way.

After you download unpack it. After you do cd into the distribution directory and type: ./configure

It will take some time to configure the settings. After it is done type: make and make install.

4.2. DHCP server configuration

When done with installation type ifconfig -a. You should see something like this:

eth0      Link encap:10Mbps Ethernet  HWaddr 00:C0:4F:D3:C4:62
          inet addr:183.217.19.43  Bcast:183.217.19.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2875542 errors:0 dropped:0 overruns:0
          TX packets:218647 errors:0 dropped:0 overruns:0
          Interrupt:11 Base address:0x210

If it doesn't say MULTICAST you should reconfigure your kernel and add multicast support. On most systems you will not need to do this.

Next step is to add route for 255.255.255.255. Quoted from DHCPd README:

"In order for dhcpd to work correctly with picky DHCP clients (e.g., Windows 95), it must be able to send packets with an IP destination address of 255.255.255.255. Unfortunately, Linux insists on changing 255.255.255.255 into the local subnet broadcast address (here, that's 192.5.5.223). This results in a DHCP protocol violation, and while many DHCP clients don't notice the problem, some (e.g., all Microsoft DHCP clients) do. Clients that have this problem will appear not to see DHCPOFFER messages from the server."

Type: route add -host 255.255.255.255 dev eth0

If you get a message "255.255.255.255: Unknown host", you should try adding the following entry to your /etc/hosts file:

255.255.255.255 all-ones

Then, try:

route add -host all-ones dev eth0

or

route add 255.255.255.0 dev eth0

eth0 is of course the name of the network device you are using. If it differs change appropriately.

4.3. Options for DHCPd

Now you need to configure DHCPd. In order to do this you will have to create or edit /etc/dhcpd.conf. There is a graphical interface for dhcpd configuration under KDE ( http://www.kde.org/ ) called kcmdhcpd that is very similar to the DHCP configurator on Windows NT. When KDE 2.0 comes out it should come with kcmdhcpd or you could get it directly from:

ftp://ftp.us.kde.org/pub/kde/unstable/apps/network/

If you want to configure it by hand follow instructions below.

Most commonly what you want to do is assign IP addresses randomly. This can be done with settings as follows:

# Sample /etc/dhcpd.conf
# (add your comments here) 
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.1, 192.168.1.2;
option domain-name "mydomain.org";

subnet 192.168.1.0 netmask 255.255.255.0 {
   range 192.168.1.10 192.168.1.100;
   range 192.168.1.150 192.168.1.200;
}

This will result in DHCP server giving a client an IP address from the range 192.168.1.10-192.168.1.100 or 192.168.1.150-192.168.1.200. It will lease an IP address for 600 seconds if the client doesn't ask for specific time frame. Otherwise the maximum (allowed) lease will be 7200 seconds. The server will also "advise" the client that it should use 255.255.255.0 as its subnet mask, 192.168.1.255 as its broadcast address, 192.168.1.254 as the router/gateway and 192.168.1.1 and 192.168.1.2 as its DNS servers.

If you need to specify a WINS server for your Windows clients you will need to include the netbios-name-servers option e.g.

option netbios-name-servers 192.168.1.1;

You can also assign specific IP addresses based on clients ethernet address e.g.

host haagen {
   hardware ethernet 08:00:2b:4c:59:23;
   fixed-address 192.168.1.222;
}

This will assign IP address 192.168.1.222 to a client with ethernet address 08:00:2b:4c:59:23.

You can also mix and match e.g. you can have certain clients getting "static" IP addresses (e.g. servers) and others being alloted dynamic IPs (e.g. mobile users with laptops). There are a number of other options e.g. nis server addresses, time server addresses etc., if you need any of those options please read the dhcpd.conf man page.

4.4. Starting the server

There is only one thing to do before starting the server. In most cases DHCP installation doesn't create a dhcpd.leases files. This file is used by DHCPd to store information about current leases. It is in the plain text form so you can view it during the operation of DHCPd. To create dhcpd.leases type:

touch /var/state/dhcp/dhcpd.leases

This will create an empty file (file size = 0). Some of the older version of dhcpd 2.0 placed the file in /etc/dhcpd.leases. You do not need to make any changes to the leases file it will be manipulated by the dhcpd. If you get a message saying that file exists simply ignore it and go to the next step.

You can now invoke the DHCP server. Simply type (or include in the bootup scripts)

/usr/sbin/dhcpd

This will invoke dhcpd on eth0 device. If you want to invoke it on another device simply supply it on the command line e.g.

/usr/sbin/dhcpd eth1

To verify that everything is working fine you should first turn on the debugging mode and put the server in foreground. You can do this by typing

/usr/sbin/dhcpd -d -f

Then boot up one of your clients and check out the console of your server. You will see a number of debugging messages come up. If everything works out fine you are done :-). Quit dhcpd and start it without the -d -f and arguments. If you want dhcpd to start at boot-up include dhcpd in e.g.

/etc/rc.d/rc.local

4.5. Other interesting documents

Linux Magazine has a pretty good article in their April issue called Network Nirvana: How to make Network Configuration as easy as DHCP that discusses the set up for DHCP.


The Linux Tutorial completely respects the rights of authors and artists to decide for themselves if and how their works can be used, independent of any existing licenses. This means if you are the author of any document presented on this site and do no wish it to be displayed as it is on this site or do not wish it to be displayed at all, please contact us and we will do our very best to accommodate you. If we are unable to accommodate you, we will, at your request, remove your document as quickly as possible.

If you are the author of any document presented on this site and would like a share of the advertising revenue, please contact us using the standard Feedback Form.


  




Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
You can choose larger fonts by selecting a different themes.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.14 Seconds