[ 9 May 1998 The Linux DHCPd mini-HOWTO is no longer being maintained. The DHCPd and DHCPcd have been merged into a single mini-HOWTO called DHCP. Please feel free to contact me at if you have any questions or concerns. ] DHCP server mini-HOWTO (DHCPd) Vladimir Vuksan, vuksan@veus.hr v1.3, 15 March 1998 This document attempts to answer basic questions on how to setup your Linux box to serve as a DHCP server. ______________________________________________________________________ Table of Contents 1. Introduction 1.1 New Versions of this Document 1.2 Feedback 1.3 Contributors 1.4 Standard Disclaimer 1.5 Copyright Information 2. Setup 2.1 Introduction 2.2 DHCPD server for Linux. 2.3 Network Configuration. 2.4 Options for DHCPd 2.5 Running the server ______________________________________________________________________ 1. Introduction 1.1. New Versions of this Document New versions of this document will be periodically posted to comp.os.linux.answers. They will also be added to the various anonymous FTP sites who archive such information, including: ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO In addition, you should generally be able to find this document on the Linux Documentation Project page via: http://sunsite.unc.edu/LDP/ 1.2. Feedback Feedback is most certaintly welcome for this document. Without your submissions and input, this document wouldn't exist. So, please post your additions, comments and criticisms to vuksan@veus.hr. 1.3. Contributors This document has been modified from the original version by Paul Makeev. 1.4. Standard Disclaimer No liability for the contents of this documents can be accepted. Use the concepts, examples and other content at your own risk. As this is a new edition of this document, there may be errors and inaccuracies, that may of course be damaging to your system. Proceed with caution, and although this is highly unlikely, I don't take any responsibility for that. Also bear in mind that this is NOT official information. Obtaining official information is usually an impossibility with many ISPs. Much content in this document are assumptions, which appear to work for people. Use the information at your own risk. 1.5. Copyright Information This document is copyrighted (c)1998 Vladimir Vuksan and distributed under the following terms: · Linux HOWTO documents may be reproduced and distributed in whole or in part, in any medium physical or electronic, as long as this copyright notice is retained on all copies. Commercial redistribution is allowed and encouraged; however, the author would like to be notified of any such distributions. · All translations, derivative works, or aggregate works incorporating any Linux HOWTO documents must be covered under this copyright notice. That is, you may not produce a derivative work from a HOWTO and impose additional restrictions on its distribution. Exceptions to these rules may be granted under certain conditions; please contact the Linux HOWTO coordinator at the address given below. · If you have questions, please contact Greg Hankins, the Linux HOWTO coordinator, at gregh@sunsite.unc.edu 2. Setup 2.1. Introduction DHCP is Dynamic Host Configuration Protocol. It is used to control vital networking parameters of hosts (running clients) with the help of server. DHCP is backward compatible with BOOTP. For more information see RFC 2131 (old RFC 1531) and other. (See Internet Resources section at the end of the document). You can also read DHCP FAQ. This mini-HOWTO is about DHCP _SERVER_ daemon. There is DHCP _client_ daemon (DHCPcd) for Linux, which is not described here. Information about DHCPcd can be found at: http://sunsite.unc.edu/LDP/HOWTO/mini/DHCPcd.html 2.2. DHCPD server for Linux. There are several DHCP servers available for U*X-like OSes, both commercial and free. One of more popular free DHCP servers is Paul Vixie/ISC DHCPd. You can get it from ftp://ftp.isc.org/isc/dhcp/dhcp-1.0.0.tar.gz After you do you need to unpack. It will create a directory of its own. Go into it and type ./configure It will take few seconds to configure the settings. Then type: make and make install 2.3. Network Configuration. When done with installation type ifconfig -a. You should get output 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. README explains why: "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." So you have to 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 -net 255.255.255.0 dev eth0 eth0 is of course the name of the network device you are using. If it differs change it appropriately. 2.4. Options for DHCPd Now you need to configure DHCPd. In order to do this you will have to create or edit /etc/dhcpd.conf. Most commonly what you want to do is assign randomly IP addresses to clients on you local network. This can be done with a paragraphs like this ______________________________________________________________________ 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 of 192.168.1.10-192.168.1.100 and 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 lease it will allow is 7200 seconds. The server will also advise the client that it should use 255.255.255.0 as its subnet mask, use 192.168.1.255 as its broadcast address, use 192.168.1.254 as the router/gateway and 192.168.1.1 and 192.168.1.2 as its DNS servers. You can also assign specific IP addresses based upon 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 of 192.168.1.222 to client with an ethernet address of 08:00:2b:4c:59:23. You can also mix and match e.g. you can have certain clients getting "static" IP addresses and others being alloted dynamic IPs. There are a number of other options, if you need any of them read the dhcpd.conf man page for details. 2.5. Running the server You can now invoke the DHCP server. Simply type (or include in the bootup scripts) /usr/sbin/dhcpd If you want to verify that everything is working fine you should first turn on the debugging mode and put the server in forground. You can do it by typing /usr/sbin/dhcpd -d -f Then try to obtain an IP address with a client. You will see a number of debugging messages coming out of the server.