How to setup a DHCP server

How to setup a DHCP server

TBD

https://wiki.debian.org/DHCP_Server

 

OS: Debian 8

 

Init Scripts (system services)

  • /etc/init.d/isc-dhcp-server
    • Uses DHCPv4 conf file /etc/dhcp/dhcpd.conf
  • /etc/init.d/isc-dhcpv6-server
    • Uses DHCPv6 conf file /etc/dhcp/dhcpd6.conf

Restart the service after any changes made.

Any errors, check /var/log/syslog

Examples for the config:

DHCPv4 Conf File (/etc/dhcp/dhcpd.conf)

authoritative;

default-lease-time 1800;
max-lease-time 1800;

log-facility local7;

# vm-4005
subnet 40.0.0.0 netmask 255.255.0.0 {
  range 40.0.1.1 40.0.255.254;
  option domain-name-servers 40.0.0.8;
  option domain-search "eng.vmware.com", "vmware.com";
  option routers 40.0.0.1;
  option host-name = concat("vlan4005-", binary-to-ascii(10, 8, "-", leased-address) );
}

# vmotion-4000
subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.151 192.168.100.250;
  option domain-name-servers 192.168.100.8;
  option domain-search "eng.vmware.com", "vmware.com";
  option routers 192.168.100.1;
}

# vsan-4001
subnet 192.168.130.0 netmask 255.255.255.0 {
  range 192.168.130.151 192.168.130.250;
  option domain-name-servers 192.168.130.8;
  option domain-search "eng.vmware.com", "vmware.com";
  option routers 192.168.130.1;
}

# vsan-4002
subnet 192.168.140.0 netmask 255.255.255.0 {
  range 192.168.140.151 192.168.140.250;
  option domain-name-servers 192.168.140.8;
  option domain-search "eng.vmware.com", "vmware.com";
  option routers 192.168.140.1;
}

# nfs-4003
subnet 192.168.150.0 netmask 255.255.255.0 {
  range 192.168.150.151 192.168.150.250;
# option domain-name-servers 192.168.150.8;
# option domain-search "eng.vmware.com", "vmware.com";
# option routers 192.168.150.1;
}

# iscsi-4004
subnet 192.168.160.0 netmask 255.255.255.0 {
  range 192.168.160.151 192.168.160.250;
# option domain-name-servers 192.168.160.8;
# option domain-search "eng.vmware.com", "vmware.com";
# option routers 192.168.160.1;
}

# vmotion-4020
subnet 192.168.120.0 netmask 255.255.255.0 {
  range 192.168.120.151 192.168.120.250;
  option domain-name-servers 192.168.120.8;
  option domain-search "eng.vmware.com", "vmware.com";
  option routers 192.168.120.1;
}

# nfs-4023
subnet 192.168.170.0 netmask 255.255.255.0 {
  range 192.168.170.151 192.168.170.250;
  option domain-name-servers 192.168.170.8;
  option domain-search "eng.vmware.com", "vmware.com";
  option routers 192.168.170.1;
}

# iscsi-4024
subnet 192.168.180.0 netmask 255.255.255.0 {
  range 192.168.180.151 192.168.180.250;
# option domain-name-servers 192.168.180.8;
# option domain-search "eng.vmware.com", "vmware.com";
# option routers 192.168.180.1;
}

# ft-4026
subnet 192.168.190.0 netmask 255.255.255.0 {
  range 192.168.190.151 192.168.190.250;
  option domain-name-servers 192.168.190.8;
  option domain-search "eng.vmware.com", "vmware.com";
  option routers 192.168.190.1;
}

# prov-4007
subnet 192.168.200.0 netmask 255.255.255.0 {
  range 192.168.200.151 192.168.200.250;
  option domain-name-servers 192.168.200.8;
  option domain-search "eng.vmware.com", "vmware.com";
  option routers 192.168.200.1;
}

# prov-4027
subnet 192.168.210.0 netmask 255.255.255.0 {
  range 192.168.210.151 192.168.210.250;
  option domain-name-servers 192.168.210.8;
  option domain-search "eng.vmware.com", "vmware.com";
  option routers 192.168.210.1;
}

# VTEP-4008
subnet 192.168.220.0 netmask 255.255.255.0 {
  range 192.168.220.51 192.168.220.250;
  option domain-name-servers 192.168.220.8;
  option domain-search "eng.vmware.com", "vmware.com";
  option routers 192.168.220.1;
}

