DHCP (Dynamic Host Configuration Protocol)
DHCP, the Dynamic Host Configuration Protocol, describes the means by which a system can connect to a network and obtain the necessary information for communication upon that network
In this article i will briefly explain howto setup DHCP Server and client on various Operating Systems, such as FreeBSD,OpenBSD,NetBSD and Linux. We will use the ISC (Internet Software Consortium) DHCP implementation.
You can get latest versions of this document from http://www.enderunix.org/documents/eng/dhcp.html
Ismail YENIGUL
ismail@EnderUNIX.ORG
EnderUNIX SDT Team Member
DHCP Installation
FreeBSD :
OpenBSD and NetBSD :
You do not do anything. dhcp comes with the default installation.
Make sure that you have BPF support in your kernel on *BSD's.
Linux:
You can install dhcp from Redhat and Mandrake distribution CDs.
DHCP Configuration
We will set up the configuration file called "dhcpd.conf"
The file path is /usr/local/etc/dhcpd.conf on FreeBSD and
/etc/dhcpd.conf on OpenBSD & NetBSD & Linux
--------------------- sample dhcpd.conf file-----------------------
options domain-name-servers 192.168.1.2 , ns2.enderunix.com ;
options domain-name "enderunix.net";
default-lease-time 6000;
max-lease-time 72000;
subnet 192.168.1.0 255.255.255.0 {
range 192.168.1.20 192.168.1.200;
options domain-name-servers 192.168.1.2 , ns2.enderunix.com ;
options domain-name "enderunix.com";
options routers 192.168.1.254 ;
options broadcast-address 192.168.1.255
default-lease-time 600;
max-lease-time 7200;
}
host freefall {
hardware ethernet 08:00:07:26:c0:a5;
fixed-address "192.168.1.10";
}
-------------------dhpcd.conf end-------------------------
Lets describe above parameters
subnet 192.168.1.0 255.255.255.0: the subnet and it's subnet mask that dhcpd will serve
range 192.168.1.20 192.168.1.200; IP address range for clients
options domain-name-servers 192.168.1.2 , ns2.enderunix.com:defines domain server
options domain-name "enderunix.com" : defines domain name
options routers 192.168.1.1 : defines default gateway for clients
options broadcast-address 192.168.1.255: defines broadcast for clients
default-lease-time TIME: TIME should be length in seconds that will be assigned to a lease; if the client requesting the lease does not ask for a specific expiration time
max-lease-time TIME; Time should be the maximum length in seconds that will be assigned to a lease; if the client requesting the lease asks for a specific expiration time
host freefall {
hardware ethernet 08:00:07:26:c0:a5;
fixed-address 192.168.1.10;
}
you can assing static IP's to some clients. above we assigned 192.168.1.10 IP address to
machine whose MAC address is 08:00:07:26:c0:a5;
Note: As you see freefall's IP address is out of range! and freefall's domain is enderunix.net not enderunix.com (because general domain name is enderunix.net)
Running DHCP
Before running dhcpd be sure dhat /var/db/dhcpd.leases file exists. if not create it:
dhcpd.leases contains information on leased IPs
to run dhcpd
rootroot
when you make changes on dhcpd.conf file you must at kill and restart dhcpd daemon.
Configuring Clients
FreeBSD:
comment out following values in /etc/rc.conf file
and add following value
ifconfig_fxp0="DHCP"
Note: Be sure to replace fxp0 with the designation for the interface that you wish to dynamically configure
OpenBSD & NetBSD:
echo dhcp >/etc/hostname.fxp0
Note: Be sure to replace fxp0 with the designation for the interface that you wish to dynamically configure
Linux:
on Redhat & Mandrake write
BOOTPROTO=dhcp
to /etc/sysconfig/network-scripts/ifcfg-eth0 file
on All UNIX and UNIX like OS you can run dhcpclient manually to get an IP
Windows:
Start->Settings -> Control Panel ->Network ->TCP/IP -> Obtain an IP address automatically
DHCP Server Startup Configuration
FreeBSD:
create dhcp.sh and write it
/usr/local/sbin/dhcpd fxp0 -q
Note: replace fxp0 with your ethernet interface name
OpenBSD & NetBSD :
add following value to /etc/rc.conf
dhcpd_flags="YES"
Linux:
add following value to /etc/rc.d/rc.local
/usr/sbin/dhcpd eth0 -q
Note: replace eth0 with your ethernet interface name
Resources:
man dhcpd
man dhcpd.conf
FreeBSD Handbook ( http://freebsd.enderunix.org)
|
|