Skip to content

Latest commit

 

History

History
113 lines (82 loc) · 6.8 KB

intro-to-dns-ip.md

File metadata and controls

113 lines (82 loc) · 6.8 KB

What is DNS?

Projected Time

About 1 hour

  • Lesson - 10 min
  • Guided Practice - 10 min
  • Independent Practice - 30-40 min

Prerequisites

Motivation

Understanding about DNS is important when it comes to IP address or URL of a website. DNS plays an important role in communicating with a website, like, when we enter "www.google.com", do you know what really happens behind the scenes? Let's find out.

Objectives

  • Participants will have a rudimentary understanding of how DNS works.

Specific Things To Teach

  • What is DNS?
    • First, what is domain name?
      • Domain name vs website
    • DNS stands for: Domain name system
    • DNS is a directory that maps friendly/readable names to IP addresses
      • Common metaphors
        • Meh: Phone books (so old school)
        • Better: Street addresses

Materials

  • Computer with terminal application

Group Lesson

  1. On your command line, enter ping google.com. Let it run for a few seconds, then press control+C. "Does anyone know what ping means?"
    • Ping: to query another computer on a network to determine whether there is a connection to it.
    • The PING command sends packets of information to a specified IP Address and then measures the time it takes to get a response from the specified computer or device.
  • Discuss output from ping google.com.
  1. DNS lookup: Act out what happens to the request. Literally have one person deliver a "packet," bouncing from different name servers, like what happens in this video or this comic.
  • A visual explanation of how DNS lookups work

If a browser has a domain name like www.abc.com that it needs an IP address for, it will query these systems in order:

  • Its own Operating System. If the domain name's corresponding IP address isn't on record, then it will query...

  • The name server (DNS server) it is set up to use. This is the recursive name server shown above. The name server doesn’t know the IP address for www.abc.com, so it will start the following chain of queries before it can report back the IP address to your computer

    1. Query the Internet root servers to get the name servers for the .com TLD.

    2. Query the .com TLD name servers to get the authoritative name servers for abc.com.

    3. Query the authoritative name servers for abc.com to finally get the IP address for the host www.abc.com, then return that IP address to your computer.

  • Done! Now that your computer has the IP address for www.abc.com, it can access that host.

    (photo and steps are from https://royal.pingdom.com/2009/06/08/a-visual-explanation-of-how-dns-lookups-work/)

Group Practice

Let's setup a DNS server locally, it's easy!

  1. Enter sudo vim /etc/hosts
##
  # Host Database
  #
  # localhost is used to configure the loopback interface
  # when the system is booting. Do not change this entry.
  ##
  127.0.0.1   localhost
  255.255.255.255 broadcasthost
  ::1             localhost
  fe80::1%lo0 localhost
  
  1. discuss output of: ipaddress domain
##
  # Host Database
  #
  # localhost is used to configure the loopback interface
  # when the system is booting. Do not change this entry.
  ##
  127.0.0.1   localhost
  255.255.255.255 broadcasthost
  ::1             localhost
  fe80::1%lo0 localhost
  
  1. Edit hosts file to point '127.0.0.1' to 'whatever.whodat'

Example:

127.0.0.1   myblog.dev
  
  1. ping whatever.whodat

Expected output:

$ ping myblog.dev
PING myblog.dev (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.041 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.089 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.047 ms

Independent Practice

  • Spend 20 minutes watching this video and reading this comic. Take notes if you think it will help.

  • Find a partner. Without any resources to look at, try to explain the process after your partner asks you, "What happens when you enter google.com in your browser search bar?"

Challenge

  • Run a local domain name server on your computer that can resolve all requests for a given top level domain to the localhost, and forward everything else to the Internet as normal.