Skip to content

IP and DNS

kimschles edited this page Apr 11, 2019 · 7 revisions

IP and DNS

IP Addresses

Khan Academy: IP and DNS

IP

Basics

  • Internet Protocol Address
  • A number to identify a piece of hardware on a network (the internet and others)
  • IP addresses were developed by Vint Cerf and Bob Kahn to make sure that networks could communicate with one another.
  • Most common IPv4 format: 151.101.65.121
    • Each number is represented in bits.
    • IPv4 addresses contain 32 bits
    • 8 bits for each part of the address
    • The first slot is for country/network
    • The second slot is for region/network
    • The third slot is for a subnetwork
    • The fourth slot is the addresses of the specific device
  • IPv6 format: 2400:cb00:2048:1::c629:d7a2 (hexidecimal)
    • 128 bits per addresses

Private vs. Public IP adddress

Private IP Addresses

  • Used behind a router or NAT device
  • Sometimes called 'local IP addresses'
  • The addresses are not available publically
  • Private Addresses Ranges:
    • 10.0.0.0 to 10.255.255.255
    • 172.16.0.0 to 172.31.255.255
    • 192.168.0.0 to 192.168.255.255
  • Said another way:
    • 10.0.0.0/8 (~ 16 million addresses)
    • 172.16.0.0/12 (~ 1 million)
    • 192.168.0.0/16 (~ 65,000)
  • Most home routers have the address 192.168.1.1
  • Find your default gateway (on MacOS): netstat -rn | grep default
  • Reserved IP addresses
    • 127.0.0.1 to 127.255.255.255
    • Loopback address (localhost!)

DNS

  • DNS servers have a list of domain names and the IP address of those domains

  • IP versions: IPv4 and IPv6

  • Kinds of IP addresses:

    • Private
    • Public
    • Static
    • Dynamic
  • DNS servers are divided by zones.

  • Cloudflare: DNS

  • OSU DevOps Bootcamp: DNS

  • Checks cache

  • If chache doesn't have a domain name and IP address saved, the browser (?) checks the root server

  • The root server will tell the computer to check the top-level domain node (.org, .com, .io)

Kinds of DNS Servers

  • Recursive

  • Authoritative

  • DNS servers cache records. Each record has a Time to Live (TTL) that specifies how long to cache the record.

  • Wildcard DNS record: a record in a DNS zone that matches requests for domains that don't exist. *.example.com

Check DNS

  • host <domain.com>
  • netstat -rn
    • See the IP tables on your computer
  • dig NS <domain.com>

How DNS Works

Software Freedom School, January 5, 2019

https://cfedde.gitlab.io/how-dns-works-and-why-you-care/

The Domain Name System is a distributed Hierarchical database with low referential integrity.

  • low referential integrity means that different servers might have different information

DNS is organized as a hierarchy. There is a tree that contains records. The top is root, then TLDs, then second-level domains

Root name server

  • The first step in resolving human readable domain names into their IP address
  • .

TLD = top level domain

  • .com, .edu, .gov, etc.
  • You can lookup the root name servers for a TLD with dig <tld> ns, for example dig com ns

Types of DNS records

  • A records (for ipv4)
  • AAAA records (for ipv6)
  • PTR records
  • MX records (mail servers)
  • SRV
  • LOC
  • TXT (text)

Fun fact: DNS uses UDP, not TCP

Command Line Tools

  • whois <domain.name>

    • a domain name directory maintained by ICANN and IANA
    • whois gives your information about the domain name registrar and who administers the domain
  • dig: domain information groper (perform DNS lookups)

  • A way to get information from a DNS name server

    • dig kimschlesinger.com
      • Returns the A records
    • dig NS <domain_here>
    • When no command line arguments or options are given, dig will perform an NS query for "." (the root).
    • dig your_domain_name.com +short for the IP addresses

Digital Ocean dig

  • nslookup is like dig, but returns less information

DNS configuration

  • /etc/resolv.conf on linux machines
  • See DNS configuration on a mac: scutil --dns

Possible Learning Objectives

  • Describe the purpose of DNS
  • Explain the difference between TCP and UDP
  • View information about a specific domain name with whois
  • View the A records of a specific domain name with dig
  • Describe the difference between NS and SOA
  • Identify the root name servers for the info domain using dig
  • Illustrate how DNS resolves a domain name
Clone this wiki locally