/ Server / Debian Router - Dhcp Server Setup


Published:2015-06-12T13:23:24Z Edited:2017-06-22T13:23:24Z

We've learned previously how to set up unbound dns server as caching dns server for our LAN users, in this article we'll configure dhcp server from which a unique ip address for each client assigned as a bonus automatically configure dns server settings for them.

 
 
In this debian router articles series also:
  1. Introduction.
  2. Hardware Requirements.
  3. Software installation.
  4. Basic Setup.
  5. /etc/network/Interfaces Configuration.
  6. Unbound dns server setup.
  7. DHCP server setup. (We are Here!)
  8. Squid setup.
  9. Final step iptables and sysctl.conf configuration.

 

We need to tell isc-dhcp-server where to listen and serve dhcp request, to do that we modify /etc/default/isc-dhcp-server as follows:

Our LAN is on eth1 so set

INTERFACESv4="eth1"

the whole file will look like:

# Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)

# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf

# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPDv4_PID=/var/run/dhcpd.pid
#DHCPDv6_PID=/var/run/dhcpd6.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".
INTERFACESv4="eth1"
INTERFACESv6=""
Next edit /etc/dhcp/dhcpd.conf 
Tell dhcp server that we rely on it to configure our LAN, so uncomment or add:
authoritative;
The following LAN setup support upto 248 clients/users
 
######################
# internal network
######################
subnet 10.5.5.0 netmask 255.255.255.0 {
 range 10.5.5.6 10.5.5.254;
 option domain-name-servers 10.5.5.1;
 option routers 10.5.5.1;
 option broadcast-address 10.5.5.255;
 default-lease-time 600;
 max-lease-time 7200;
}

 

Give LAN-AP a fixed ip address, this address must not be available for dynamiclly assigned ip addresses range, notice that we've already chosen 10.5.5.5 which is out of the range  [10.5.5.6 - 10.5.5.254]

replace 00:00:00:00:00:00 with your LAN-AP mac address:

# LAN-AP need fixed ip address 10.5.5.5
# 00:00:00:00:00:00 mustbe replaces with router hardware mac address
host router{
hardware ethernet 00:00:00:00:00:00;
fixed-address 10.5.5.5;
}
 The whole /etc/dhcp/dhcpd.conf will look like the following (comments strip for brevity):
 
# 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-update-style none;

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

######################
# internal network
######################
subnet 10.5.5.0 netmask 255.255.255.0 {
 range 10.5.5.6 10.5.5.254;
 option domain-name-servers 10.5.5.1;
 option routers 10.5.5.1;
 option broadcast-address 10.5.5.255;
 default-lease-time 600;
 max-lease-time 7200;
}

# LAN-AP need fixed ip address 10.5.5.5
# 00:00:00:00:00:00 mustbe replaces with router hardware mac address
host router{
 hardware ethernet 00:00:00:00:00:00;
 fixed-address 10.5.5.5;
}

Next Squid setup

Next
Debian Router - Network Interfaces Configuration
Previous
openbsd pf rules for webservers
Tags