Official Power Up Hosting Blog

Everything about Linux, Windows, and hosting ;)

I am an avid book reader, who enjoys technology as well as writing.

Share


Our Newsletter


Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Tags


Twitter


Official Power Up Hosting Blog

A Complete Guide To Install DHCP server (Windows & Linux):

Apurva ChodnekarApurva Chodnekar

Contents Of This Guide.

  1. Introduction.

  2. What is DHCP server?

  3. Static IP.

  4. DHCP.

  1. Ethernet interface.

  2. How to install DHCP server in linux and configure it.

  3. How to install DHCP server in windows 7.

  1. How to configure DHCP server in windows 2012 server step by step

Introduction:

Many of you might be aware of what DHCP server means and why you want to install it. So, those of you who know all about it can skip directly to the Installation part.

But there will still be some who have no idea what it is and installing it because they were told to or they need to.

We are going into detail about DHCP Server and its workings just for you people.

What is DHCP server?

The DHCP stands for Dynamic host Configuration Protocol.

As you must know that every computer or a device on a network has an IP address.

This Ip address is like the id of that particular computer or device on the network.

It identifies a particular computer or device on a network.

There are two ways in which you can assign an IP address to a computer or a device.

First one is Static IP and second one is Dynamic IP.

Static IP.

Here is how a static IP works.

A user has to assign a static IP manually.

That is the way it has been done since the beginning of networking.

For that you have to open the “Network configuration” of your windows if you are working on windows and then manually assign an IP address, a subnet mask and dns server to the computer or device.

And if you want to add new device or computer to the network, you will have to repeat these steps again and again.

And again you also have to make sure ip addresses are unique.

If the same ip address is assigned to more than one device on the network it will cause an ip conflict.

Both of the devices that were assigned the same IP address will be rendered useless as in they won't be able to access the network.

DHCP:

That's where DHCP comes in. It saves all the manual work and get the ip address directly from a DHCP server

It not only assigns the computer with an IP Address but it also assigns it with a Subnet mask, Default Gateway and a DNS server.

How it works?

The computer or device that wants access to the networks broadcasts a request asking for IP address.

It is then that the DHCP server sends a IP address to that particular computer or device from its pool.

The reason it is more popular than Static IP is that it’s automatic and saves hours of manual labour.

It also makes managing the entire network much easier in practice.

Scope:

DHCP assigns IP addresses to the devices on the network from it's scope.

This scope is basically a range of IP addresses available to be allocated.

Here is an example of a scope.

Start IP Address: 11.0.0.1

End IP address : 11.0.0.100

As you can see the range starts at 11.0.0.1 and ends at 11.0.0.100.

What is means is that there are 98 IP address besides these two that can be allocated to devices in the network.

It could assign a device 11.0.0.56 or It could assign a device 11.0.0.3

The computer on the current network will get IP addresses from this range of IP addresses.

Lease:

IP addresses are leased by DHCP and not given.

Let's take an example to explain it better.

Suppose the DHCP has just two IP addresses and it gives them away to Computer A and Computer B.

Let’s assume that Computer A has been given the IP address 11.0.0.1 and Computer B 11.0.0.2.

Now:

Now for some reason you want to remove Computer B from the network. When computer B is removed it keeps the IP address 11.0.0.2 with it.

Next:

You are looking to add a new computer, let’s say Computer C to the network. You place it in the network but the DHCP server has no IP addresses left to give.

DHCP lease:

Let’s rethink the entire thing in terms of a lease.

Lease is the amount of time an IP address is assigned to a computer.

So same scenario DHCP server with the same two IP addresses and it assigns them to computer A and Computer B respectively.

These addresses are leased and they will expire and return back to the DHCP server pool and DHCP server will be free to assign them to other computer even if Computer B was removed from the network.

Reservation:

Not all of you will be happy with the constant changing IP addresses.

So if you computer or device to be assigned the same IP Address you will have to make the required changes in the reservation table.

You are basically creating a reservation here.

The Reservation table will have following columns.

IP address || Device Name || MAC address

A reservation in this table ensures that the computer or the device can be identified by its mac address and it will always be given the same IP address when that device or computer broadcasts a request for IP address allocation.

So in short, reservations are not just handed out they are for VIP's.

Jokes aside, it's actually true. Reservations are given to the special devices or special computers.

Now that device could be a network printer, computer, server or routers.

Because these devices need to work with the same IP addresses.

Ethernet Interfaces.

During the installation of DHCP on ubuntu DHCP interfaces are necessary. We are talking about the Ethernet Interface here.

What is Ethernet Interface?

It is actually a network interface or card that has been installed on a computer system. It acts as a network client.

This network interface will connect your computer or a mobile device to the LAN network and it uses Ethernet medium for it.

How to install DHCP server in Linux:

Refer Ubuntu Server Setup Guide for Beginners (Version 16.04) if you are yet to install Ubuntu.

You will learn how to install and how to configure DHCP server in ubuntu step by step:

This guide is not just limited to Ubuntu but you can also install DHCP server on redhat or fedora.

Update your packages with the following command.

sudo apt-get update

Step 1. DHCP server installation.

The following linux DHCP command is the first step of installing DHCP server as well as configuring it.

This command is eligible if you are trying to install ubuntu 16.04 DHCP server.

apt-get install isc-dhcp-server

When installing DHCP server on ubuntu a few of you might face the "unable to locate package isc-dhcp-server" error.

This happens becuase people usually forget to run or choose to ignore the sudo apt-get update command.

But it you are working with a Redhat or Fedora you will have to work with the following command.

yum install dhcp

Step 2. Basic DHCP configuration

This step includes defining a subnet.

Errors like isc-dhcp-server not configured to listen on any interfaces, no subnet declaration for ethO, or isc-dhcp-server failed to start will occur if you skip this step of installation.

The server you are working with might be connected to various networks subnets.

To start the installed DHCP server you will have to define at least one subnet inside the DHCP configuration file ("dhcp.conf").

sudo nano /etc/dhcp/dhcp.conf

When the conf file is open add the following lines of code to it.

subnet  152.10.15.0 netmask 255.255.255.0{
    range 152.10.15.3 152.10.01.254;
}
subnet 192.168.0.0 netmask 255.255.0.0{
}

This file tells the DHCP server to listen (i.e wait) for DHCP client request on the subnet 152.10.15.0 with netmask 255.255.255.0

This file also gave the DHCP server it's scope. The range of IP address for it to assign. It will assign IP addresses from the range 152.10.15.3-152.10.15.254.

This is how you can add your subnet into the /etc/dhcp/dhcp.conf file.

Now restart your DHCP server using the following command.

service isc-dhcp-server restart

Step 3. Lease Time.

Add the following lines to the config file.

default-lease-time 1800;
max-lease-time 7800;

The default lease time is the time period for which the DHCP server will lease an IP address to the device if a lease time is not provided by the client.

The max lease time it's the maximum lease time that can be allocated to an assigned IP address by the DHCP server.

Step 4. Defining the DNS Server.

A] Your code before defining the DNS server.

default-lease-time 1800;
max-lease-time 7800;
subnet  152.10.15.0 netmask 255.255.255.0{
    range 152.10.15.3 152.10.01.254;
}
subnet 192.168.0.0 netmask 255.255.0.0{
}

B] Code after defining the DNS server.

We have made some changes to the above code. What we have don is, We have added a line about option domain-name-servers and mentioned the two DNS servers that we want our clients to use.

And then we added the option routers for a similar purpose.

default-lease-time 1800;
max-lease-time 7800;

subnet  152.10.15.0 netmask 255.255.255.0{
    range 152.10.15.3 152.10.01.254;
    option domain-name-servers 152.10.15.1, 9.9.9.9;
}
subnet 192.168.0.0 netmask 255.255.0.0{
}
subnet  152.10.15.0 netmask 255.255.255.0{
    range 152.10.15.3 152.10.01.254;
    ==option routers 152.10.15.1;==
}

C] Setting the default gateway.

We have added this line already to the last part of the code in the step 4 B]. We still have to add the line
option routers 152.10.15.1 to the DNS definition.

After you add the line. DHCP will set your DHCP client with the gateway 152.10.15.1.

default-lease-time 1800;
max-lease-time 7800;

subnet  152.10.15.0 netmask 255.255.255.0{
    range 152.10.15.3 152.10.01.254;
    option domain-name-servers 152.10.15.1, 9.9.9.9;
    ==option routers 152.10.15.1;==
}
subnet 192.168.0.0 netmask 255.255.0.0{
}
subnet  152.10.15.0 netmask 255.255.255.0{
    range 152.10.15.3 152.10.01.254;
    option routers 152.10.15.1;
}

Step 5. Reserving IP addresses for special devices.

If you have read the entire guide you must remember the "reservation table".

How the same IP address can be assigned to the same special device, every time it sends a broadcast request.

Here's how you can do it. Consider the host to be one of the special devices you want to get a static IP for.

This is how you can configure DHCP. By adding these lines of codes to the dhcp.conf file.

default-lease-time 1800;
max-lease-time 7800;

subnet  152.10.15.0 netmask 255.255.255.0{
    range 152.10.15.3 152.10.01.254;
    option domain-name-servers 152.10.15.1, 9.9.9.9;
    option routers 152.10.15.1;
}
subnet 192.168.0.0 netmask 255.255.0.0{
}
host device {
    hardware ethernet FC-AA-14-F0-42-E6
    fixed-address 152.10.15.200;
}

In the above code, we used device's MAC address to assign the fixed address 152.10.15.200 to the same device every time it requests for an IP address.

That concludes DHCP server installation for Linux.

Note:
Here's a short not for users who want to know how to install DHCP server in ubuntu.

You can follow the same steps but you will also have to edit the /etc/network/interfaces file with the following code.

auto eth0
iface eth0 inet dhcp

This is how you configure ubuntu DHCP client.

How to configure DHCP server in windows 7.

Step 1:

Go to the DHCP server website. Get the latest version for your windows 7.

DHCP

Step 2:

Next step is to extract the content of the downloaded file.

Once that is done, double click on the dhcpwiz.exe file.

Step 3:

Dhcp configuration wizard. Click on "Next".

DHCPserverconfiguration-1

Step 4:

Network Interface cards.

NetworkInterfaceCards-1

The configuration wizard will present you with a list of identified network interfaces on your computer.

You have to select one from the list if you wish to configure DHCP on windows 7.

This interface will be used by the dhcp server.

Do not choose a network interface whose IP address has been assigned by DHCP server. It will lead to conflict.

After you select a network click on next.

Step 5:

Supported protocols.

Supported-Protocols

Tick the HTTP(web server) checkbox.

Click on next.

Step 6:

Configuring DHCP for Interface

Configuring-DHCP-for-Interface

The IP-pool you can see in the configuration box is actually the scope that we just read about.

We need to configure a list of IP addresses (Range) as you can see in the above figure.

The range here is 192.168.1.1 - 192.168.1.254.

The following image displays the drop down list for lease time.

Configuring-DHCP-Interface

With the advance option you can define the subnet mask, gateway, DNS and WINS.

AdvanceOptions

If you don't define then the DHCP wizard will take it upon itself and define it automatically based on your network interface card.

Click on Next.

Step 7:

Writing the INI file.

WriteINIfile

Click on Write INI file.

"INS file successfully written" will appear at the bottom in place of "Overwrite existing INI file".

Do not tick overwrite existing INI file checkbox.

Click on next.

Step 8:

DHCP Server.

As you can see the status is "Not installed"

BeforeInstallDHCPserver

Click on Install to continue with the process.

AfterInstallDHCPserver

You'll notice that the status will now say "Stopped".

Now move on to the next step.

Step 9:

Start the DHCP server program.

Click on start for that.

Start-DHCP-Server

After you start the service the status will be set to running.

You can visit 127.0.0.1 in your web browser to check the status. It will be displayed to you as follows.

checkstatus

Note: You can stop the service when done by clicking on stop.

StopDHCPServer

If you try to access 127.0.0.1 after stopping the service. You will see something like that in your browser.

Stoppedstatus

Follow the same steps if you want to install and configure DHCP server for Windows 8 or Windows 10.

