Hey everyone and welcome back. Now in the previous nugget we had discussed the very basics around
the dynamic host configuration protocol. Now we learned that we would have to invoke a DHCP server
in order to hand out the IP addressing to our client network. Now in this nugget right here
that is exactly what we're going to be focusing on. We're going to be focusing on the DHCP server
component of this interaction. So with that said how about we dive in and begin the configuration
then. Now the very first thing that we want to do is we want to install a DHCP server. So what I'm
going to see here is sudo apt and I'm going to say isc-dhcp and then hyphen server. If I hit enter
in fact I should actually say apt install getting ahead of myself as per usual so that looks a
little bit better let's hit enter I'll type in my password okay perfect I'll say why hit enter
and the installation should complete. Great so what I will do is I'll clear the screen.
Now the first thing to note is that when we install this server package there is going to be a DHCP
configuration file. Now depending on the distribution that you have this may be in a different location
you may find it in the etsy directory and directly within that you may have a file called DHCP-d
for the DHCP daemon and this will be .conf. Conversely you might actually have within the
etsy directory another directory called DHCP and then within that directory have a DHCP-d .conf.
So really depending on the distribution you may or may not have this sub directory here. Now
another important configuration file we want to know is going to be within the etsy directory
and then within here the default directory and within that directory we should have a file called
isc dhcp-server. Both of these configuration files are going to be important for us so let's go and
check these out then the first one we will check out is going to be the dhcpd .conf file so let's
go there then. Now on my distribution I happen to be in the configuration file resides within
and within the sub directory DHCP within here as we can see we have this dhcpd .conf if I happen
to open this one up and I hit enter now you will recall that when we discussed DHCP in the very
first nugget we learned that DHCP can also handle DNS based information so this is what we're going
to be able to specify right here so we can see here the option domain name in this case we have
example.org I can maybe change this to let's just say the domain name was CBTNuggets example.com
whatever it may be and then I can specify the option domain name servers in this case here I
could just hand out let's maybe say google's public DNS which would be 8.8.8.8 and then we can specify
a default lease time now we can see here that this is 600 that is 600 seconds this ultimately
translates to 10 minutes now we also have a max lease time this is 7200 seconds i.e. two hours
and if I scroll on down we have this option here ddns update style so with respect to DHCP we have
the option for our DHCP servers to participate in updating our DNS zone file records in the case
here this option is specifying the value none i.e. we do not want to attempt to do any type of
updating for our DNS servers now if we scroll on down once again we come here to our subnet
directive we see this right here now this happens to be all commented out so it's not actually taking
effect but we can create our own range that will take effect so what I will do here is I will use
keyword subnet and then I will specify a particular subnet so let's maybe say that we're going to have
a DHCP server that is going to hand out IP addresses within the 10.1.1.0 range and we'll have the subnet
mask of slash 24 which is 255 255 255 0 and then we can do our curly brace so what we're specifying
here is the network which is going to be 10.1.1.0 slash 24 and then within here we want to specify
the actual range of a loud host that we can give out so I could say 10.1.1 and then let's maybe start
from IP address 20 and we will go to 10.1.1 let's maybe say 100 so that is all we're going to be
giving out the very first client that requests an IP address they will get 10.1.1.20 the next one
will get 21 the next 22 all the way up to 100 in which case after that our IP address range will be
exhausted so what we want to do here is to have a semi colon and now what I'm going to say here is
option or routers and what this is going to do it's going to allow us to specify a default gateway
so let's imagine that the default gateway happened to be the very first address within this range
so that would be 10.1.1.1 and then I can do my semi colon and then my curly brace and what we've
done here is create a simple DHCP pool like I say this is the network we are targeting anyone
who wants an address can get the IP addresses from 20 all the way up to 100 and when they make
that request they will also be given their default gateway information of the very first
address within that network 10.1.1.1 now you can actually specify more information right here we
could maybe say you know the default lease time we could have a very specific lease time for this
particular range so we could maybe say 2000 seconds and the max lease time could be maybe say 5000
seconds and if we wanted to have different domain name configurations for this particular pool we
could say option domain name and let's just say the domain here for this one was ipv0.org in fact
I'm forgetting my semi colon here just notice that and in this case here we will say option
domain name hyphen servers and we will give this a different ip address of 8.8.4.4 and
semi colon now there definitely are more configurations that we can change and configure
within this particular file we can do things like static host configuration but for now
that is all we're going to focus on and in fact before I actually even do anything I've just noticed
a very big error on my part before we actually specify the range of ip addresses i.e. this range
right here I actually need to prepend this with the keyword range so this is very very important
just as well I caught that there just remember to do that don't make the same mistake as me
otherwise the configuration will absolutely not work so with that said this should be a valid
subnet configuration and so what I'm going to do is I'll save this and I will exit out we can see we
already have an interface here with an ip address in this case so I have added another ethernet
interface to my device enp0 s8 if I wanted to listen on this interface for devices requesting
dhcp information I could actually specify that I want to listen on this interface and I would do
so within the etsy in fact the better say sudo nano the etsy directory default isc dhcp server
now within here down at our interfaces I would just specify the name of the interface in which I
want to listen so that would be enp0 s8 and conversely if I wanted to have a dhcp version 6
server that is handing out ipv6 addressing then I could also specify that too but in this case here
I will just leave it at v4 so if I save this so if I just happen to open the file once more for
our main configuration there we go remember our subnet range is in the 10110 network so what I could
do is I could say sudo ip adder and I could add the network of 1011 and give my interface an address
of maybe say 3 slash 24 and I'll put this on dev enp0 s8 and if I do an ip adder we can see this
interface here has an ip address within this particular range so what could now happen is if
I draw my little server here this is my ubuntu machine which is now a dhcp server I have my
interface here which is enp0 s3 this ultimately connects to the internet and I now have another
interface here which is enp0 s8 and this has got the ip address of 10113 so now if anyone
happened to be connected on the same network here let's imagine we had a switch and a whole
bunch of different client computers all connected if on that same network segment someone sends out
that broadcast address trying to discover a server we could then reply with an offer within our
particular pool and that client could either accept or refuse that offer and that really is
the basics of what we want to understand for the purposes of our dhcp configurations we have that
main configuration file whereby we can specify our leases we can specify our dns server configuration
we want to hand out the default gateway configuration as well as the network we are serving and the
valid range of addresses we want to serve out and we also have that additional configuration file
which specifies which interface we want to be listening on for incoming dhcp requests in this
case here we're specifying enp0 s8 but notice here that this is all revolving around devices
within the same network here so all these devices here are connected on the same network segment
what would happen then if we happen to have a server on a completely separate segments from
a potential client that would want to use its dhcp services well the reality is we do have a solution
for that that's called a dhcp really and that is what we're going to be talking about in the very
next nuggets i hope this has been informative for you and i'd like to thank you for viewing