Install and configure DHCP Server on Ubuntu 13.04 12.10 12.04 Debian

Install and configure DHCP Server on Ubuntu 13.04 12.10 12.04 Debian

DHCP Server topology

1. Install dhcp server on Ubuntu / Debian

root@ubuntu:~# sudo apt-get install isc-dhcp-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘isc-dhcp-server’ instead of ‘dhcp3-server’
Suggested packages:
isc-dhcp-server-ldap
The following NEW packages will be installed:
isc-dhcp-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 916 kB of archives.
After this operation, 2,126 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ raring/main isc-dhcp-server amd64 4.2.4-5ubuntu2 [916 kB]
Fetched 916 kB in 8s (111 kB/s)
Preconfiguring packages …
Selecting previously unselected package isc-dhcp-server.
(Reading database … 59498 files and directories currently installed.)
Unpacking isc-dhcp-server (from …/isc-dhcp-server_4.2.4-5ubuntu2_amd64.deb) …
Processing triggers for man-db …
Processing triggers for ureadahead …
ureadahead will be reprofiled on next reboot
Setting up isc-dhcp-server (4.2.4-5ubuntu2) …
Generating /etc/default/isc-dhcp-server…
isc-dhcp-server start/running, process 8146
isc-dhcp-server6 stop/waiting
Processing triggers for ureadahead …
root@ubuntu:~#

2.  If you have many network cards in your Ubuntu server, then you have to select the network card on which your server will be listen for DHCP. (Optional)

root@ubuntu:/etc/dhcp# sudo nano /etc/default/isc-dhcp-server
# Defaults for isc-dhcp-server initscript
# sourced by /etc/init.d/isc-dhcp-server
# installed at /etc/default/isc-dhcp-server by the maintainer scripts#
# This is a POSIX shell fragment
## Path to dhcpd’s config file (default: /etc/dhcp/dhcpd.conf).
#DHCPD_CONF=/etc/dhcp/dhcpd.conf# Path to dhcpd’s PID file (default: /var/run/dhcpd.pid).
#DHCPD_PID=/var/run/dhcpd.pid

# Additional options to start dhcpd with.
# Don’t use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=””

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. “eth0 eth1″.
INTERFACES=”eth0
root@ubuntu:/etc/dhcp#

3. Configure DHCP Server with address pool, subnet mask, gateway … to DHCP Clients

Backup dhcp configuration

root@ubuntu:/etc/dhcp# sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak

Create new dhcp configuration

root@ubuntu:/etc/dhcp# rm /etc/dhcp/dhcpd.conf
root@ubuntu:/etc/dhcp# nano /etc/dhcp/dhcpd.conf
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.129.0;
option routers 192.168.129.254;
option domain-name-servers 192.168.1.1, 8.8.8.8;
option domain-name “ithelpblog.com”;
subnet 192.168.129.0 netmask 255.255.255.0
{
range 192.168.129.100 192.168.129.200;
}
root@ubuntu:/etc/dhcp

4. Restart DHCP Server on Ubuntu/Debian

root@ubuntu:/etc/dhcp# /etc/init.d/isc-dhcp-server restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service isc-dhcp-server restartSince the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop isc-dhcp-server ; start isc-dhcp-server. The restart(8) utility is also available.
isc-dhcp-server start/running, process 8501
root@ubuntu:/etc/dhcp# /etc/init.d/isc-dhcp-server restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service isc-dhcp-server restartSince the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop isc-dhcp-server ; start isc-dhcp-server. The restart(8) utility is also available.
isc-dhcp-server stop/waiting
isc-dhcp-server start/running, process 8521
root@ubuntu:/etc/dhcp#

5. Configure DHCP Client to receive IP from DHCP Server

http://ithelpblog.com/os/linux/redhat/centos-redhat/configure-dhcp-client-on-centos-6-4-6-3-5-9-redhat-rhel-fedora-18/

http://ithelpblog.com/os/linux/debian/ubuntu-debian/configure-dhcp-client-on-ubuntu-13-04-12-10-12-04-debian/

That’s all. Thanks for using IThelpblog.com.

 

 

One comment to Install and configure DHCP Server on Ubuntu 13.04 12.10 12.04 Debian

  • Paul Godden  says:

    A great article – with a few options that weren’t in the Ubuntu ones.

    I’m having issues even getting it started ATM though! I’ve run through lots of different tutorials that all end something like “And that’s it! All done!” Nope – not at all for me.

    Doing a netstat -uap shows DHCP isn’t running at all – and when you restart the service with service isc-dhcp-server restart the lines read:

    stop: Unknown instance:
    isc-dhcp-server start/running, process 3178

    Restarting again creates the same message (PID changes of course) – this points to it not even being able to start the service initially. Any ideas as to why it isn’t working!? Starting to get frustrated now with a system that’s normally child’s play to set up on any other system..

    My settings are the same as yours although using the 192.168.1.0/24 subnet. I’ve turned off the router’s dhcp server. There’s also 1 ethernet card set up in the server, so “eth0” is in the isc-dhcp-server file in /etc/default.

    One thing I did notice is when it was originally installed, after checking this file it had nothing in it at all. Just two quotes. Also the server has a static IP – which is pretty normal lol so wouldn’t expect that to be interfering somehow with the DHCP config. The ranges I’m allowing are from 192.168.1.1 to 199 – all static IPs on the LAN are 200+

    Really confused as to why it isn’t working – any ideas would be gratefully appreciated =)

Leave a reply

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=""> <s> <strike> <strong>