How to configure DHCP server in windows 2012 server step by step

This step by step installation works for windows server 2012 as well as windows server 2016.

DHCP installation and configuration in windows server 2012:

Step 1) Start the "Server Manager"

Step 2) Go to the "Dashboard".

Step 3) Select "Manage" then click on "Add Roles and Features".

ManageAdd

Image Source

Step 4) You will be greeted with a "Before you Begin" page.

Skim through the content of this window and if you satisfy all the conditions then move forward with the installation and click on "Next".

Step 5) Installation type.

Select the installation type. There are two options for you to select from.

One is the "Role-based on feature-based installation" and the other is "Remote Desktop Services installation.".

Rolebased

Select Role-based on feature-based installation.It configures a single server by adding roles, role services, and features.
Click on "Next".

Step 6) Server Selection.

You will be presented with a Server Pool.

Select a server from the list.

Then click on "Next".

Step 7) Server Roles.

From the roles listed find and tick DHCP Server.

DHCP-server

It will take you to a Add roles and Features Wizard.

Tick the Include manage tools (if applicable) checkbox and then click on add features.

Click on "Next".

Step 8) Features.

You don't mess around with those just click on Next.

Step 9) DHCP Server.

This window will explain in short what DHCP is.
And you should pay attention to the "Things to note:" section.

First, you need to have at least one static IP address on your computer.

The second thing is, you need to plan your subnets, scopes(range) and exclusions before you install the DHCP server.

Click on "Next".

Step 10) Confirmation.

Tick the "Restart the destination server automatically if required"

A dialogue box will open with the message "If a restart is
required, this server restarts automatically, without additional notifications. Do you want to allow automatic restart? as shown in the following image.

restart

Select "Yes".

Then click on Install.

Step 11) After the installation is done. select the Complete DHCP configurations as shown in the image below.

completeDHCPconfiguration

It will open a configuration wizard.

DHCP Post-Install configuration wizard.

1) Description.

Click on "Next".

2) Authorization.

Fill in the appropriate username and then click on "commit".

credentials

3) Summary.

After you complete all these steps click on "close".

Setting The DHCP server

1) Go to Tools , select DHCP.

DHCP

2) Select the entry in the DHCP section by clicking on it.

Right click on IPv4.

Select "New Scope".

It will open the New Scope Wizard.

Now, click next.

3) Add the Name of scope and move to the next page.

Set the IP address range by adding the start IP address and the end IP address.

newscopewiz

When you fill in the Start IP address the configurations settings that propagate to DHCP client will be automatically filled.

Click on "Next".

4) Add the range of IP addresses that you want to exclude from the scope. Or you could even type in a single IP address in the "Start IP address" section and click on add.

Exclusion

Here you can set the Lease duration. Set it and then click next.

5) Configure DHCP Options.

You can choose to configure Gateway,DNS servers and WINS settings now or later. Select the preferable option and click on next.

But here we are going to configure these options now.

So, when you click next you will be asked to add.

i) Gateway IP address, leave it empty and click on Next.

ii) Domain Name and DNS Servers.

Enter your domain name in the Parent domain text box.

Then add the IP address of your domain. in the IP address section.

Now click on next.

iii) As we don't need WINS server we won't make any changes just click on next again.

6) Next, you will be presented with an Activate scope screen.

Select yes and then click on next.

Click on Finish.

That completes the installation. You can now check the details like the scope, exclusion IP addresses or even the dns server in the DHCP window.

To open the DHCP management window again. You can open the run and then type in "dhcpmgmt.msc" and click on ok.

As we have already covered this section works, if you want to find out how to configure dhcp server in windows 2016 server step by step.

Conclusion

From the DHCP basics to the installation and configuration on variety of platforms this guide covers it all.

You won't need to go to other sources if you want to find of what a certain thing means, just check the contents of this guide and then you can navigate to whichever section you want.

Furthermore if you are interested in knowing How to Create IP-Based Virtual Hosting? you can always refer 6 Fast Steps to Create IP based Virtual Hosting using Apache on Ubuntu.

I am an avid book reader, who enjoys technology as well as writing.

Comments