Monday, May 29, 2006

Basic DHCPD Tutorial

Purpose:
This tutorial aims to teach users on how to setup a basic DHCP server.

What is a dhcp server?
Dynamic Host Configuration Protocol, a protocol for assigning dynamic LP addresses to devices on a network. With dynamic addressing, a device can have a different IP address every time it connects to the network. DHCP also supports a mix of static and dynamic IP addresses.

In other words or in laymans term a dhcp server is used to automatically assign ip addresses to your workstations to access your network. This saves you time in assigning static ip addresses to each one of them granting you have 20 or more computers.

How to install dhcp?
For Fedora / Centos and Redhat users its pretty simple
just type in your console as root: yum install dhcp and it will automatically gather requirements and begin to install in your computer.

Next step would be configuration, now lets disect a simple dhcpd.conf file found in your /etc/ directory for most linux distros.

------------------------------------------
# Sample dhcpd.conf
#

ddns-update-style ad-hoc; # This is the default. You can set it to none

# option definitions common to all supported networks...
# You need to change this one to your own setting

option domain-name "yourdomain.com";

# Your name servers. You can normally find these in
# your /etc/resolv.conf file. These will be distributed to all DHCP
# clients.

option domain-name-servers 10.1.1.1, 65.39.196.215, 65.39.192.130;

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;

# Configuration for an internal subnet.
subnet 10.1.1.0 netmask 255.255.255.0 {
range 10.1.1.2 10.1.1.25; # The range of ip addresses it will give out ( from .2 - .25 )
option domain-name-servers 10.1.1.1, 65.39.196.215, 65.39.192.130; # Change to your DNS
option domain-name "mydomain.com"; # You need to change this to your own setting
option routers 10.1.1.1; # Your gateway, your machine that is connected to the internet
option broadcast-address 10.1.1.255;
default-lease-time 600;
max-lease-time 7200;

}

-------------------------------------------

After your done editing your dhcpd.conf you can now restart your machine by typing
/sbin/service dhcpd restart . If it encounters errors you can view them by typing cat /var/log/messages or tail -f /var/log/messages

For testing you can set your workstations ip address to dynamic and try connecting it to the network. As soon as it starts up you can type this command in linux as root ifconfig in windows you can type ipconfig /all


I hope this tutorial helped you in a way.

No comments: