DHCP Server Installation

From Scottworld
Jump to navigation Jump to search

We will now set up a DHCP Server and configure it to hand out a specific range of addresses and update DNS (once we set it up)

Install the DHCP server package.

sudo apt-get install isc-dhcp-server

It will fail on startup as it is not configured yet.

service isc-dhcp-server stop

Configure the interface to listen on

nano /etc/default/isc-dhcp-server

Change the parameter for "interfaces"

INTERFACES="br0" (in our case we use br0 as we are using a bridge)

Configure /etc/dhcp/dhcpd.conf

nano /etc/dhcp/dhcpd.conf

The following sample config file sets up the following parameters.

  • Hands out IP addresses in the range 192.168.3.10 192.168.3.49
  • Sets the following clients default settings
    • default router = 192.168.3.1
    • domain-name-servers 192.168.3.200, 192.168.3.1;
    • domain-name "scottworld.net";
    • routers 192.168.3.1;
    • broadcast-address 192.168.3.255;
    • It reserves a number of addresses by mac address for certain devices / hosts.

Its will also attempt to dynamically update DNS with new clients. (When we configure it)

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-updates on;
ddns-update-style standard;
allow unknown-clients;
use-host-decl-names on;

# Definition of RFC 4833 Timezone Options

option tz-posix-string code 100 = string;
option tz-database-string code 101 = string;

# option definitions common to all supported networks...
option domain-name "scottworld.net";
option ntp-servers 192.168.3.200;
option time-servers 192.168.3.200;
option time-offset 0;
option tz-database-string "Europe/London";
option tz-posix-string "GMT0BST,M3.5.0/01:00,M10.5.0/01:00";
option domain-name-servers 192.168.3.200;

default-lease-time 14400;
max-lease-time 86400;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# Scottworld DNS zones
zone scottworld.net. {
        primary 192.168.3.200;
}

zone 3.168.192.in-addr.arpa. {
        primary 192.168.3.200;
}

# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.

#subnet 10.254.239.32 netmask 255.255.255.224 {
#  range dynamic-bootp 10.254.239.40 10.254.239.60;
#  option broadcast-address 10.254.239.31;
#  option routers rtr-239-32-1.example.org;
#}

# A slightly different configuration for an internal subnet.
subnet 192.168.3.0 netmask 255.255.255.0 {
        range 192.168.3.10 192.168.3.50;
        option broadcast-address 192.168.3.255;
        option routers 192.168.3.1;
        ddns-domainname "scottworld.net.";
        ddns-rev-domainname "in-addr.arpa.";
}

# Fixed IP addresses can also be specified for hosts.   These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP.   Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.

host saturn {
  hardware ethernet FC:AA:14:E2:72:21;
  fixed-address 192.168.3.5;
}

host ddhomerun {
  hardware ethernet 00:18:DD:23:17:4F;
  fixed-address 192.168.3.50;
}

host pi {
  hardware ethernet DC:A6:32:19:ED:C1;
  fixed-address 192.168.3.201;
}



Restart DHCP server and test (DNS will still be broken we need to do that next)

service isc-dhcp-server restart