Setting up DHCPD

this guide helps to setup pxe

Requirements

    dhcpd --version
    ifconfig | grep inet

slackware

    ls -lF /etc/dhcpd.conf.example
    mv -i /etc/dhcpd.conf /etc/dhcpd.conf.dist
    vi /etc/dhcpd.conf

netbsd

    cp -pi /usr/share/examples/dhcp/dhcpd.conf /etc/dhcpd.conf.dist
    grep -vE '^#|^$' /etc/dhcpd.conf.dist > /etc/dhcpd.conf
    vi /etc/dhcpd.conf

ubuntu

    ls -lF /usr/share/doc/isc-dhcp-server/examples/dhcpd.conf.example
    mv -i /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.dist
    vi /etc/dhcp/dhcpd.conf

MWE

    option routers 10.3.3.1;
    option domain-name-servers 62.210.16.6, 62.210.16.7;
    # 208.67.222.222, 208.67.222.220;
    #option domain-name example.local;
    #option domain-search "example.local", "example.net";

    option smtp-server 10.3.3.254;
    option ntp-servers 10.3.3.252;

    default-lease-time 600;
    max-lease-time 7200;
    ddns-update-style none;
    log-facility local7;

    subnet UNUSED-IP netmask UNUNSED-NETMASK {
    }

    subnet 10.3.3.0 netmask 255.255.255.0 {
            range 10.3.3.100 10.3.3.199;
    }

Super-duper PXE

Here’s a super-duper DHCP setup for PXE/BIOS. See client classification for more details.

    authoritative;
    allow bootp;
    allow booting;
    ddns-update-style none;
    allow unknown-clients;
    ignore-client-uids on;

    subnet 172.17.0.0 netmask 255.255.0.0 {
    }

    subnet x.x.x.0 netmask 255.255.255.0 {
            range dynamic-bootp x.x.x.100 x.x.x.199;
            option routers x.x.x.254;
            option domain-name-servers x.x.x.252;

            next-server x.x.x.x;

    # BIOS vs. EFI64
            if substring (option vendor-class-identifier, 15, 5) = "00007" { #EFI BC (EFI Byte Code)
                    filename "efi64/syslinux.efi";
            } elsif substring (option vendor-class-identifier, 15, 5) = "00009" { #EFI x86-64
                    filename "efi64/syslinux.efi";
            } else { # (option vendor-class-identifier, 0, 32) = "PXEClient:Arch:00000:UNDI:002001"
                    filename "pxelinux.0";
            }

    # pxeboot_ia32.bin got chain-loaded
    # enforcing TFTP instead of NFS and offering a nice path for the default kernel
    if substring (option vendor-class-identifier, 0, 17) = "NetBSD:i386:libsa" {
        if filename = "netbsd" {
            filename "tftp:netbsd9/binary/kernel/netbsd-INSTALL.gz";
        }

    # pxeboot got chain-loaded
    } elsif substring (option vendor-class-identifier, 0, 9) = "PXEClient" {
        if substring (option user-class, 1, 7) = "FreeBSD" {
            # diskless for fbsd
            option root-path "x.x.x.x:/tftpboot/fbsd";
        } else { # TODO 255 End
            # diskless for dfly
            option root-path "x.x.x.x:/tftpboot/dfly";
        }

    # TODO slackware live
    } else {
        # diskless for slackware
        option root-path "/tftpboot/slackware-live";
    }
    }

    #allow booting;
    #option option-128 code 128 = string;
    #option option-129 code 129 = text;

Note ignore client-identifiers (since v4.2.0) breaks the specification, but prevents sysrescuecd from changing IPs.

Check

    # ubuntu
    dhcpd -t -cf /etc/dhcp/dhcpd.conf

    # slackware
    dhcpd -t -cf /etc/dhcpd.conf

