Experiment: Configuring a DHCP Server
Objective:
To set up a DHCP server that automatically assigns IP addresses to clients on a local network.
Requirements:
- A Linux machine (Ubuntu preferred) to act as the DHCP server.
- A client machine (can be another physical or virtual machine) to test DHCP functionality.
- Administrative access to both machines.
Procedure:
Step 1: Install the DHCP Server
Update the Package List: Open a terminal on the server machine and run:
Install the ISC DHCP Server: Install the DHCP server package using the following command:
Step 2: Configure the DHCP Server
Edit the DHCP Configuration File: Open the DHCP configuration file in a text editor:
Configure the DHCP Settings: Add the following configuration to the file. Adjust the subnet, range, and other parameters according to your network setup:
Save and Exit: Save the changes and exit the text editor (in nano, press
CTRL + X, thenY, andEnter).
Step 3: Specify the Network Interface
Edit the DHCP Server Defaults: Open the DHCP server defaults file:
Specify the Interface: Find the line that starts with
INTERFACESand specify the network interface that the DHCP server should listen on. For example:Replace
eth0with the appropriate interface name (you can find it usingip a).Save and Exit: Save the changes and exit the text editor.
Step 4: Start the DHCP Server
Restart the DHCP Service: Start or restart the DHCP server to apply the changes:
Check the Status: Verify that the DHCP server is running without errors:
Step 5: Test the DHCP Server
Configure the Client Machine: On the client machine, ensure that the network interface is set to obtain an IP address automatically (via DHCP). This can usually be done in the network settings.
Release and Renew the IP Address: On the client machine, open a terminal and run the following commands:
Check the Assigned IP Address: After running the commands, check the assigned IP address on the client machine:
You should see an IP address assigned from the range specified in the DHCP server configuration (e.g., 192.168.1.10 to 192.168.1.50).
Step 6: Monitor DHCP Leases
- Check the DHCP Leases File: You can view the leases granted by the DHCP server by checking the leases file:
Conclusion
You have successfully configured a DHCP server on a Linux machine. The server automatically assigns IP addresses to clients on the network. This setup is essential for managing
Post a Comment
If you have any doubts, please let me know