Žilinská univerzita > Fakulta riadenia a informatiky > Katedra informačných sietí

A VERY BASIC DHCP server configuration under Debian OS

This article describes a very basic configuration of DHCP server (isc-dhcp-server) under Debian OS.

 

Installing DHCP server:

#apt-get install isc-dhcp-server

*note: package isc-dhcp-server replaced the old dhcp3 package

 

We need to specify the port to bind to. To do this we need to edit the file "/etc/default/isc-dhcp-server":

INTERFACES="eth0"

Next and the last thing to do to configure our DHCP server is to specify subnetworks in its configuration file "/etc/dhcp/dhcpd.conf". Here is the example of the file:

#define that the dhcp server is configured correctly and is
#the authoritative served if multiple dhcp servers exist
authoritative;
 
#define the default (if not specified differently for subnet)
domain for all users
option domain-name "ps1.sk";

#define the default (if not specified differently for subnet) dns servers for all users
option domain-name-servers 1.254.0.1;

#specify the default lease and max lease time 
default-lease-time 86400;
max-lease-time 86400;

#for logging file (set for rsyslog)
log-facility local7;
 

#DEFINITION OF SUBNETS

subnet 1.1.0.0 netmask 255.255.0.0 {
  #lease addresses from this range:
  range 1.1.0.2 1.1.255.254;
  #if DHCP request comes from routers with there addresses (separated by commas): 
  option routers 1.1.0.1;             
 
  #define subnet specific parameters which will override global parameters, for example:
  #max-lease-time 7200;

  #you can specify statically mapped IP addresses to MAC addresses like this:  
  #  host print_server {
  #    hardware ethernet 00:01:23:e2:d1:22;
  #    fixed-address 1.1.0.2;         
  #}

  #if you need to specify groups of addresses which you must treat differently (for example different lease time or domain name), you can
  #specify address pools and define their specific values:
  #pool {
  #  range 1.1.0.2 1.1.0.10;
  #  max-lease-time 7200;
  #}
 
}

subnet 1.2.0.0 netmask 255.255.0.0 {
  range 1.2.0.2 1.2.255.254;
  option routers 1.2.0.1;             
}

#we need to specify default range for interfaces we are listening on.. 
#since we configured our server to listen only on eth0 (with IP 1.254.0.1),
#we need to scecify:
subnet 1.254.0.0 netmask 255.255.255.0 {
}

When the configuration is done, restart the dhcp server:

/etc/init.d/isc-dhcp-server restart

Done :)

If the server is complaining about something, see the "/var/log/syslog" for more details.

Groups: