License

Copyright (C) 2008-2017 Oliver Bohlen.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.

A copy of the license is included in the section entitled "GNU Free Documentation License".

Introduction

This documentation comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.

Howto: DHCP-Server for Gentoo Linux

If you want to manage your IPs in a central way you should use a DHCP-Server. This helps you to install and configure it.

If you want to use this solution you need the following howto(s) finished:

Required software

The required software has to be installed with the following command(s):
emerge net-misc/dhcp

Changes in /etc/conf.d/dhcpd

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /etc/conf.d/dhcpd

Changed on 17.11.09
Issued by olli
Beginning line 20

Only change this if you want to store your DHCP-Settings in your LDAP. This sets the configuration file for LDAP.


Before change
# DHCPD_CONF="/etc/dhcp/dhcpd.conf"
After change
DHCPD_CONF="/etc/dhcp/dhcpd.conf"

Changed on 17.11.09
Issued by olli
Beginning line 29

The Listen Interface


Before change
# DHCPD_IFACE=""
After change
DHCPD_IFACE="eth0"

Changes in /etc/conf.d/dhcpd-wlan

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /etc/conf.d/dhcpd-wlan

Changed on 17.11.09
Issued by olli
Beginning line 20

Config File fpr DHCP in WLAN Network


Before change
# DHCPD_CONF="/etc/dhcp/dhcpd.conf"
After change
DHCPD_CONF="/etc/dhcp/dhcpd-wlan.conf"

Changed on 17.11.09
Issued by olli
Beginning line 29

The Listen Interface


Before change
# DHCPD_IFACE=""
After change
DHCPD_IFACE="wlan0"

Changes in /etc/dhcp/dhcpd.conf

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /etc/dhcp/dhcpd.conf

Changed on 06.09.08
Issued by olli
Beginning line 1

DHCP Base settings only if you want to use DHCP without LDAP. After some default definitions like gateway, DNS Server, domain name,... it defines a range of IPs for clients. Change it according to your environment if you dont use DHCP over LDAP.


option domain-name "example.com";

default-lease-time 600;
max-lease-time 7200;

option subnet-mask XXX.XXX.XXX.XXX;
option broadcast-address XXX.XXX.XXX.XXX;
option domain-name-servers my.lan.ip.addr;
option ntp-servers my.lan.ip.addr;
option routers my.lan.ip.addr;
default-lease-time 7200;
max-lease-time 14400;
ddns-update-style none;
subnet my.lan.network.ip netmask XXX.XXX.XXX.XXX {
 range XXX.XXX.XXX.XXX XXX.XXX.XXX.XXX;
}

Changes in /etc/dhcp/dhcpd.conf

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /etc/dhcp/dhcpd.conf

Changed on 06.09.08
Issued by olli
Beginning line 35

Here are some Examples for fixed IPs of some DHCP-Hosts. (only if you don't use DHCP over LDAP)

host think-gabosh {
 hardware ethernet XX:XX:XX:XX:XX:XX;
 fixed-address XXX.XXX.XXX.XXX;
}

host dgabosh {
 hardware ethernet XX:XX:XX:XX:XX:XX;
 fixed-address XXX.XXX.XXX.XXX;
}

host ddgabosh {
 hardware ethernet XX:XX:XX:XX:XX:XX;
 fixed-address XXX.XXX.XXX.XXX;
}

host smallgabosh {
 hardware ethernet XX:XX:XX:XX:XX:XX;
 fixed-address XXX.XXX.XXX.XXX;
}

host backup-gabosh {
 hardware ethernet XX:XX:XX:XX:XX:XX;
 fixed-address XXX.XXX.XXX.XXX;
}

host gaboshberry {
 hardware ethernet XX:XX:XX:XX:XX:XX;
 fixed-address XXX.XXX.XXX.XXX;
}

host gaboshsleepberry {
 hardware ethernet XX:XX:XX:XX:XX:XX;
 fixed-address XXX.XXX.XXX.XXX;
}

Changes in /etc/dhcp/dhcpd-ldap.conf

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /etc/dhcp/dhcpd-ldap.conf

Changed on 17.11.09
Issued by olli
Beginning line 1

This are the settings for connecting to the LDAP Server. It is only needed if you want to use LDAP as DHCP-Storage.

ldap-server "localhost";
ldap-port 389;
ldap-username "";
ldap-password "";
ldap-base-dn "ou=DHCP-Servers,dc=example,dc=com";
ldap-dhcp-server-cn "silent-gabosh.example.com";
ldap-method dynamic;
ldap-debug-file "/tmp/dhcp-ldap-startup-config";

Changes in /etc/dhcp/dhcpd-ldap-wlan.conf

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /etc/dhcp/dhcpd-ldap-wlan.conf

Changed on 17.11.09
Issued by olli
Beginning line 1

This are the settings for connecting to the LDAP Server. It is only needed if you want to use LDAP as DHCP-Storage.

ldap-server "localhost";
ldap-port 389;
ldap-username "";
ldap-password "";
ldap-base-dn "ou=DHCP-Servers,dc=example,dc=com";
ldap-dhcp-server-cn "silent-gabosh.example.com-wlan";
ldap-method dynamic;
ldap-debug-file "/tmp/dhcp-ldap-startup-config-wlan";

Changes in /etc/dhcp/dhcpd-wlan.conf

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /etc/dhcp/dhcpd-wlan.conf

Changed on 06.09.08
Issued by olli
Beginning line 1

Configuration for DHCP in WLAN Network

option subnet-mask XXX.XXX.XXX.XXX;
option broadcast-address XXX.XXX.XXX.XXX;
option domain-name-servers my.lan.ip.addr;
option domain-name "example.com";
option ntp-servers my.lan.ip.addr;
option routers XXX.XXX.XXX.XXX;
default-lease-time 7200;
max-lease-time 14400;
ddns-update-style none;
subnet XXX.XXX.XXX.XXX netmask XXX.XXX.XXX.XXX {
 range XXX.XXX.XXX.XXX XXX.XXX.XXX.XXX;
}

next-server XXX.XXX.XXX.XXX;
filename "bootx64.efi";

Changed on 06.09.08
Issued by olli
Beginning line 20

Hosts with fixed IP

host small-gabosh-wlan {
 hardware ethernet XX:XX:XX:XX:XX:XX;
 fixed-address XXX.XXX.XXX.XXX;
}
host htc-gabosh {
 hardware ethernet XX:XX:XX:XX:XX:XX;
 fixed-address XXX.XXX.XXX.XXX;
}
host htc-gabosh2 {
 hardware ethernet XX:XX:XX:XX:XX:XX;
 fixed-address XXX.XXX.XXX.XXX;
}

Changes in /etc/openldap/dhcp.ldif

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /etc/openldap/dhcp.ldif

Changed on 17.11.09
Issued by olli
Beginning line 1

This is the DHCP-Configuration for LDAP. You only need this if you want so store your DHCP-Settings in LDAP. You can also mix them with the DNS-Entrys from the DNS-Howto. If you have both you should use the Objectclass gaboshComputer instead of DNSZone. Change the settings to fit your needs, then insert this file with

ldapadd -x -D cn=Manager,dc=example,dc=com -W -f /etc/openldap/dhcp.ldif
when the slapd is started.


# The DHCP Object with some default settings. filename and next-server are only needed if you want to boot with PXE.

# The entriees for your DHCP-Server(s)
dn: ou=DHCP-Servers,dc=example,dc=com
objectClass: organizationalUnit
objectClass: top
ou: DHCP-Servers

dn: cn=nas-gabosh.example.com,ou=DHCP-Servers,dc=example,dc=com
objectClass: top
objectClass: dhcpServer
cn: nas-gabosh.example.com
dhcpServiceDN: cn=Computers,dc=example,dc=com
dhcpStatements: next-server XXX.XXX.XXX.XXX
dhcpOption: routers XXX.XXX.XXX.XXX
dhcpOption: domain-name-servers XXX.XXX.XXX.XXX
dhcpOption: ntp-servers XXX.XXX.XXX.XXX

dn: cn=silent-gabosh.example.com,ou=DHCP-Servers,dc=example,dc=com
cn: silent-gabosh.example.com
objectClass: top
objectClass: dhcpServer
dhcpOption: domain-name-servers my.lan.ip.addr
dhcpOption: ntp-servers my.lan.ip.addr
dhcpOption: routers my.lan.ip.addr
dhcpStatements: next-server my.lan.ip.addr
dhcpServiceDN: cn=Computers,dc=example,dc=com

# The global settings for all your DHCP-Server(s)
dn: cn=Computers,dc=example,dc=com
cn: Computers
dhcpOption: subnet-mask XXX.XXX.XXX.XXX
dhcpOption: broadcast-address XXX.XXX.XXX.XXX
dhcpOption: domain-name "example.com dmz medianet"
dhcpStatements: ddns-update-style none
dhcpStatements: get-lease-hostnames true
dhcpStatements: use-host-decl-names true
dhcpStatements: filename "/pxelinux.0"
dhcpStatements: default-lease-time 7200
dhcpStatements: max-lease-time 14400
objectClass: dhcpService
objectClass: top
dhcpSecondaryDN: cn=silent-gabosh.example.com,ou=DHCP-Servers,dc=example,dc=com
dhcpSecondaryDN: cn=nas-gabosh.example.com,ou=DHCP-Servers,dc=example,dc=com

# The DHCP-Subnet entry:
dn: cn=XXX.XXX.XXX.XXX,cn=Computers,dc=example,dc=com
objectClass: top
objectClass: dhcpSubnet
objectClass: dhcpOptions
dhcpNetMask: 16
dhcpRange: XXX.XXX.XXX.XXX XXX.XXX.XXX.XXX
cn: XXX.XXX.XXX.XXX

# The entries for your DHCP-Client(s)
dn: cn=think-gabosh.example.com,cn=Computers,dc=example,dc=com
objectClass: top
objectClass: dhcpHost
dhcpHWAddress: ethernet XX:XX:XX:XX:XX:XX
dhcpStatements: fixed-address XXX.XXX.XXX.XXX
cn: think-gabosh.example.com


Changes in /etc/openldap/slapd.conf

File permissions:
Owner: root
Group: ldap
Permissions: -rw-r-----

Click here for a download of the complete file: /etc/openldap/slapd.conf

Changed on 19.02.10
Issued by olli
Beginning line 21

If you want to use LDAP-Data for Samba you need to include this schema

include         /etc/openldap/schema/dhcp.schema

Setting up services

For starting the new service after system reboot you should add it to a runlevel with the following command(s):

rc-update add dhcpd 

Please send a feedback to: doc<at>gabosh.net

Howto listing
File Index

Here you can find the official Gentoo Linux Forums where you can find a lot of answers.

Here a link to the official Gentoo Linux Homepage.

Edit Howto

About / Impressum

Click here for About / Impressum

Wishlist

If you want to support my work you can find my Amazon whishlist here