Pre-requisites:
A working LAN where clients can ping each other from static IP address's. For more information on configuring a Debian or Ubuntu server with a static IP address see this article.
Login as root;
sudo -i
Setting up DHCP is a fairly simple affair. We start by installing dhcp-server from the repositories;
apt-get install dhcp3-server
We need to tell it which interface to listen for client requests on;
vi /etc/default/dhcp3-server
Add your (space separated) interface(s) like so;
INTERFACES=”eth0″
There is a lot of useful documentation in the default configuration file, however this tends to make things a bit cluttered. I prefer a minimalist config file so we will backup the default one for future reference;
mv /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf.default
Now, we create a new config file;
vi /etc/dhcp3/dhcpd.conf
Add the following contents, modifying as applicable for your own network of course;
default-lease-time 600;
max-lease-time 7200;
subnet 10.1.1.0 netmask 255.255.255.0 {
range 10.1.1.10 10.1.1.200;
option subnet-mask 255.255.255.0;
option broadcast-address 10.1.1.255;
option routers 10.1.1.1;
option smtp-server 10.1.1.1;
option domain-name "tuxnetworks.net";
option domain-name-servers 10.1.1.1, 10.1.1.2;
host earth {
hardware ethernet 00:1f:d0:c0:3b:9d;
fixed-address 10.1.1.10;
}
}
Notes:
I have added a fixed address for the host "earth" identified by MAC address 00:1f:d0:c0:3b:9d. This is for illustrative purposes only and can be removed if it is not needed.
The above example assumes you have DNS servers running on the your network on hosts 10.1.1.1 and 10.1.1.2. If you want to use upstream DNS resolvers enter the addresses for your ISP DNS servers instead. Alternately you can use the servers provided by OpenDNS[1] or configure your own DNS server.
To apply the changes, restart the dhcp server daemon;
service dhcp3-server restart
Now you should refresh the IP address on a PC configured as a dhcp client and you should receive a shiny new DHCP lease.
Now that you have a DHCP server, why not improve it by adding DDNS (Dynamic DNS) updates so that your clients names are automagically added to your DNS Server?
[1] OpenDNS use error redirects (DNS Hijacking) as a way to generate income. If you are like me and don't like such shenanigans then I recommend that you configure your own DNS server.
1 comment:
These instructions are very easy to read and work up to 11.04 which has changed the location and names of the dhcp files.
Please check documentation specific for 11.04 and greater for correct procedure.
Post a Comment