# vlan-4009
subnet 192.168.240.0 netmask 255.255.255.0 {
  range 192.168.240.151 192.168.240.250;
  option domain-name-servers 192.168.240.8;
  option domain-search "eng.vmware.com", "vmware.com";
  option routers 192.168.240.1;
}

DHCHv6 Conf File (/etc/dhcp/dhcpd6.conf)

authoritative;

default-lease-time 7200;
preferred-lifetime 7200;
option dhcp-renewal-time 3600;
option dhcp-rebinding-time 5400;
#allow leasequery;
#option dhcp6.info-refresh-time 21600;
#dhcpv6-lease-file-name "/usr/local/var/db/dhcpd6.leases";

log-facility local7;

# vmotion-4000
subnet6 2016:192:168:100::/64 {
    range6 2016:192:168:100::1000 2016:192:168:100::8000;
    option dhcp6.name-servers 2016:192:168:100::8;
    option dhcp6.domain-search "internal.example.org";
}

# vsan-4001
subnet6 2016:192:168:130::/64 {
    range6 2016:192:168:130::1000 2016:192:168:130::8000;
    option dhcp6.name-servers 2016:192:168:130::8;
    option dhcp6.domain-search "internal.example.org";
}

# vsan-4002
subnet6 2016:192:168:140::/64 {
    range6 2016:192:168:140::1000 2016:192:168:140::8000;
    option dhcp6.name-servers 2016:192:168:140::8;
    option dhcp6.domain-search "internal.example.org";
}

# nfs-4003
subnet6 2016:192:168:150::/64 {
    range6 fc00:192:168:150::1000 fc00:192:168:150::8000;
    option dhcp6.name-servers fc00:192:168:150::8;
    option dhcp6.domain-search "internal.example.org";
}

# iscsi-4004
subnet6 2016:192:168:160::/64 {
    range6 2016:192:168:160::1000 2016:192:168:160::8000;
    option dhcp6.name-servers 2016:192:168:160::8;
    option dhcp6.domain-search "internal.example.org";
}

# vm-4005
subnet6 2016:40::/64 {
    range6 2016:40::1000 2016:40::ffff;
    option dhcp6.name-servers 2016:40::8;
    option dhcp6.domain-search "internal.example.org";
}

# ft-4006
subnet6 2016:192:168:110::/64 {
    range6 2016:192:168:110::1000 2016:192:168:110::8000;
    option dhcp6.name-servers 2016:192:168:110::8;
    option dhcp6.domain-search "internal.example.org";
}

# vmotion-4020
subnet6 2016:192:168:120::/64 {
    range6 2016:192:168:120::1000 2016:192:168:120::8000;
    option dhcp6.name-servers 2016:192:168:120::8;
    option dhcp6.domain-search "internal.example.org";
}

# nfs-4023
subnet6 2016:192:168:170::/64 {
    range6 2016:192:168:170::1000 2016:192:168:170::8000;
    option dhcp6.name-servers 2016:192:168:170::8;
    option dhcp6.domain-search "internal.example.org";
}

# iscsi-4024
subnet6 2016:192:168:180::/64 {
    range6 2016:192:168:180::1000 2016:192:168:180::8000;
    option dhcp6.name-servers 2016:192:168:180::8;
    option dhcp6.domain-search "internal.example.org";
}

# ft-4026
subnet6 2016:192:168:190::/64 {
    range6 2016:192:168:190::1000 2016:192:168:190::8000;
    option dhcp6.name-servers 2016:192:168:190::8;
    option dhcp6.domain-search "internal.example.org";
}

# prov-4007
subnet6 2016:192:168:200::/64 {
    range6 2016:192:168:200::1000 2016:192:168:200::8000;
    option dhcp6.name-servers 2016:192:168:200::8;
    option dhcp6.domain-search "internal.example.org";
}

# prov-4027
subnet6 2016:192:168:210::/64 {
    range6 2016:192:168:210::1000 2016:192:168:210::8000;
    option dhcp6.name-servers 2016:192:168:210::8;
    option dhcp6.domain-search "internal.example.org";
}

