Wednesday, February 08, 2012

Install DHCP on Linux

Install DHCP on Linux

root@servert# apt-get install dhcp3-server

====================================
sample config

root@servert# cat /etc/dhcp3/dhcpd.conf
ddns-update-style none;
log-facility local7;
ignore client-updates;
option domain-name-servers 192.168.2.1, 172.30.0.1;
default-lease-time 600;
max-lease-time 3600;
authoritative;
subnet 192.168.2.0 netmask 255.255.255.0 {
        range 192.168.2.200 192.168.2.229;
        option subnet-mask 255.255.255.0;
        option broadcast-address 192.168.2.255;
        option routers 192.168.2.1;
}



root@servert# cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.168.2.1
    netmask 255.255.255.0
    network 192.168.2.0
    broadcast 192.168.1.255




root@servert# cat /etc/default/dhcp3-server
# 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="eth0"


=======================================================
check lease time

Note:   This time format refer UTC +0 cannot modify any more

root@servert# cat /var/lib/dhcp3/dhcpd.leases
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-V3.1.3

lease 192.168.2.200 {
  starts 3 2012/02/08 14:08:08;
  ends 3 2012/02/08 14:18:08;
  tstp 3 2012/02/08 14:18:08;
  cltt 3 2012/02/08 14:08:08;
  binding state active;
  next binding state free;
  hardware ethernet 00:50:56:C0:00:08;
  uid "\001\350\232\217]4\366";
  client-hostname "pc001";
}
lease 192.168.2.200 {
  starts 3 2012/02/08 14:13:08;
  ends 3 2012/02/08 14:23:08;
  cltt 3 2012/02/08 14:13:08;
  binding state active;
  next binding state free;
  hardware ethernet 00:50:56:C0:00:08;
  uid "\001\350\232\217]4\366";
  client-hostname "vmhost";
}

root@servert#

No comments:

Post a Comment