24 Dynamic Host Configuration Protocol – Alpine Linux

Braedyn Case

Dynamic Host Configuration Protocol (DHCP) is an interactive client-server protocol that automatically provides a host (PC, Laptop, Phone, etc) with an Internet Protocol (IP) address upon request. The purpose of this activity is for learners to see DHCP in action rather than just read about the DHCP handshake theory. A secondary purpose is to have learners experience frustration when hosts do not receive a DHCP IP address. Learners can see how the packets move and where they may get hung up while working to ensure DHCP functions correctly on their network. Finally, learners can see Address Resolution Protocol (ARP) in action. While DHCP occurs when a host requests an IP address for an existing MAC address, ARP occurs when a host has an IP address but is unsure what MAC address it belongs to.

We strongly recommend you complete the DHCP-Linux lab first. Since this is essentially the DHCP-Linux lab, but using a different Linux distribution, these steps are somewhat abbreviated. It is assumed that you are already familiar with the DHCP-Linux lab. If you follow these steps exactly, you will create an Alpine Linux DHCP server, but your understanding will be limited. Alpine Linux is much lighter than Ubuntu Server, which helps address performance issues. Alpine Linux is terminal-only. Proceed with caution, as incorrect commands and incorrectly edited configuration files can break your VM!

Estimated time for completion: 60 minutes

Phase 0 – Professional Alignment

Enterprise networks rely on automated network services to efficiently configure and manage connected devices. In this chapter, you will deploy a Kea DHCP server on Alpine Linux, gaining experience with a lightweight Linux distribution commonly used in virtualized, containerized, and embedded environments. You will also analyze DHCP and ARP traffic using Wireshark while developing the troubleshooting skills needed to diagnose network service failures.

DCWF Work Roles

The knowledge and skills developed in this chapter align with the following Department of Defense Cyber Workforce Framework (DCWF) work roles:

  • 441 – Network Services Specialist
  • 511 – Network Operations Specialist
  • 531 – Systems Administrator

NICE Work Roles

This chapter supports competencies associated with the following NICE Workforce Framework for Cybersecurity work roles:

  • Network Services Specialist
  • Network Operations Specialist
  • Systems Administrator

Professional Skills

By completing this chapter, you will begin developing the ability to:

  • Deploy and configure DHCP services on a Linux server using Kea DHCP.
  • Administer network services from the Linux command line.
  • Capture and analyze DHCP and ARP protocol traffic using Wireshark.
  • Validate automatic IP address assignment for enterprise clients.
  • Troubleshoot DHCP configuration and client connectivity problems.
  • Document and verify enterprise network service deployments.

What You’ll Be Able to Do

After completing this chapter, you should be able to:

  • Install the required Kea DHCP software packages on Alpine Linux.
  • Configure and manage a Kea DHCP server using command-line tools and configuration files.
  • Verify that client devices automatically receive valid IPv4 addressing information.
  • Capture and interpret the DHCP Discover, Offer, Request, and Acknowledgment (DORA) process using Wireshark.
  • Capture and analyze ARP traffic to understand Layer 2 address resolution.
  • Diagnose and resolve common DHCP configuration and connectivity issues within an enterprise network.

 

LEARNING OBJECTIVES
  • Successfully deploy a DHCP solution using Alpine Linux on an enterprise network
  • Capture and Observe DHCP packets using Wireshark
  • Capture and Observe ARP packets using Wireshark
  • Successfully add hosts to an enterprise network and receive IP addresses automatically
PREREQUISITES
DELIVERABLES
  • 5 Screenshots:
    • Wireshark – DHCP Packets for PC1
    • Wireshark – DHCP Packets for PC2
    • Wireshark – ARP Packets for PC1/PC2
    • GNS3 Workspace
    • Configuration of the DHCP Daemon
RESOURCES
CONTRIBUTORS AND TESTERS
  • Antionette Hults, Cybersecurity Student, ERAU-Prescott
  • Mathew J. Heath Van Horn, PhD

 

Phase I – Create the DHCP server vm

 

Alpine-Linux goal configuration
Figure 0.5 – DHCP Alpine-Linux goal image
  1. Open Oracle VirtualBox
  2. Right-click on your Alpine VM and click Clone
    1. In the Name field type “DHCP-Alpine”
    2. Under clone type, select “Full Clone”
    3. Under MAC Address Policy, select “Generate new MAC address for all network adapters”
  3. Select DHCP-Alpine and start the VM
  4. Log in with the same credentials you used to create the original Alpine VM. In our example, we used:
    1. Username: root
    2. Password: toor
  5. Use the command line to install two packages using the command below

