DHCP Cheat Sheet

A Dynamic Host Configuration Protocol (DHCP) cheat sheet can be handy for managing and troubleshooting DHCP services on a network. Here are cheat sheet of DHCP commands and concepts:

Basic DHCP Concepts

DHCP Server:

  • The server that dynamically assigns IP addresses and other network configuration information to devices on a network.
  • DHCP Client:
    • A device that requests and receives network configuration information from a DHCP server.

Commands and Configuration

Install DHCP Server (on Linux):

sudo apt-get install isc-dhcp-server

Start DHCP Server (on Linux):

sudo service isc-dhcp-server start

Stop DHCP Server (on Linux):

sudo service isc-dhcp-server stop

Restart DHCP Server (on Linux):

sudo service isc-dhcp-server restart

Configuration File (dhcpd.conf)

Location (on Linux):

/etc/dhcp/dhcpd.conf

Example dhcpd.conf:

subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.10 192.168.1.50;
  option routers 192.168.1.1;
  option domain-name-servers 8.8.8.8, 8.8.4.4;
}

DHCP Lease Management

View Active Leases (on Linux):

cat /var/lib/dhcp/dhcpd.leases

Release DHCP Lease (on Linux):

sudo dhclient -r

DHCP Relay

Install DHCP Relay (on Linux):

sudo apt-get install isc-dhcp-relay

Configure DHCP Relay (on Linux):

  • Edit /etc/default/isc-dhcp-relay and set SERVERS to the DHCP server’s IP.

Troubleshooting

Check DHCP Server Status (on Linux):

sudo service isc-dhcp-server status

Check DHCP Server Logs (on Linux):

tail -f /var/log/syslog

Test DHCP Configuration (on Linux):

sudo dhcpd -t

Renewing DHCP Lease

Renew DHCP Lease (on Linux):

sudo dhclient -r
sudo dhclient

DHCP Options

Common DHCP Options:

  • option subnet-mask, option routers, option domain-name-servers, etc.

DHCPv6

Install DHCPv6 Server (on Linux):

sudo apt-get install isc-dhcp-server6

Configure DHCPv6 (on Linux):

  • Edit /etc/dhcp/dhcpd6.conf.

This cheat sheet provides a quick reference for managing and troubleshooting DHCP services. Always refer to the specific documentation for your DHCP server implementation for more details and advanced configurations.