In this lesson, we're going to cover
the configuration of DHCP and DNS for client services
as well as how these protocols are implemented
on a Linux workstation or server.
Now IP address configuration
is one of the most critical settings
on your network devices.
Workstations, servers, routers, and other components
all have to be properly assigned IP addresses
to be able to participate on the network.
IP address configurations can be set one of two ways,
as I've mentioned before.
You can either do this statically or dynamically.
Now each method has its advantages and disadvantages.
It's important to know when you're going to use each method.
Static IP address configuration means that the settings
are implemented manually by an administrator.
This method increases the risk of mistakes,
but it also ensures that the system
always has the exact same IP address and,
therefore, the same network identity.
Dynamic IP address configuration, on the other hand,
means that the settings on that client
are going to change each time.
Cause every time you boot up the system,
it's going to go to the server, ask for an IP address,
and be given one to use temporarily.
This method does decrease the risk of mistakes,
but it means that system is not always going to have
the same IP address or identity on the network.
Dynamic IP address configurations
are usually going to be appropriate for client machines,
not servers.
Static IPs are normally going to be used
for servers and network print devices.
Now a dynamic host configuration protocol server
or DHCP server contains one or more pools of IP addresses
and related configuration options
that we're going to hand out to our client machines
once they connect.
We call this a lease when we hand it out to them
because we're letting them borrow it
for a given amount of time.
Now, by doing this,
we can save ourself a lot of administrative effort
because this IP address information
doesn't have to be configured statically
on each and every system.
DHCP servers are going to be configured
with a given scope or range of available IP addresses
along with some additional options
like the DNS server's location and the default gateway.
The DHCP service, though, has to be installed on a server
that's going to host this DHCP service
and then allow all the client machines
to lease out those configurations from that server.
These workstations are going to
lease their IP address information from that DHCP server,
and the process really consists of four basic steps
that's initiated by the clients
when they boot up and connect to the network.
These four steps follow the acronym DORA, D-O-R-A.
This stands for discover, offer, request, and acknowledge.
The way this works is that
when the client first connects to the network,
it's going to send out a DHCP discover message.
This is the discover process.
Essentially it says,
hey, is there anybody on this network that's a DHCP server.
If the DHCP server sees that message,
it's going to get that discover message
and then reply with what they call an offer request.
This offer message is going to tell the client,
hey, I'm a DHCP server,
and I'm willing to give you an IP address.
If that client wants to take that offer,
it's going to send back what's called a DHCP request message.
This message is going to say, hey, I'm a client.
You're a server.
I would really like to have one of those IP addresses.
And then the server is going to respond back
with what's called a DHCP acknowledged message.
This message is going to send it back to that client and say,
yes, I understand you want an IP address,
and here is your IP address.
You can have it for the next 24 hours, or seven days,
or 30 days, or whatever that lease time is.
In this message, it's also going to give them their IP address,
their subnet mask, the default gateway,
and the DNS server information.
This is all the information that this client is going to need
to configure itself and be able to connect to the network.
At this point, the client will then configure itself
by taking that IP address and assigning it to its interface,
and connect to the network.
Now, as a system administrator,
it's important to understand where you can configure
your DHCP client on your given Linux system.
To do this, you're going to go
into the /etc/dhcp/dhclient.conf file.
This file enables the configuration of DHCP client settings,
including timeout values, dynamic DNS configurations,
and other things like that.
This file is usually managed and edited
using the network manager.
And this serves as your network configuration service
for all of your different network settings,
including your DHCP client configuration.
Whenever you make changes to the DHCP client configuration
inside the network manager,
it's going to update the /etc/dhcp/dhclient.conf file for you.
I recommend you use the network manager,
either in the command line environment,
the text user interface, or the graphical user interface,
to be able to edit this dhclient.config file
because otherwise, you're likely to make mistakes.
Next, let's talk a little bit about DNS and name resolution.
You might remember that TCP/IP data packets
always need to have a source IP and a destination IP.
So if I want to send something to you
or you want to visit my website,
you would need to know its IP address.
Now the problem is we humans are not very good
at remembering lots of different long series of numbers.
So if I had remember the IP address
for every website I wanted to go to,
that would just be a total pain,
and it would make going on the internet not very fun.
Therefore, there's a system created
called DNS or domain name system.
This allows us to type in user-friendly names
like diontraining.com,
and that gets converted to the IP address
and routes our computer over there.
To set this up on your system,
you need to configure your DNS file.
Now to do this, there is really two methods
to be able to do this names to numbers association.
The first way is the original way it was done
on the internet when the internet was a much smaller place.
And it was where there was a static text file
with all of these links inside of it.
This is called the /etc/hosts file.
If you go into your Linux system
and do cat space /etc/hosts, you'll be able to see
if there's anything in your etc/hosts file.
If you want to have some kind of a link
that overrides everything else on your system
in terms of names, you can put it in the etc/hosts file.
For example, one of my kids
was not doing his homework one night,
and he kept going on YouTube.
So I went into his computer.
I edited his etc/hosts file and added youtube.com,
and redirected it to the IP address of his school's website.
So every time he tried to go to YouTube,
it just pushed him right over
to his school's website instead
because your system is always
going to check the etc/hosts file first
before it goes to the second method,
which is that dynamic database known as DNS.
As I said, in the old days name resolution
can be managed using a single static text file.
And we could just add the different names and numbers in it,
like a phone book.
And we could then go to all the websites we wanted to.
When the internet only had 50 or 100
or a couple of thousand computers, that was manageable.
But today, there are millions and millions of websites
so there's just no way to keep up
with all of the IP address changes, additions,
and deletions that may happen.
So we have to use this dynamic system of DNS instead.
So to use DNS, the way our clients work
is they're going to reach out to a DNS server and say,
I would like to go to this hostname, like diontraining.com.
And then the DNS server will look it up and say,
I know where that is, it's this IP address,
and hand you back the IP address in the background,
and your computer then goes over to that IP address.
That's all DNS does in the background
to resolve a name and give you an IP address in return.
This DNS server contains the resource records
that provides all the answers to these different queries
because diontraining.com isn't just one IP address.
We actually have multiple IP addresses
associated with that name, including our email server,
our web server, our FTP server, and things like that.
So we have to have all these records in a DNS server
that we share with the rest of the world.
And that way, they can know where to find our services.
Now, how does your client know which DNS server to look at?
Well, it does this by looking in the /etc/resolv.conf file.
This is known as the /etc/resolve.config file,
and it's stored locally on each Linux system.
And it tells your system the IP address
of one or more DNS servers.
Now because DNS is so important,
it's really a good idea to have at least
two DNS servers listed inside your /etc/resolv.config file.
Now another place you're going to configure DNS
is inside the /etc/nsswitch.conf file.
This includes a couple of different configuration options
you should be aware of.
For example, there's an option in here
related to name resolution that defines the order
in which name resolution methods
are going to be used on your system.
So should you go to etc/hosts first, then DNS?
Or should you go to DNS first and then /etc/hosts?
Whichever one it is,
you need to configure that inside your nsswitch.config file.
I will tell you, as a matter of best practice,
you should go to /etc/hosts first and then go to your DNS,
which is the dynamic method as your second option.
This is how your system is configured by default.
But if you'd like to change it,
you can do that inside the /etc/nsswitch.config file.
Now to set up your different DNS configurations,
you can manually edit these files,
or you could take the easy way out
and use the network manager tool.
Remember, there's a command line version,
a text-based version, and a graphical user interface version
that you can use to easily configure the IP address
of your DNS servers that you want your client to use.
Now, the last thing I want to talk about
is a couple of command line tools
that you should be aware of to interact with the DNS system.
For example, if you wanted to find out right now
what the IP address is for diontraining.com,
you can do that using your Linux system.
Simply open up your terminal,
type in dig space diontraining.com,
and it's going to return the IP address of diontraining.com.
Dig is one of the ways that you can look up information
on DNS and get that value back.
Another way to get information
is to use a tool called nslookup.
Now, nslookup stands for name server lookup,
and this will allow you to go
and interact with a DNS name server
to be able to get information back.
For example, you might want to use nslookup
to be able to go and look at the DNS records
that are associated with my MX records,
which are mail server records for diontraining.com,
and figure out who am I using as an email service provider.
Another thing you can use is host.
Host is another DNS query tool,
and it does the same type of thing as dig and nslookup,
where you can query a DNS server and get the records back
and look at the IP addresses and the names associated
with each of those different records.
Now, the final tool I want to talk about is whois.
Whois is a command line utility
that's going to allow you to communicate with a whois server,
which actually hosts information about people
who own different domain names.
So if you want to find out who owns diontraining.com
and what our contact information is,
what our mailing address is, and things like that,
that's what whois is used for.
You could type in whois then the name diontraining.com
and it will come back with all the information
that we used to register that with the domain authorities
when we bought that domain.
As you can see, there's lots of different things
you should be aware of when it comes to DHCP and DNS.
Remember, you can configure both of these
on your client using the network manager tool.
When it comes to DHCP, you want to use DHCP assignments
when you're dealing with clients,
but you still want to statically assign things
when you're dealing with servers.
When it comes to DNS, remember,
you can interact with the DNS servers
and get information using dig, nslookup, or host.
If you want to find that information
about who owns that domain, you can use the whois command.