apk add kea-dhcp4 curl

Command Purpose
apk (Alpine Package Keeper) is the default package manager for Alpine Linux. It is used to install, update, upgrade, and delete software packages on the system.
add Used to install or update software packages on Alpine Linux
kea-dhcp4 Kea is the full-featured, open source, standards-based DHCP server distribution from the Internet Systems Consortium authority
curl (Client URL) is a powerful command-line utility used in Linux to transfer data to or from a remote server

Phase II – Configure kea

Kea is open source DHCP server developed by the Internet Systems Consortium.
  1. Go to the kea config directory by typing the command

    cd /etc/kea

     

    Command Purpose
    cd Change Directory – a built-in shell tool used to navigate through files and folders
    /etc/kea Change working directory to the kea subfolder of the etc folder.  The (et cetera) folder is the nerve center of a Linux system. It stores all system-wide configuration files.
    Screenshot Intructions
    Figure 1 – Entering the kea config directory

  2. Once in the directory, backup the kea-dhcp4.conf and delete the original one by running the following commands
    1. cp kea-dhcp4.conf kea-dhcp4.bak

      cp is the Linux command for “copy”

    2. rm kea-dhcp4.conf

      rm is the Linux command for “remove”

  3. Download the new kea-dhcp4.conf by typing the command

    curl -O https://raw.githubusercontent.com/braedyncase06/MasteringEnterpriseNetworks/main/Alpine-kea-configs/kea-dhcp4.conf

    NOTE: The dash is not followed by a zero; it is followed by an O as in Oscar. Also, the link must be perfectly copied for this command to work. Because Alpine Linux is so minimal, there is no copy and paste function between your computer and the VM terminal. So take your time entering the above command, or you will have to redo it!

     

  4. Verify that the download was successful by typing the command

    cat kea-dhcp4.conf

     

  5. The contents of the file should match the following image
    Screenshot Instructions
    Figure 2 – The kea config file contents should match this image

     

  6. If the contents DO NOT match the picture above, go back to step 3 and ensure that you type in the link correctly.

    NOTE: You can manually adjust the Kea IPv4 configuration file by following the instructions in the DHCP-Linux chapter.

Phase III – Configure the VM NIC for DHCP

The Network Interface Configuration for the VM needs configuration so that it will keep it’s IP address.

  1. Run the command

    vi /etc/network/interfaces

  2. In the text editor, scroll down to the last line that contains “iface eth0 inet dhcp”
  3. Press “i” to edit the file
  4. Remove the dhcp part at the end of the line
  5. type in “static”
  6. The line should now read “iface eth0 inet static”
  7. Press Enter to go to the blank line beneath and press Tab
  8.  In the newly indented line type “address 200.200.200.254”
  9. Press Enter to make a new line and press Tab
  10. In the newly indented line type “netmask 255.255.255.0”
  11. Press Enter to make a new line and press Tab
  12. In the newly indented line type “gateway 200.200.200.1”
  13. The file should look like the following image
    Screenshot Instructions
    Figure 3 – Network interfaces file should look like this
  14. Press Escape to stop editing the file
  15. Then type in “:wq” to save changes and exit out of the text editor
  16. Type the following command to activate kea dhcp server upon boot

    rc-update add kea-dhcp4 default

     

    Command Use
    rc-update A utility used to manage which services start automatically at boot
    add Add the following service to the rc-update utility
    kea-dhcp4 The file we just edited using vi
    deafult Start normal operational services after
  17. Power down the VM

Phase IV – Configure the GNS3 Environment