# vtep-4008
subnet6 2016:192:168:220::/64 {
    range6 2016:192:168:220::1000 2016:192:168:220::8000;
    option dhcp6.name-servers 2016:192:168:220::8;
    option dhcp6.domain-search "internal.example.org";
}

# vlan-4009
subnet6 2016:192:168:240::/64 {
    range6 2016:192:168:240::1000 2016:192:168:240::8000;
    option dhcp6.name-servers 2016:192:168:240::8;
    option dhcp6.domain-search "internal.example.org";
}

Interfaces conf (/etc/network/interfaces)

source /etc/network/interfaces.d/*

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

allow-hotplug eth0

iface eth0 inet dhcp

# This is an autoconfigured IPv6 interface

iface eth0 inet6 auto

# vmotion-4000

auto eth1.4000

allow-hotplug eth1.4000

iface eth1.4000 inet static

    address 192.168.100.254/24

iface eth1.4000 inet6 static

    address 2016:192:168:100::254

    netmask 64

    accept_ra 0

# vsan-4001

auto eth1.4001

allow-hotplug eth1.4001

iface eth1.4001 inet static

    address 192.168.130.254/24

iface eth1.4001 inet6 static

    address 2016:192:168:130::254

    netmask 64

    accept_ra 0

# vsan-4002

auto eth1.4002

allow-hotplug eth1.4002

iface eth1.4002 inet static

    address 192.168.140.254/24

iface eth1.4002 inet6 static

    address 2016:192:168:140::254

    netmask 64

    accept_ra 0

# nfs-4003

auto eth1.4003

allow-hotplug eth1.4003

iface eth1.4003 inet static

    address 192.168.150.254/24

iface eth1.4003 inet6 static

    address fc00:192:168:150::254

    netmask 64

    accept_ra 0

# iscsi-4004

auto eth1.4004

allow-hotplug eth1.4004

iface eth1.4004 inet static

    address 192.168.160.254/24

iface eth1.4004 inet6 static

    address 2016:192:168:160::254

    netmask 64

    accept_ra 0

# vm-4005

auto eth1.4005

allow-hotplug eth1.4005

iface eth1.4005 inet static

    address 40.0.0.254/16

iface eth1.4005 inet6 static

    address 2016:40::254

    netmask 64

    accept_ra 0

# vmotion-4020

auto eth1.4020

allow-hotplug eth1.4020

iface eth1.4020 inet static

    address 192.168.120.254/24

iface eth1.4020 inet6 static

    address 2016:192:168:120::254

    netmask 64

    accept_ra 0

# nfs-4023

auto eth1.4023

allow-hotplug eth1.4023

iface eth1.4023 inet static

    address 192.168.170.254/24

iface eth1.4023 inet6 static

    address 2016:192:168:170::254

    netmask 64

    accept_ra 0

# iscsi-4024

auto eth1.4024

allow-hotplug eth1.4024

iface eth1.4024 inet static

    address 192.168.180.254/24

iface eth1.4024 inet6 static

    address 2016:192:168:180::254

    netmask 64

    accept_ra 0

# ft-4026

auto eth1.4026

allow-hotplug eth1.4026

iface eth1.4026 inet static

    address 192.168.190.254/24

iface eth1.4026 inet6 static

    address 2016:192:168:190::254

    netmask 64

    accept_ra 0

# prov-4007

auto eth1.4007

allow-hotplug eth1.4007

iface eth1.4007 inet static

    address 192.168.200.254/24

iface eth1.4007 inet6 static

    address 2016:192:168:200::254

    netmask 64

    accept_ra 0

# prov-4027

auto eth1.4027

allow-hotplug eth1.4027

iface eth1.4027 inet static

    address 192.168.210.254/24

iface eth1.4027 inet6 static

    address 2016:192:168:210::254

    netmask 64

    accept_ra 0

# vtep-4008

auto eth1.4008

allow-hotplug eth1.4008

iface eth1.4008 inet static

    address 192.168.220.254/24

iface eth1.4008 inet6 static

    address 2016:192:168:220::254

    netmask 64

    accept_ra 0

# vlan-4009

auto eth1.4009

allow-hotplug eth1.4009

iface eth1.4009 inet static

    address 192.168.240.254/24

iface eth1.4009 inet6 static

    address 2016:192:168:240::254

    netmask 64

    accept_ra 0

Leave a Reply

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

%d bloggers like this: