There are many ways to install a dhcp server on Ubuntu 7.10, below is the CLI method. The first thing I did was switch users to root so I didn't have to keep typing in my root password. Then I used apt-get to download and install the package.
user@U2-desktop:~$ sudo -s root@U2-desktop:~# apt-get install dhcp3-server Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: dhcp3-server 0 upgraded, 1 newly installed, 0 to remove and 94 not upgraded. Need to get 0B/316kB of archives. After unpacking 774kB of additional disk space will be used. Preconfiguring packages ... Selecting previously deselected package dhcp3-server. (Reading database ... 94828 files and directories currently installed.) Unpacking dhcp3-server (from .../dhcp3-server_3.0.5-3ubuntu4_i386.deb) ... Setting up dhcp3-server (3.0.5-3ubuntu4) ... * Starting DHCP server dhcpd3 [ OK ]
Next, I checked to see if the dhcpd process was running.
root@U2-desktop:~# pgrep dhcpd 6161
I need to define an ethernet interface that the server will use. First, I make a backup of the file. Then I open it in a GUI editor. The contents of the file are listed below. All I need to do is change INTERFACES="" to INTERFACES="eth3". The name of the ethernet interface can vary so it's best to use ifconfig command to determine the names of the ethernet interfaces installed.
root@U2-desktop:~# cp /etc/default/dchp3-server /etc/default/dchp3-server.back # Defaults for dhcp initscript # sourced by /etc/init.d/dhcp # installed at /etc/default/dhcp3-server by the maintainer scripts # # This is a POSIX shell fragment # # On what interfaces should the DHCP server (dhcpd) serve DHCP requests? # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACES="eth3"
The next step is to edit the dhcpd.conf file. The first thing I do is make a backup of the file. Then open it and modify the settings. Below is the unedited version of the file followed by the version that I used.
root@U2-desktop:~# cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcp3.back
#
# Sample configuration file for ISC dhcpd for Debian
#
# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $
#
# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
#subnet 10.152.187.0 netmask 255.255.255.0 {
#}
# This is a very basic subnet declaration.
#subnet 10.254.239.0 netmask 255.255.255.224 {
# range 10.254.239.10 10.254.239.20;
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.
#subnet 10.254.239.32 netmask 255.255.255.224 {
# range dynamic-bootp 10.254.239.40 10.254.239.60;
# option broadcast-address 10.254.239.31;
# option routers rtr-239-32-1.example.org;
#}
# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name "internal.example.org";
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;
# default-lease-time 600;
# max-lease-time 7200;
#}
# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.
#host passacaglia {
# hardware ethernet 0:0:c0:5d:bd:95;
# filename "vmunix.passacaglia";
# server-name "toccata.fugue.com";
#}
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
#host fantasia {
# hardware ethernet 08:00:07:26:c0:a5;
# fixed-address fantasia.fugue.com;
#}
# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.
#class "foo" {
# match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
#}
#shared-network 224-29 {
# subnet 10.17.224.0 netmask 255.255.255.0 {
# option routers rtr-224.example.org;
# }
# subnet 10.0.29.0 netmask 255.255.255.0 {
# option routers rtr-29.example.org;
# }
# pool {
# allow members of "foo";
# range 10.17.224.10 10.17.224.250;
# }
# pool {
# deny members of "foo";
# range 10.0.29.10 10.0.29.230;
# }
#}
I deleted everything above and used this basic configuration.
subnet 192.168.226.0 netmask 255.255.255.0 {
range 192.168.226.10 192.168.226.200;
option routers 192.168.226.2;
option broadcast-address 192.168.226.255;
default-lease-time 600;
max-lease-time 7200;
option domain-name "localdomain";
option domain-name-servers 68.87.76.178, 68.87.78.130;
}
Whenever you make a change to the dhcpd.conf file you need to restart the server.
root@U2-desktop:~# /etc/init.d/dhcp3-server restart * Stopping DHCP server dhcpd3 [ OK ] * Starting DHCP server dhcpd3
root@U2-desktop:~# grep dhcpd /var/log/syslog Dec 3 05:50:58 U2-desktop dhcpd: Internet Systems Consortium DHCP Server V3.0.5 Dec 3 05:50:58 U2-desktop dhcpd: Copyright 2004-2006 Internet Systems Consortium. Dec 3 05:50:58 U2-desktop dhcpd: All rights reserved. Dec 3 05:50:58 U2-desktop dhcpd: For info, please visit http://www.isc.org/sw/dhcp/ Dec 3 05:50:58 U2-desktop dhcpd: Wrote 1 leases to leases file. Dec 3 05:59:26 U2-desktop dhcpd: DHCPDISCOVER from 00:0c:29:ce:48:8c via eth3 Dec 3 05:59:27 U2-desktop dhcpd: DHCPOFFER on 192.168.226.128 to 00:0c:29:ce:48:8c (WindowsXPClient1) via eth3 Dec 3 05:59:27 U2-desktop dhcpd: DHCPREQUEST for 192.168.226.128 (192.168.226.5) from 00:0c:29:ce:48:8c (WindowsXPClient1) via eth3 Dec 3 05:59:27 U2-desktop dhcpd: DHCPACK on 192.168.226.128 to 00:0c:29:ce:48:8c (WindowsXPClient1) via eth3 Dec 3 06:00:30 U2-desktop dhcpd: DHCPINFORM from 192.168.226.128 via eth3: not authoritative for subnet 192.168.226.0
If you want to see issued leases you can check the /var/lib/dhcp3/dhcpd.leases. The time differences in the dhcpd.leases and syslog are different because one sets the time as GMT and the other as the local time zone.
# All times in this file are in UTC (GMT), not your local timezone. This is
# not a bug, so please don't ask about it. There is no portable way to
# store leases in the local timezone, so please don't request this as a
# feature. If this is inconvenient or confusing to you, we sincerely
# apologize. Seriously, though - don't ask.
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-V3.0.5
}
lease 192.168.226.128 {
starts 1 2007/12/03 04:59:27;
ends 1 2007/12/03 05:09:27;
binding state active;
next binding state free;
hardware ethernet 00:0c:29:ca:47:8c;
uid "\001\000\014)\316H\214";
client-hostname "WindowsXPClient1";
}
lease 192.168.226.128 {
starts 1 2007/12/03 05:04:26;
ends 1 2007/12/03 05:14:26;
binding state active;
next binding state free;
hardware ethernet 00:0c:29:ca:47:8c;
uid "\001\000\014)\316H\214";
client-hostname "WindowsXPClient1";
}
The next thing I did was to switch over to my Windows XP client to see if it could pull configuration information from the dhcp server.
Windows IP Configuration
Host Name . . . . . . . . . . . . : WindowsXPClient1
Primary Dns Suffix . . . . . . . : localdomain
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : PLANIT.local
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : localdomain
Description . . . . . . . . . . . : AMD PCNET Family PCI Ethernet Adapter
Physical Address. . . . . . . . . : 00-0C-29-CA-47-8C
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 192.168.226.128
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.226.2
DHCP Server . . . . . . . . . . . : 192.168.226.5
DNS Servers . . . . . . . . . . . : 68.87.76.178
68.87.78.130
Lease Obtained. . . . . . . . . . : Sunday, December 02, 2007 9:01:40 PM
Lease Expires . . . . . . . . . . : Sunday, December 02, 2007 9:11:40 PM
Pinging www.l.google.com [74.125.19.147] with 32 bytes of data:
Reply from 74.125.19.147: bytes=32 time=11ms TTL=128
Reply from 74.125.19.147: bytes=32 time=10ms TTL=128
Reply from 74.125.19.147: bytes=32 time=15ms TTL=128
Reply from 74.125.19.147: bytes=32 time=13ms TTL=128
Ping statistics for 74.125.19.147:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 10ms, Maximum = 15ms, Average = 12ms
The lease is successful and the domain name servers, ip address, default gateway, lease duration and domain name are all correct.