DHCP daemon on Raspberry Pi

DHCP stands for “Dynamic Host Configuration Protocol”.    The DHCP daemon is the process which assigns IP addresses to computers when they join a network, and gives them other important information about the network.

Here is how to set up and configure dhcpd on Raspbian Stretch:

  1. Install: Install the package:
    sudo apt-get install isc-dhcp-server
    When you install this package it is configured to run automatically at boot time.
  2. Configure: There are two files to edit:
    1. Move the existing file /etc/dhcp/dhcpd.conf out of the way so you can replace it with your own:
      sudo mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.ORIG
      (You should keep it because it contains good documentation and examples).
      Then create and edit a new file /etc/dhcp/dhcpd.conf containing:1

      #                                                                               
      # Configuration file for DHCP server on Rasberry Pi                             
      #                                                                               
      ddns-update-style none;
      option domain-name "wifipi.local";
      option domain-name-servers 8.8.8.8;
      default-lease-time 3600;
      max-lease-time 86400;
      authoritative;
      log-facility local7;
      
      # Configure service for local network 192.168.47.0 (the wireless AP)                    
      subnet 192.168.47.0  netmask 255.255.255.0 {
          range 192.168.47.50 192.168.47.250;
          option routers 192.168.47.1;
      }
      ##
    2. Also edit the file /etc/default/isc-dhcp-server to add the line:
      INTERFACESv4="wlan1"
  3. Restart: The service should already be enabled, and is probably already running. Restart it with
    sudo systemctl restart isc-dhcp-server

References

  1. “How to: Make a Raspberry Pi Powered Wifi Repeater” by Dryfire117, https://pastebin.com/A4jUp2Nq
Print Friendly, PDF & Email