How to setup a Raspberry Pi as a DHCP Server in 2 minutes

This quick tutorial assumes you understand Linux and just need the raw steps to get dhcp working on the pi.

It should work on any Debian installation including ubuntu or Mint.

ssh to your pi

Become root:
$ sudo su –

# apt-get install isc-dhcp-server
# vi /etc/network/interfaces

Insert the following text:-

auto <e.g. eth0>
iface <e.g. eth0> inet static
address <IP Address of pi – e.g. 192.168.1.100>
mask <e.g. 255.255.255.0>
gateway <e.g. 192.168.1.1>

Modify the DHCP config file

# vi /etc/dhcp/dhcpd.conf

subnet <starting-IP-address-of-your-network> netmask <starting-IP-address-of-your-network> {
range <first-IP-address-of-your-DHCP-address-range> <last-IP-address-of-your-DHCP-address-range>;
option routers <the-IP-address-of-your-gateway-or-router>;
option broadcast-address <the-broadcast-IP-address-for-your-network>;

# vi /etc/default/isc-dhcp-server

DHCPD_CONF=/etc/dhcp/dhcpd.conf
DHCPD_PID=/var/run/dhcpd.pid
INTERFACES=”<your interface e.g. eth0>”

# service isc-dhcp-server restart

The dhcp server keeps its current set of leases in a text file in /var/lib/dhcp/dhcpd.leases

Remember to disable any existing DHCP server on your LAN.

DONE!

Posted in IT Tagged with: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*