POOLS

    grep ^lease /var/state/dhcp/dhcpd.leases | sort -V

    sbopkg -i uthash

    git clone git://git.code.sf.net/p/dhcpd-pools/code dhcpd-pools
    cd dhcpd-pools/
    ./bootstrap
    ./configure
    echo $MAKEFLAGS
    make
    make install

as cron job

    crontab -e

    0 12 * * * /usr/local/bin/dhcpd-pools --config=/etc/dhcpd.conf --leases=/var/state/dhcp/dhcpd.leases --color=never --format=text
    #--color=always

NOTES

more options

    #server-name "DHCPserver";
    #server-identifier 10.1.1.253;
    #max-lease-time 7200;
    #default-lease-time 120;
    #max-lease-time 120;

    #option subnet-mask 255.255.255.0;

TROUBLES

wireshark filter

    !arp && !dns && !tcp && !icmp && !ntp

RESOURCES

dhcpd: any way to check dhcp pool status? https://unix.stackexchange.com/questions/39431/dhcpd-any-way-to-check-dhcp-pool-status

Command to list assigned dhcp addresses https://unix.stackexchange.com/questions/91799/command-to-list-assigned-dhcp-addresses/247514#247514

How do I show active dhcp leases https://askubuntu.com/questions/219609/how-do-i-show-active-dhcp-leases

ISC dhcpd lease analysis and reporting http://dhcpd-pools.sourceforge.net/

How do you have dhcpd reload its configuration file? https://kb.isc.org/docs/aa-00335

ISC dhcpd lease analysis and reporting http://dhcpd-pools.sourceforge.net/

options

dhcp-options - Dynamic Host Configuration Protocol options https://netbsd.gw.com/cgi-bin/man-cgi?dhcp-options+5

Options https://wiki.syslinux.org/wiki/index.php?title=PXELINUX#Options

Dynamic Host Configuration Protocol (DHCP) https://help.ubuntu.com/community/isc-dhcp-server

32.8. Diskless Operation with PXE https://docs.freebsd.org/en/books/handbook/network-diskless.html

client-identifier

ISC DHCP 4.1 Manual Pages - dhcpd.conf https://kb.isc.org/docs/isc-dhcp-41-manual-pages-dhcpdconf

ISC DHCP 4.1 Manual Pages - dhcpd.leases https://kb.isc.org/docs/isc-dhcp-41-manual-pages-dhcpdleases

Dhcp with known and unknown hosts http://www.macfreek.nl/memory/Dhcp_with_known_and_unknown_hosts

How to reserve dhcp for mac address in another file? https://askubuntu.com/questions/1015658/how-to-reserve-dhcp-for-mac-address-in-another-file

dhcpd.conf - dhcpd configuration file https://manpages.debian.org/unstable/isc-dhcp-server/dhcpd.conf.5.en.html

How do i keep ISC-DHCPD from offering different IPs when there is two requests from the same MAC https://serverfault.com/questions/694351/how-do-i-keep-isc-dhcpd-from-offering-different-ips-when-there-is-two-requests-f

syslinux

DHCP options https://wiki.syslinux.org/wiki/index.php?title=PXELINUX#DHCP_options

efi64

PXELINUX-Multi-Arch https://wiki.syslinux.org/wiki/index.php?title=PXELINUX-Multi-Arch

BIOS and UEFI Co-Existence https://wiki.fogproject.org/wiki/index.php/BIOS_and_UEFI_Co-Existence

[syslinux] RE: DHCP option 93 for UEFI https://www.syslinux.org/archives/2014-October/022683.html

Dynamic Host Configuration Protocol (DHCP) Options for the Intel Preboot eXecution Environment (PXE https://tools.ietf.org/html/rfc4578

DHCP boot options https://community.meraki.com/t5/Security-SD-WAN/DHCP-boot-options/td-p/44536

UEFI Mode PXE Booting Doesn’t Work https://superuser.com/questions/1182862/uefi-mode-pxe-booting-doesnt-work


GUIDES | LECTURES | BENCHMARKS | SMTP HEALTH