Setting up a Linux DHCP server


Today we are going  install and set up a Linux DHCP server.  Linux Mint 9 was used in this tutorial but the steps are identical for the majority of recent distributions.

First thing to do is to give your server a static ip address. For details on how to do this read this.

Now we need to install the dhcp package.  Open up a terminal and type:

sudo apt-get install dhcp3-server

There are two main files /etc/default/dhcp3-server and /etc/dhcp3/dhcpd.conf which we will need to configure so lets take the first.  Open up a terminal and using your favourite text editor type:

sudo gedit /etc/default/dhcp3-server

You should get the following:

———————————————————————————————–

# 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″

————————————————————————————————–

Replace eth0 above with the name of your network interface that you want the server to lease addresses on.  Onto the next file.  Open up a terminal and type:

sudo gedit /etc/dhcp3/dhcdp.conf

which should give you the output below.

————————————————————————————————-

#
#   DHCP Server Config File
#
ddns-update-style none;
ignore client-updates;

lease-file-name “/var/lib/dhcp3/dhcp.leases”;
authoritative;

option domain-name                      “comtech.com”;
default-lease-time                     600;
max-lease-time                         7200;

subnet 192.168.1.0 netmask 255.255.255.0 {
option routers                  192.168.1.1;
option subnet-mask              255.255.255.0;

option broadcast-address        192.168.1.255;
option domain-name-servers      192.168.1.4, 192.168.1.1;

option ntp-servers              192.168.1.4;
option netbios-name-servers     192.168.1.4;
option netbios-node-type        8;
range   192.168.1.10   192.168.1.200;
}

————————————————————————————————-

This needs a little bit of explaining.

1. The dhcp.lease file is where all the leases given out by the server will be stored.  Make sure this is /var/lib/dhcp3/dhcp.leases.

2. The option domain name is your dns zone name.  For example mine is set to comtech.com.

3. Range should be the range of ip addresses that you want the server to give out to clients.

Using the above output as a guide modify your file accordingly.  Next thing to do is actually create the dhcp.lease file.  In your terminal type:

sudo touch /var/lib/dhcp3/dhcp.leases

Now restart the dhcp service by typing:

sudo service dhcp3-server restart

Thats it!! Your dhcp server should be running, however it is best to check.  Open up a terminal and type:

sudo netstat -uap

which will show you the following information:

————————————————————————————————

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 chris-server.loc:domain *:*                                 1072/named
udp        0      0 localhost:domain        *:*                                 1072/named
udp        0      0 *:bootps                *:*                                 1829/dhcpd3
udp        0      0 *:mdns                  *:*                                 625/avahi-daemon: r
udp        0      0 *:35246                 *:*                                 625/avahi-daemon: r
udp6       0      0 [::]:domain             [::]:*                              1072/named

————————————————————————————————

This shows that the dhcp daemon is working.

About the Author

Hi I am Chris the owner of ComTech. I provide IT Support, Laptop repairs and Computer repairs to both personal and business clients in and around Stirling. For a list of what I can offer you why not visit my website www.comtech247.net where you will find my blog, testimonials, services and much more.  Start supporting a local business today so I can start supporting you.

If you found this blog useful then why not sign up to my RSS Feed for news, tutorials, views and general techie stuff!!

 

 

This entry was posted in Blog and tagged computer repair, dhcp, IT Support, laptop repairs, linux, server, stirling. Bookmark the permalink.

2 Responses to Setting up a Linux DHCP server

  1. Sharen says:

    I want to give thanks a whole lot for that work you have made in writing this piece of writing. I am hoping the same perfect job by you down the road also.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current month ye@r day *