DEV Community

Amin Arria
Amin Arria

Posted on

How to teach DNS and DHCP

I'm going to do a small talk/workshop/class to teach DNS and DHCP basics to the new members of our small sysadmin-like lab at my university. The main objective is to give the basics concepts, how to setup, and how to properly maintain an existing domain. So I was wondering what was the best way (or well, your way) to approach this and any tips/recommendations you had.

Top comments (3)

Collapse
 
math2001 profile image
Mathieu PATUREL

I'd say I'm intermediate when it comes to this kind of thing (pretty close to a beginner though), but here's how I think I would have understood it:

DHCP

DHCP stands for Dynamic Host Configuration Protocol.

Your DHCP is your router, usually, the box your internet provider gave you.

A DHCP server gives your device an IP, and a default configuration with it.

Here's a simple scheme:

        Router (Global IP: 202.168.17.148, Local IP: 192.168.1.1)
         /                      |                   \
        /                       |                    \
Laptop (192.168.1.3)  Home computer (192.168.1.2) Your phone (192.168.1.4)

The devices under your router, unlike your router, don't have a global IP (an IP that can be accessed from anywhere on the internet). They are "hidden" behind it.

A proof? Lookup "what is my IP" on Google on different devices connected to your router.

It'll be the exact same.

It's very easy to communicate with devices on your local network. You just need their IP. For example, from your Home Computer, if you open the command prompt and run ping 192.168.1.3, it'll ping your laptop.

If, on your Home Computer, you run a server like this for example:

python -m http.server 8080

This runs the default Python's server on port 8080.

Now, on your phone, open up your browser and type in the URL 192.168.1.4:8080.

You'll the index page of your Python's server.

DNS

Every domain name is associated with the IP of a server, server which is going to give you the web page you're looking for. Well, a DNS is a server that gives you the IP address from the domain name.

So here's what happens when you contact to your router and go on dev.to:

  1. Your router (DHCP), gives you an IP (let's say 192.168.1.5), and some configuration, including the IP to a DNS server.
  2. You switch to your browser and open enter dev.to
  3. Your computer asks the DNS server which IP corresponds to dev.to, which gives it 151.101.129.41
  4. Finally, your computer asks 151.101.129.41 for the web page.

If every DNS servers (because, obviously, there are more than one) doesn't work properly, that means internet won't work (and this is why there regularly is some attack on the most common DNS servers).

A real example (which actually happen to me a few weeks back): my internet provider is TPG, and I live in Australia. From time to time, github.com just wouldn't work (that's when you realize that you use GitHub for literally everything). It could last for a whole day! After searching it up on the internet, I found out I wasn't the only one to have this problem with TPG.

And guess what was the problem: TPG's DNS server that I was using (the one that my router gave by default) wasn't working properly. The solution was to override the DHCP's configuration, in other words, change in my computer's setting the DNS server I wanted to use.

8.8.8.8 and 8.8.4.4 are Google's open DNS server, which are the ones I know use.

Collapse
 
penderis profile image
Keith

So one is a security guard with an address book that takes the name, checks for the number, if the number exists then it let's you go there?

The other gives you an address so you know what your house number is on your block?

Collapse
 
math2001 profile image
Mathieu PATUREL

So one is a security guard with an address book that takes the name, checks for the number, if the number exists then it let's you go there?

Not really, it just tells you where to find what you're looking for. You have to actually go get it (or your slave, aka browser).

The other gives you an address so you know what your house number is on your block?

You don't really care about where you live, although if you ask nicely, you can still chose which house you want, but some bad things will happen if some's already there! You just want him to remember where you live so that he'll be able to deliver the pizza you're going to order at the right place.