Configuring a DHCP Server w/ Multiple Subnets on Linux

Category: Software and Systems Engineering
Author: Sean O'Donnell
Wed, Aug. 3rd, 2005 @ 3:33:23 (MDT)

The following is an example of how to configure a Linux Server that has 4 Ethernet/NIC cards, as a DHCP Server w/ Multiple Subnets.

This is generally for creating a Linux Software Router for the home or small office network.

Theoretically, the example configuration below, along with proper configuration of iptables, ipmasq'ing, and (a few =) ethernet switches, you can create a multi-subnet Stealth Firewall/NAT/Router, which would allow you to connect upto 100 computers per subnet, a total of 300 computers.

/etc/dhcpd.conf

##########################################################
# file: dhcpd.conf
#
# Configuration file for ISC dhcpd (see 'man dhcpd.conf')
#
# For more information regarding the ISC DHCP Daemon, 
# please visit: http://www.isc.org/sw/dhcp/
#
##########################################################
#
# Configuration Notes: 
#
# This configuration file assumes that you
# have a total of 4 NIC cards installed on your system, 
# with eth0 connecting (as a client) to a remote dhcp server. 
#
# This will assign a dhcp subnet to each additional NIC card 
# (eth1, eth2, and eth3), which can be used to create a 
# multi-subnet DHCP Server.
#
# Example by: Sean O'Donnell http://code.seanodonnell.com
#
##########################################################
#
# DHCP CLIENT CONFIGURATION SETTINGS
#

# use ad-hoc style name server updating procedures
ddns-update-style ad-hoc;

# this may be required for some network configurations,
# but seems to work fine without it on my LAN.
option domain-name "remote-name-server.com";

# assign the remote dhcp server hostname/ip addresses
option domain-name-servers ns1.remote-name-server.com, ns2.remote-name-server.com, 66.64.64.4, 66.64.64.5;

##########################################################
#
# DHCP SERVER CONFIGURATION SETTINGS
#

# assign the defaul lease time (seconds)
default-lease-time 600000000;

# assign the max lease time (seconds)
max-lease-time 720000000;

# eth1 subnet configuration
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.2 192.168.1.100;
  option routers 192.168.1.1;
  option broadcast-address 192.168.1.1;
}

# eth2 subnet configuration
subnet 192.168.2.0 netmask 255.255.255.0 {
  range 192.168.2.2 192.168.2.100;
  option routers 192.168.2.1;
  option broadcast-address 192.168.2.1;
}

# eth3 subnet configuration
subnet 192.168.3.0 netmask 255.255.255.0 {
  range 192.168.3.2 192.168.3.100;
  option routers 192.168.3.1;
  option broadcast-address 192.168.3.1;
}

##########################################################
# end config

The configuration above assumes that you have 4 Ethernet/NIC Cards installed on your system.

The 1st NIC (eth0) generally acts as a DHCP Client, and is plugged directly into a modem or external router/switch, which is controlled by a remote DHCP Server.

The 2nd (eth1), 3rd (eth2), and 4th (eth3) NIC's will be your DHCP Server Interfaces.

To begin running the DHCP Server, execute the following command (as root):

$ dhcpd

Copyleft (<) 1998-2019 www.seanodonnell.com