Debian Router - Dhcp Server Setup

Published:2021-06-06
Share:

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.

 

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

Read also

Debian Router - Unbound Dns Server Setup

In the previous article we''ve configured network interfaces, so by now debian box is connected to internet through WAN-AP on eth0 and to local network through LAN-AP on eth1. Today we''ll setup unbound dns server to serve dns queries for our awesome LAN clients.     In this debian router articles series also: Introduction . Hardware Requirements . Software installation . Basic Setup . /etc/network/Interfaces Configuration . Unbound dns server...

Using Linux Debian As Router Setup

In this articles series you will learn how to setup Linux (Debian) as a Router for home/business local networks, to spice things I''ll show how to add dns server, proxy/web caching server, and basic web traffic filter to our cute debian box.   In this series I''ll go over: Introduction . Hardware Requirements . Software installation . Basic Setup . /etc/network/Interfaces Configuration . Unbound dns server setup . DHCP server setup . Squid setup. ...

Debian Router - Squid Setup

We''ve configured the dhcp server , so what''s for today?! Today we''ll configure Squid for caching web traffic and access control.     In this debian router articles series also: Introduction . Hardware Requirements . Software installation . Basic Setup . /etc/network/Interfaces Configuration . Unbound dns server setup . DHCP server setup .  Squid setup . ( We are Here! ) Final step iptables and sysctl.conf configuration ...

Debian Router - Network Interfaces Configuration

In preparation of using debian as a router, We''ll configure network interfaces, after performing initial setup .     In this debian router articles series also: Introduction . Hardware Requirements . Software installation . Basic Setup . /etc/network/Interfaces Configuration. ( We are Here! ) Unbound dns server setup . DHCP server setup . Squid setup. Final step iptables and sysctl.conf configuration .   We''ll modify ...

Debian Router - Iptables And Sysctl.Conf Configuration

Tody we''ll finish configuring our awesome router, in the previous article we''d configured squid proxy, in this article we''ll pass all LAN traffic through squid using iptables.    In this debian router articles series also: Introduction . Hardware Requirements . Software installation . Basic Setup . /etc/network/Interfaces Configuration . Unbound dns server setup . DHCP server setup .  Squid setup .  Final step iptables a...