Build DHCP server on ubuntu linux

DHCP server is server who providing or giving ip address on each client, example you want giving ten ip address for your client whose on scope 10.10.10.1 until 10.10.10.10

hope this article help you


Step by step

  1. set ip address nic
  2. install dhcp server package
  3. config dhcp server

1. set nic ipaddress

let say you have ip 10.10.10.254/24 eth0
execute this command on your terminal

"ip addr add 10.10.10.254/24 dev eth0"

you can make it permanent when you fill above script to rc.local file


2. install bind package

execute "apt-get update" and
"apt-get install dhcp3-server"


3. config bind server

edit file dhcpd.conf on /etc/dhcp3 folder
put this
ddns-update-style none;
subnet 10.0.0.0 netmask 255.0.0.0 {
range 10.10.10.1 10.10.10.10;
option routers 10.10.10.254, www.zoepha.co.cc;
option domain-name-servers 10.10.10.254, www.zoepha.co.cc;
option domain-name "www.zoepha.co.cc";
default-lease-time 600;
max-lease-time 7200;

host emak {
next-server www.zoepha.co.cc;
hardware ethernet 00:EA:01:02:EB:4B;
fixed-address 10.10.10.253;
}
}


explanation
----------------------------------------
assumtion you have dns server with name www.zoepha.co.cc
range 10.10.10.1 10.10.10.10; >> client will get ip between 10.10.10.1 until 10.10.10.10
option routers 10.10.10.254, www.zoepha.co.cc; >> client will get gateway 10.10.10.254
option domain-name-servers 10.10.10.254, www.zoepha.co.cc; >> client will get dns 10.10.10.254
----------------------------------------
default-lease-time 600;
max-lease-time 7200; >> two this config for client ip address expiration, and client will tell server to get new ip address repeat on 10 minut, max 7200 second alias 120 on minute 2 on hour
-------------------------------------------------
host emak {
next-server http://www.zoepha.co.cc;
hardware ethernet 00:EA:01:02:EB:4B;
fixed-address 10.10.10.253;
}
it will specify interface whose mac address 00:EA:01:02:EB:4B will get ip 10.10.10.253

restart your dhcp server with this command
/etc/init.d/dhcp3-server restart


i dont create the image, i got from experts-exchange.com