Now that KEA is setup on the VM, we can add it to the GNS3 environment.

  1. Open GNS3
  2. Wait for the GNS3 VM to connect and for the status indicator to turn green
  3. Create a new project by going to File > New Blank Project
    Screenshot Instructions
    Figure 4 – Making a new GNS3 Project
  4. Name the project whatever you want (Mine is called DHCP-Alpine)
  5.  To add the VM, go to the top of the window, click on Edit > Preferences > VirtualBox VMs
    Screenshot Instructions
    Figure 5 – Add the VM to GNS3
  6.  Click on New
  7. In the Window, select Run this VirtualBox VM on my local computer
  8. Click Next
  9. In the next window, click the dropdown arrow and select the name of your Alpine DHCP VM that you made
  10. Click Finish
    Screenshot Instructions
    Figure 6 – Selecting the VM to add to GNS3
  11.  In the GNS3 project window, go to Browse End Devices (Desktop Computer Icon at the left of the window)
  12. Double-click on the VM you added
  13.  In the configuration window, click on Network
  14. At the bottom of the window, check the box next to Allow GNS3 to use any configured VirtualBox adapter
    Screenshot Instructions
    Figure 7 – Configuring the Network Interface

     

  15. Click OK
  16. Drag DHCP-Alpine into the project space
  17. Drag VPCS into the project space
  18. When the pop-up window opens, click the dropdown arrow and select GNS3 VM
  19. Click OK
  20. Drag another VPCS into the project space
  21.  When the pop-up window opens, click the dropdown arrow and select GNS3 VM
  22. Click OK
  23. Go to Switches (just above Browse End Devices)
  24. Drag the Ethernet Switch into the project space
  25. When the pop-up window opens, click the dropdown arrow and select GNS3 VM
  26. To the left of the window, click on the wire icon
  27.  Click on DHCP-Alpine-1 and select Ethernet0, then click on Switch1 and select Ethernet0
  28. Click on PC1 and select Ethernet0 then click on Switch1 and select Ethernet1
  29. Click on PC2 and select Ethernet0 then click on Switch1 and select Ethernet2
    Screenshot Instructions
    Figure 8 – Basic DHCP Network

Phase V – See DHCP in action

Monitor packets for PC1 and PC2 during the DHCP handshake
  1. At the top of the window, press the start button
  2. After all devices start fully (indicator at the right is green), right-click on the wire between PC1 and Switch1
  3. Click Start Capture
  4. In the pop-up window, click OK
  5. Go back to the GNS3 Project window and right-click on PC1
  6. Click Console
  7. In the console, type the command

    ip dhcp

     

  8. You should see DORA printed on the terminal, indicating that you have successfully connected to your DHCP server!
    Screenshot Instructions
    Figure 9 – Successful connection to the Alpine DHCP Server

     

  9. You should also see a full DHCP handshake in your Wireshark capture
    Screenshot Instructions
    Figure 10 – Observing DHCP Handshake

    10. Repeat with PC2 and then try to ping PC1 with the newly assigned IP addresses

 

Career Connection

Automated network services such as DHCP are essential to modern enterprise operations, and many organizations deploy these services on lightweight Linux platforms to improve efficiency and simplify administration. Network engineers, systems administrators, and cybersecurity professionals routinely configure, monitor, and troubleshoot DHCP services while validating network behavior with packet analysis tools such as Wireshark. The combination of Linux command-line administration, protocol analysis, and troubleshooting practiced in this chapter reflects the day-to-day responsibilities of professionals responsible for maintaining reliable enterprise network infrastructure.

End of Lab

Deliverables

5 screenshots are needed to receive credit for this exercise:

  • Wireshark – DHCP Packets for PC1
  • Wireshark – DHCP Packets for PC2
  • Wireshark – ARP Packets for PC1/PC2
  • GNS3 Workspace
  • Configuration of DHCP Daemon

Homeworks

Assignment 1 – Combined network traffic watching

  • Turn off all devices
  • Replace the switch with a hub and reconnect all devices
  • Monitor any of the PCs with Wireshark and capture ARP, DHCP, and ICMP packets for each PC as you turn devices back on
  • RECOMMENDED GRADING CRITERIA
    • Screenshot of GNS3 environment with everything labeled
    • Screenshot of Server-PC1 ARP from PC2-Hub link
    • Screenshot of Server-PC1 DHCP from PC2-Hub link
    • Screenshot of Server-PC1 ICMPfrom PC2-Hub link

Assignment 2 – Reconfigure the DHCP server

  • Figure out the number of devices that can be attached to the switch
  • Generate a random IP address and choose a subnet that will allow the use of all the switch connections with as few wasted IP addresses as possible
  • Reconfigure the network to use these new network addresses
  • Reconfigure the DHCP settings to issue IPv4 address in this new space
  • RECOMMENDED GRADING CRITERIA
    • Screenshot of the DHCP configuration file
    • Screenshot of the GNS3 workspace
    • Screenshot of DHCP of one PC
    • Screenshot of ICMP of one PC

 

 

Send correspondence to prmaster@erau.edu
Figure 404 – use prmaster@erau.edu for correspondence

License

Icon for the Creative Commons Attribution-NonCommercial 4.0 International License

Mastering Enterprise Networks 3e Copyright © 2024 by Mathew J. Heath Van Horn is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License, except where otherwise noted.