DHCP (Demo)

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hey cybrarians and welcome back to
00:00
the Linux plus course here at Cybrary.
00:00
I'm your instructor Rob Goelz,
00:00
and in today's lesson,
00:00
we're going to cover DHCP servers.
00:00
Upon completion of today's lesson,
00:00
you're going to be able to understand
00:00
the need for the DHCP server role,
00:00
we'll talk a little bit about how DHCP
00:00
operates and hands out IP addresses
00:00
>> and then finally,
00:00
>> we're going to install this DHCP server role
00:00
>> on both CentOS and Ubuntu.
00:00
Every device in the network requires an IP address.
00:00
You're not able to communicate with
00:00
other devices on the network without an IP.
00:00
The Dynamic Host Control Protocol, or DHCP,
00:00
is used to handout or assign
00:00
an IP address to devices automatically.
00:00
DHCP also distributes required network information.
00:00
Along with handing out the IP address is
00:00
going to hand out the gateway IP address,
00:00
it's going to tell you the name server,
00:00
which we covered in the previous lesson
00:00
>> and it's going to give you
00:00
>> a network mask for that network.
00:00
>> The DHCP server is responsible for keeping track
00:00
>> of all of these things that it hands out
00:00
>> but most specifically the IP addresses.
00:00
>> It has to ensure that each device that it has
00:00
>> in its pool of available IP addresses is unique
00:00
>> so we don't have two systems
00:00
>> with the same IP address
00:00
>> thus creating an IP address conflict.
00:00
>> It also establishes what's called
00:00
>> a lease time for all the IP addresses,
00:00
>> which means that once the lease is up,
00:00
the server has to release that IP address,
00:00
and once lease expires,
00:00
the IP address is returned to a pool,
00:00
and then it's available for use and reuse by DHCP.
00:00
When you're talking about DHCP
00:00
>> handing out IP addresses,
00:00
>> there's a little process here.
00:00
The client starts by sending
00:00
a DHCP discovery requests on port 67.
00:00
The DHCP server then sends an IP offer on port 68.
00:00
The client responds to the request,
00:00
accepting the offer for the IP on port 67,
00:00
and the DHCP server acknowledges
00:00
>> the response on port 68.
00:00
>> You might be asking,
00:00
>> why is Rob enunciating
00:00
>> all of these things so carefully?
00:00
>> It's because this whole process is called DORA.
00:00
D for discovery, O for offer,
00:00
R for request, and A for acknowledgment.
00:00
Just remember when you're talking about
00:00
DHCP on Linux, remember DORA,
00:00
and clients communicate to the DHCP server on port 67,
00:00
the DHCP server communicates
00:00
>> back to the client on port 68.
00:00
>> But let's go ahead and see how DHCP hands out
00:00
addresses with some demo time.
00:00
Here we are under demo environment
00:00
>> and today we're going to start here in CentOS,
00:00
>> and we're just going to go ahead and do a dnf
00:00
install dhcp-server and hit ''Enter''.
00:00
This is a little bit of a fib because
00:00
>> I've already gone ahead and installed this.
00:00
>> But we've got a lot of stuff to cover today.
00:00
I want to make this a little bit quicker
00:00
>> so we won't sit here and watch install.
00:00
>> The next thing I want to show you
00:00
>> is that on this system,
00:00
>> I've set up a secondary static IP address,
00:00
which is here on enp0s8,
00:00
and it is in the network 172.16.10.1.
00:00
Now, what we'll do is we're going to take a look at
00:00
the configuration file for DHCP.
00:00
This is in xtc dhcp, dhcpd.coaf.
00:00
Clear my screen and hit that, and there we go.
00:00
What we're going to see is that we have
00:00
a configured lease time,
00:00
the minimum and maximum amount of time that
00:00
this system can have an IP on the first two lines.
00:00
We're also going to see a setting here for our subnet.
00:00
Remember this is a 172.16.0 network with a slash 25,
00:00
which means it has a net mask of 255.255.255.0.
00:00
We set a range of IP addresses
00:00
that we're going to hand out here,
00:00
and so that range is going to go from
00:00
172.16.10.2 to 172.16.10.100,
00:00
and devices on this network can get
00:00
an IP address from that range when they request it.
00:00
We'll also hand out the router
00:00
>> or the default gateway
00:00
>> as being 172.16.10.1 which is us,
00:00
>> we are the DHCP server,
00:00
and the subnet mask,
00:00
as we said, is a /24.
00:00
Then the last two options I just set up Google
00:00
>> as the domain name server,
00:00
>> so 8.8.8.8, 8.8.4.4
00:00
>> those are the two Google DNS server addresses.
00:00
>> Let's quit out of there.
00:00
>> Now what we need to do in order to start this,
00:00
>> is we just do a system CTL enable.
00:00
We're just going to a --enable now that'll start it
00:00
and enable it every time the system starts up,
00:00
and we say that we're starting up DHCPD.
00:00
There we go, we're good to go.
00:00
Now, the last thing that we need to do
00:00
in order to get this setup is let's check
00:00
>> and see if the firewall system is running on here.
00:00
>> Remember when we were talking about CentOS,
00:00
the firewall in question is going to be firewalld.
00:00
We can just look and see if it's running by doing
00:00
a system CTL status on firewalld and it is running.
00:00
In order to go ahead and add the DHCP
00:00
>> so that DHCP traffic can travel through this firewall,
00:00
>> we have to use our friend,
00:00
the firewall CMD command.
00:00
What we're going to do is say firewall CMD,
00:00
we want to add the service and the service equals DHCP.
00:00
We're going to make this a permanent addition to
00:00
our rules, so I'll say permanent.
00:00
Then we'll just go ahead and reload it.
00:00
Let's do a firewall-cmd --reload,
00:00
and then hit ''Enter''.
00:00
This is going to apply the rules,
00:00
as you can see, I've already enabled these,
00:00
but just for the purposes
00:00
so you can see how this process works,
00:00
that's how we go and add the rules,
00:00
and reload the firewall
00:00
>> and now DHCP traffic can travel.
00:00
>> Let's go ahead and take a look at the same thing
00:00
in our Ubuntu system.
00:00
Here we are over in our Ubuntu system,
00:00
and what we need to do here is do an app install,
00:00
and the installation is a little bit different.
00:00
We're going to install ist-dhcp-server,
00:00
and it'll install the package.
00:00
Again, packages are installed here,
00:00
I cheat a little bit just so we
00:00
wouldn't have to wait for that to finish.
00:00
If we take a look at the system
00:00
by doing IP address lists, ip addr list,
00:00
we can also see that I've configured
00:00
another static network
00:00
here 172.16.20.1 on enp0s8.
00:00
On CentOS was 10,
00:00
here it's 20, just so they don't bump into each other.
00:00
Now, we can look at this system
00:00
>> and the configuration file as well,
00:00
>> so let's do that by going to less xtc dhcp dhcpd.coaf,
00:00
we can look in this file and see what we got here.
00:00
By comparison, we see that
00:00
the lease time and max lease time
00:00
are configured in a different section
00:00
>> instead of in like a single block or a single stanza.
00:00
>> Then we also see that
00:00
the configured range of available IPs
00:00
>> and the subnet is its own separate block.
00:00
>> Just a little bit of a different configuration
00:00
>> for the dhcp.coaf file or dhcpd.coaf file in Ubuntu.
00:00
>> But other than that, not much difference from CentOS.
00:00
Let's quit out of here, and again,
00:00
to go ahead and enable this we do a systemctl
00:00
enable --now on isc-dhcp-server.
00:00
We can see that that is enabled,
00:00
then now we can do a systemctl status,
00:00
and we see that it started in to running.
00:00
We're good to go there.
00:00
With that, we've reached the end of this lesson.
00:00
In this lesson, we covered the need for DHCP servers.
00:00
We talked a little bit about how DHCP operates,
00:00
the DORA process,
00:00
port 67, port 68, don't forget that.
00:00
Then we talked about how to install
00:00
the DHCP server role on CentOS and Ubuntu.
00:00
Thanks so much for being here
00:00
>> and I look forward to seeing you in the next lesson.
Up Next