Learn how to configure your Raspberry Pi for dynamic IP allocation using DHCP

A step-by-step guide on checking and setting up the Dynamic Host Configuration Protocol (DHCP) settings on your Raspberry Pi. …


Updated August 19, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


A step-by-step guide on checking and setting up the Dynamic Host Configuration Protocol (DHCP) settings on your Raspberry Pi.
To check and set up the Dynamic Host Configuration Protocol (DHCP) settings on your Raspberry Pi, follow these simple steps:

  1. Open a terminal window by clicking on the “Terminal” icon in the menu bar or pressing Ctrl + Alt + T.
  2. Type sudo nano /etc/dhcpcd.conf and press Enter to open the DHCP configuration file in the nano text editor. You may be prompted for your password.
  3. Scroll down through the file using the arrow keys or Page Down button until you find the lines starting with interface eth0. These lines define the network interface settings for Ethernet (wired) connections. If you’re using WiFi, look for a section starting with interface wlan0 instead.
  4. To check the current DHCP settings, look for a line that starts with static ip_address=. If this line is present, your Raspberry Pi is set to use static IP addressing and you’ll need to remove it to enable DHCP:
    • To delete the line, place the cursor on the line and press Ctrl + K until it’s highlighted. Then, save the file by pressing Ctrl + X, confirming your changes with Y, and hitting Enter.
  5. Now, add a new line to enable DHCP by typing dhcp on an empty line below the interface eth0 or interface wlan0 section and pressing Enter. Your configuration should look like this:
interface eth0
dhcp
  1. Save the changes by pressing Ctrl + X, confirming your changes with Y, and hitting Enter. Reboot your Raspberry Pi by typing sudo reboot in the terminal and pressing Enter to apply the new settings.
  2. After your Raspberry Pi reboots, check the IP address it was assigned by your DHCP server. Open a terminal window again and type ifconfig. Look for the “inet” address under the appropriate network interface (either eth0 or wlan0). This is your dynamic IP address.
  3. To set a static IP address using DHCP, you can also configure the DHCP client on your router to always assign the same IP address to your Raspberry Pi based on its MAC address. Consult your router’s documentation for instructions on how to do this.
  4. To revert back to static IP addressing at any time, open /etc/dhcpcd.conf again and add a line like static ip_address=192.168.1.10/24 (replace the IP address with your desired static IP and subnet mask), save the file, and reboot your Raspberry Pi.

And that’s it! You now know how to check and configure DHCP settings on your Raspberry Pi. With DHCP enabled, you don’t need to manually set an IP address every time you connect your device to a network, making it much easier to manage multiple devices and avoid IP conflicts.