In this lesson, we're going to talk about
the Domain Name System, or DNS.
The DNS protocol is used to help our network clients
find a website using human readable host names
instead of numeric IP addresses.
For example, if I wanted to tell you to go to my website,
I can simply say, go to diontraining.com,
and that's a lot easier for you to remember
than having to say something like,
it's at 66.123.45.237,
or whatever the IP address of my web server
happens to be right now.
After all, saying all those numbers out loud
as part of a TV commercial isn't quite as catchy
or memorable as telling your customer
to visit coca-cola.com or microsoft.com,
or diontraining.com, right?
So how does the computer know how to find
the web server's IP from these given domain names?
Well, that is the entire purpose of DNS.
The way DNS works is that when a user's computer
is told to go to Dion Training,
it's going to reach out to a DNS server and say,
"Hey, do you know where I can find Dion training?"
And then the DNS server will reply back
and say, "Oh, yeah, I know where diontraining.com is.
It's located at 66.blah.blah.blah."
Then the client can get redirected to the web server
using the router and their WAN connection.
Since they now know the right IP to use as the destination.
This all happens in the background for your users
without them even having to ask
because DNS is such an embedded part of our networks
and our systems these days.
Now, most of us when we're operating as a home user,
aren't going to be running our own DNS servers,
and instead we rely on our internet service providers
to do this for us, but if you're running your own websites
or you're working for a large corporate network,
you may also want to have your own DNS server
inside of your network, and then you'll be responsible
for setting up your own DNS records
that will dictate what servers are located
at what IP addresses.
This allows you to run your own domain name
and host resolution, which will convert
these domain names to IP addresses.
And if you want to think of it this way,
it's really similar to a contact list on your phone.
Nowadays, how many phone numbers
do you actually have memorized?
Probably not a whole lot because you just pull out
your cell phone and you scroll down to the person's name
and then hit their name with your finger
and it dials them up.
For instance, if I want to call my friend up,
I would simply scroll down to their name,
push my finger on their face,
and my phone on the contacts app,
and immediately it dials their number.
I don't have to memorize those 10 digits.
That's because as people,
we remember names and faces better than we do numbers.
And so we do this face or name to number conversion
in our phones all the time.
Well, it's the same thing for computers,
except computers actually like numbers better than names,
but we as humans want names instead of numbers.
So what we want to do is convert the domain names
into IP addresses that are used for routing
in our computers, and that's what DNS does for us.
It converts names to numbers and numbers to names.
Now, one of the key concepts that we use in DNS
is what's known as an FQDN or a Fully Qualified Domain Name.
This is when a domain name is under a top level provider.
The most common top level provider is .com,
but there's many other ones out there like .mill,
.edu, .org, and .net.
Let's go ahead and use the example of Dion Training.
At Dion Training we have a lot of different servers online
to do a lot of different functions.
One of those servers is actually our web server
located at www.diontraining.com.
Now, the top level domain here is .com,
and the domain name that I use is Dion Training.
To be fully qualified, I'm going to add the www
to the front of it, making it a fully qualified domain name
of www.diontraining.com.
So if you want to get to my web server,
you'll go to your browser and type in www.diontraining.com,
and you'll be redirected to my web server,
because DNS knows that it should resolve the IP address
of my web server anytime somebody asks,
"where is www.diontraining.com?"
Now, on the other hand, if you want to go to a file server,
you might want to go to ftp.diontraining.com.
If you want to go to my mail server,
you might type in mail.diontraining.com.
All three of these are examples
of fully qualified domain names or FQDNs.
Essentially, you're going to have some service, a dot, a name,
a dot, and a top level domain.
And this works the same way
no matter what domain you're looking at across the internet.
Now, DNS is set up as a hierarchy,
and there are actually five different levels
in this hierarchy, starting with the root level,
the top level domain, the second level domain,
the subdomains, and the host.
The root level is the highest level
in the DNS hierarchy tree, and the root name server
is going to answer requests in the root zone.
These servers contain the global list
of the top level domains like .com, .net,
.org, .mil, and many others.
The second level down we have
is what's known as the top level domains.
These are broken up into two categories,
organizational hierarchies like .com, .net, .org,
and others, and then geographic hierarchies
such as .uk for the United Kingdom,
.it for Italy, .fr for France,
and many other countries around the world.
The third level down is what we call
the second level domains.
And these domains are going to tie directly
below the top level domain.
For example, my domain diontraining
is a second level domain underneath the top level domain
of .com, which is underneath the root level.
Now, the fourth level down we have is known as a subdomain.
Now, if I want to create a new server
underneath my second level domain of diontraining.com,
I can do that using a subdomain.
In my case, I have multiple different subdomains,
including the www subdomain
located at www.diontraining.com for my web server.
I have another one called support,
and the support subdomain is support.diontraining.com,
which leads to my support portal,
and I have many, many others.
The fifth and final level is the host level.
Now, this is the lowest and most detailed level
inside the DNS hierarchy,
and it refers to a specific machine.
When we think of DNS though, most of us like to think
of a fully qualified domain name,
something like www.diontraining.com,
which contains a subdomain, a second level domain,
and a top level domain.
Now, if I wanted to take this a step further,
I can actually look at it from a URL perspective,
which stands for a Uniform Resource Locator.
Again, taking my web server as an example
with www.diontraining.com,
that was a fully qualified domain name,
but it doesn't actually tell you
how you're going to access it.
Do you want to access it securely or insecurely?
Well, if you're going to give me your username
and password to log in,
you probably want to do that securely.
So you're going to add https:// to the beginning of it,
and it becomes https://www.diontraining.com,
which becomes a full Uniform Resource Locator,
because it has that https at the beginning.
If you want to access it insecurely, you could do that
by adding http:// to the beginning.
If you wanted to connect to my FTP server
using the FTP protocol, you could do that
by going to FTP://ftp.diontraining.com as the URL.
And this is how DNS works by contacting a DNS server,
and then asking it to convert the name,
like ftp.diontraining.com into an IP address
that's actually hosting the FTP service on a given server.
Now, before we finish up this lesson,
you may be wondering how all this was done
before DNS was created, and the answer is
a flat file known as the host file.
Now, a host file on a computer system
is like an old well thumbed address book
nestled on your desk that's filled with all the names
and addresses of your friends, your families,
and your important contacts.
Stored within your operating system
there's a simple text file that serves
as this first point of contact when a device
wants to seek out communication
with other devices over the network.
Now, whenever you attempt to access a website
by typing in a user-friendly domain name,
like www.diontraining.com,
your system will first take a look into this host file.
If there's a corresponding IP address
for the domain name listed in that host file,
your system will use that information directly
and it will completely bypass the need
for using a DNS server.
This was what was done in early networks
when we just had networks inside a single office,
or building instead of going all over the world.
Now, this traditional mechanism is now considered
a local override for the more complex
globally distributed system known as the Domain Name System.
Even though DNS is the Internet's most comprehensive
and constantly updated system it's continually storing
and translating human friendly domain names
into IP addresses that computers can use
to identify each other on the network,
every time you enter a website's name,
your system has to first consult its host file
to see if it already knows the IP address
for that given domain name.
If it does, it's going to use the host files entry instead.
If it doesn't, then it will go out and send a query
to the DNS instead to get the current IP address
related to that domain name.
Now, the relationship between the host file and DNS
is one of precedents and proximity.
The host file due to its local nature,
takes priority over DNS,
and it has a closer proximity to your computer.
It's like choosing to use a known shortcut
from your personal notebook before you refer
to a citywide map for directions.
This precedent can also be incredibly useful
for various use cases as well.
Network administrators, for example,
often use the host file for testing out
mappings of their domain names to specific IP addresses
before the actual DNS record is set up or updated.
It's also a favorite tool in cybersecurity,
where undesirable websites can be redirected
to non-existent addresses to effectively block them.
For example, when my kids were little
and were watching YouTube
instead of doing their homework each afternoon,
I actually reconfigured the host file on their laptops
so that the domain name of youtube.com
would be redirected to the IP address
of their school's homepage.
And this way, it reminded them it was time for them
to get back to doing their homework.
Then anytime they tried to go to youtube.com
on their laptops, they were being greeted
by their school's login page.
Now, be careful though,
when you're configuring the host file
because it is a powerful tool that can lead to misdirection
of your network traffic if you have the wrong entries
added into that host file.
For example, some malicious attackers
have learned that they can modify
a compromised workstation's host file
so that every time somebody tries to go to something
like gmail.com, they would be redirected to a website
that's actually controlled by the attacker,
and it looks just like gmail.com.
But when the victim logs in into this fake site,
their username and password is going to be collected
and used for further attacks across the internet.
So remember, when it comes to the Domain Name System,
the DNS protocol is going to be used
to help your network clients find a website
using human readable host names
instead of numeric IP addresses.
DNS uses a hierarchy across five levels,
including the root level, the top level domain,
the second level domain, the sub-domains, and the host.
If you do not have an accessible or working DNS system,
you can individually configure your systems
to use the host file instead on your network devices
to provide this alternative to DNS.
But this really only works with a handful of server names
and IP addresses before the flat file becomes too large
and complex for you to effectively use
and update across your different systems.