How to Make your Linux Box a DHCP Server

Home > Blogs > Cisco > How to Make your Linux Box a DHCP Server

How to Make your Linux Box a DHCP Server

Like This Blog 0 Mark Jacob
Added by March 16, 2015

This topic is of interest to readers who are desiring their Network Plus certification, or those who just like to tinker with network settings (in a safe and approved environment) and observe the results. In this blog, I will delve into configuring your Linux box as a DHCP server, and then I will show a client obtaining its information from this DHCP server. Let’s get rolling…

First off, I will be working with a machine running the Ubuntu distribution of Linux. I have a client box which is running Windows XP (yes, XP, I just can’t let it go) but the client can be any IP endpoint that supports obtaining its network information via DHCP. Keep in mind that I am not covering every subtle nuance of fine-tuning DHCP on a Linux box, I will just show a basic configuration which will allow DHCP clients to be served. I want to verify that my client is running DHCP and at least attempting to talk to a DHCP server.


Figure 1

This is actually expected behavior, since I haven’t yet configured the Linux box to answer the client requests. But it does verify that the client machine is in the correct state because it tries in vain to contact a DHCP server. So on to the server.

The first thing I want to do on my server box is to configure a static IP address on the interface with which DHCP will be associated. This may already be done on your box, but if not, here is what needs to be done. Type this command:

sudo nano /etc/network/interfaces  (sudo allows me to execute this command with elevated privileges.) If you have not executed a command using sudo within the last five minutes (by default) you will be prompted for a password which entitles you to execute the command. I have entered the password, and here is the resulting output:


Figure 2

As you can see, I have set a static IP address of /24 on interface Ethernet 0 (eth0). I placed the ‘#’ symbol in front of the line referencing dhcp, because my interface cannot be both statically set and a dynamic client itself.  I saved these changes and exited the editor. However, to get my system to adjust to this change, I must execute this command:

sudo /etc/init.d/networking restart

Once this is done, I can use ifconfig to check status:


Figure 3

So far so good. Now to execute the commands to enable DHCP. Many of my readers are quite likely Cisco people and as such may already be quite comfortable with configuring DHCP on a Cisco router. I have blogged on this topic in the past, and if you want a refresher, go here. While the concept is the same, the commands (and how and where to type them) are different. The first thing that must be done is to tell the box on which interface DHCP will be active. Type the following:

sudo nano /etc/default/dhcp3-server

In my case, I want it all to happen on eth0, so notice the output once I have entered this:


Figure 4

Before I entered eth0, it looked like this INTERFACES=””

Now I save these changes and exit. The next step is to configure the configuration file that dhcp will use to hand out client information. That is done by typing the following command:

sudo nano /etc/dhcp3/dhcpd.conf

Once inside the editor, there is a sequence of commands to type. I scrolled down until the entries ended and then added the needed commands to the end. Here is what that looked like:


Figure 5

Now I save and exit the editor. To force to system to acknowledge the change, execute this command:

sudo /etc/init.d/dhcp3-server restart

Now we go to the XP client, release and renew its IP information, and see if it receives and IP address from the pool we just created.


Figure 6

And there it is! Client has been served. This is a pretty handy config to keep around, especially for building home lab scenarios where you are using Linux machines to practice your networking skills. If you have any suggestions or comments, I would love to hear them!

Until next time…

Mark Jacob
Cisco and CompTIA Network + Instructor – Interface Technical Training
Phoenix, AZ

Videos You May Like

Agile Methodology in Project Management

0 172 0

In this video, you will gain an understanding of Agile and Scrum Master Certification terminologies and concepts to help you make better decisions in your Project Management capabilities. Whether you’re a developer looking to obtain an Agile or Scrum Master Certification, or you’re a Project Manager/Product Owner who is attempting to get your product or … Continue reading Agile Methodology in Project Management

An Overview of Office 365 – Administration Portal and Admin Center

0 923 3

This is part 1 of our 5-part Office 365 free training course. In this Office 365 training video, instructor Spike Xavier introduces some of the most popular services found in Microsoft Office 365 including the Admin Portal and Admin Center. For instructor-led Office 365 training classes, see our course schedule: Spike Xavier SharePoint Instructor – … Continue reading An Overview of Office 365 – Administration Portal and Admin Center

Creating Users and Managing Passwords in Microsoft Office 365

0 750 4

In this Office 365 training video, instructor Spike Xavier demonstrates how to create users and manage passwords in Office 365.   For instructor-led Office 365 training classes, see our course schedulle: Spike Xavier SharePoint Instructor – Interface Technical Training Phoenix, AZ 20347: Enabling and Managing Office 365    

Write a Comment

Share your thoughts...

Please fill out the comment form below to post a reply.