Home Download Debian

Installing a DHCP server under Debian server

"DHCP" is the acronim for Dynamic Host Configuration Protocol, which is a protocol that handles assignment of IP addresses, subnet masks, default routers, dns servers, etc for all those computer clients that have no static IP address. In my case, DHCP is useful for assigning IP addresses to all clients that are using my Local Area Connection.

Requirements for setting up a DHCP server:
* make sure there are no other DHCP server in your LAN, for example, a hardware router.
* make sure you have no other DHCP programs installed in your server, like i had. I was struggling to find out why i was unable to setup my own DHCP server, and i forgot about dnsmasq.

LAN setup:
* i have a linuxbox running Debian Server, which is making ICS and has a sharing system through Samba. I'm using a network, netmask and broadcast address The NIC is eth1.
* The gateway is the server itself, which has as it's IP address.
* The DNS servers i use are and, OpenDNS servers.
* The range of IP adresess that can be assigned to our clients are to

Installing DHCP server:

As root, run the following command, which will install our DHCP server:
apt-get install dhcp3-server

After installing, the DHCP server will try to startup and will fail. We need to configure it first. Backup the config file (it's optional):

cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak

Edit the config file, delete everything and replace with the following:

ddns-update-style none;

option domain-name-servers,;

default-lease-time 86400;
max-lease-time 604800;


subnet netmask {
        option subnet-mask;
        option broadcast-address;
        option routers;

- "ddns-update-style none" will instruct DHCP server to update a DNS server if the ip address of a server in yuor LAN has changed. As we assign static ip addresses, we can leave it to none;
- "option domain-name-servers," are the DNS ip addresses which will be assigned to your LAN clients. You may use the providers ones;
- "default-lease-time, max-lease-time" a client may tell to DHCP server for how long it would like to get an IP address. If it doesn't do this, the server assigns an IP address for default-lease-time seconds; if it does, the server grants the requested time, but only up to max-lease-time seconds;
- "authoritative" if it's not set, if a client requests an address that the server knows nothing about and the address is incorrect for that network segment, the server will not send a DHCPNAK (which tells the client it should stop using the address). We want it to be set;
- "subnet" the subnet we use. you need to end it with zero
- "netmask" the netmask we use. If you don't know it, use subnetmask calculator;
- "range" tells then DHCP server from which range it can assign IP addresses to clients;
- "option subnet-mask" the subnetmask that will be assigned to clients;
- "option broadcast-address" the broadcast address we use;
- "option routers" the gateway will be assigned to clients;

To start/restart the DHCP server:

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

Resources: man dhcpd, howtoforge.com


Post a Comment