Title: An introduction to Domain Name System: DNS
1An introduction to Domain Name System DNS
2Why use DNS Domain Name System?
- Internet Hosts
- IP address (32 bit for IPV4) - used for
addressing datagrams (used by computer) - name, e.g., www.yahoo.com - used by humans
- DNS provides translation between host name and
IP address - distributed database implemented in hierarchy of
many name servers - distributed for scalability reliability
3DNS Services
- Hostname to IP address translation
- Host aliasing
- Canonical and alias names
- Mail server aliasing
- Load distribution
- Replicated Web servers set of IP addresses for
one canonical name
4DNS Infrastructure
root DNS server
2
- Host at cis.hku.edu wants IP address for
gaia.cs.umass.edu - Infrastructure
- Client resolver
- Local DNS server
- Authoritative DNS Server
- Root DNS Server
- Top-Level Domain DNS Server
3
TLD DNS server
4
5
6
7
1
8
authoritative DNS server dns.cs.umass.edu
requesting host cis.hku.edu
gaia.cs.umass.edu
5Distributed, Hierarchical Database
- Root servers and TLD servers typically do not
contain hostname to IP mappings they contain
mappings for locating authoritative servers.
6DNS Root name servers
- contacted by local name server that cannot
resolve name directly - root name server
- contacts authoritative name server if name
mapping is not known - gets mapping
- returns mapping to local name server
7TLD and Authoritative Servers
- Top-level domain (TLD) servers responsible for
.com, .org, .net, .edu, .gov, .mil, and all
top-level country domains (e.g., .hk, .cn, .uk,
.fr, .ca, .jp) - Different companies in different countries
maintain servers for different top-level domain
servers. - Authoritative DNS servers organizations DNS
servers, providing authoritative hostname to IP
mappings for organizations servers (e.g., Web
and mail). - Can be maintained by organization or service
provider
8Local Name Server
- Each ISP (residential ISP, company, university)
has one. - Also called default name server
- When a host makes a DNS query, query is sent to
its local DNS server - Acts as a proxy (for request handling and data
caching), forwards query into hierarchy. - Reduces lookup latency for commonly searched
hostnames
9Recursive queries
- recursive query
- puts burden of name resolution on contacted name
server - heavy load?
- iterated query
- contacted server replies with name of server to
contact - I dont know this name, but ask some other
server
10DNS caching and updating records
- once (any) name server learns mapping, it caches
mapping - cache entries timeout (disappear) after some time
called the Time To Live (TTL) - TLD servers typically cached in local name
servers - Thus root name servers not often visited
- update/notify mechanisms under design by IETF
(optional) - RFC 2136
- http//www.ietf.org/html.charters/dnsind-charter.h
tml
11DNS records
Optional
- DNS distributed database storing resource
records (RR)
- TypeCNAME
- name is alias name for some canonical (the
real) name - www.ibm.com is really servereast.backup2.ibm.com
- value is canonical name
- TypeA
- name is hostname
- value is IP address
- TypeNS
- name is domain (e.g. foo.com)
- value is IP address of authoritative name server
for this domain
- TypeMX
- value is name of mail server associated with name
12DNS protocol, messages
Optional
- DNS protocol query and reply messages, both
with same message format
- message header
- identification 16 bit for query, reply to
query uses same - flags
- query or reply
- recursion desired
- recursion available
- reply is authoritative
13DNS protocol, messages
Optional
Name, type fields for a query
RRs in response to query
records for authoritative servers
additional helpful info that may be used
DNS messages are carried using UDP on port 53
14Inserting records into DNS
Optional
- Example just created startup Network Utopia
- Register name networkutopia.com at a registrar
(e.g., AsiaRegistry for HK69.0 per year, really
cheap!) - Need to provide registrar with names and IP
addresses of your authoritative name server
(primary and secondary) - Registrar inserts two RRs into the com TLD
server - (networkutopia.com, dns1.networkutopia.com, NS)
- (dns1.networkutopia.com, 212.212.212.1, A)
- Put in authoritative server Type A record for
www.networkutopia.com and Type MX record for
networkutopia.com - How do people get the IP address of your Web
site?
15Introduction to HTTP
- Refs
- RFC 1945 (HTTP 1.0)
- RFC 2616 (HTTP 1.1)
16What is HTTP?
17Web Components
- In order to start communicating with one anothers
we need the following web components
- User, Author
- User Agent Browser (MS IE, Firefox)
- Network
- Web Server Apache, IIS
- Proxy Squid, ISA, Fiddler (beyond the scope of
this course)
H
Proxy
www.hku.hk
HTTP Message
Cache
Content Delivery Network
18What is HTTP?
- HTTP is the protocol that supports communication
between web browsers and web servers. - A Web Server is a HTTP server
- Most clients/servers today speak version 1.1, but
1.0 is also in use.
19Netscape
A Brief Timeline of HTTP
Marc Andreessen
NN Mozilla
Firefox Mozilla/5.0
TEXT
IMAGE
WorldWideWeb Nexus
NCSA Mosaic
MS IE
w3C
CERN
Berners-Lee
NCSA HTTPD
Apache
R. Fielding
httpd
HTTP/1.1
HTTP/0.9
HTTP/1.0
1989
1999
1991
1996
GET
20From the RFC
- HTTP is an application-level protocol with the
- lightness and speed necessary for distributed,
- hypermedia information systems.
21Domain Name Mapping
nslookup www.hku.hk nslookup www.hku.edu.hk
Domain Name 1
IP
Domain Name 2
www.hku.hk
147.8.145.43
www.hku.edu.hk
TCP/IP
Client
147.8.145.43
Host www.hku.edu.hk
Content of www.hku.edu.hk
HTTP
22Transport Independence
- The RFC states that the HTTP protocol generally
takes place over a TCP connection, but the
protocol itself is not dependent on a specific
transport layer.
23From Plain Text to Hypertext
space
- Text to Hypertext
- eBook eDocument (internal link)
- Gopher external links
- Multimedia Images Audio Video
- Interactive Page
- JavaScript
- Java Applet
- ActiveX Object
- Flash
- More App than just static Doc
Transcending space and time
time
24HTTP Request - Response
25Request - Response
- HTTP has a simple structure
- client sends a request
- server returns a reply.
- HTTP can support multiple request-reply exchanges
over a single TCP connection.
26Well Known Address
- The well known TCP port for HTTP servers is
port 80. - Other ports can be used as well... Depending how
the web server has been set up.
27HTTP Connection Process
- DNS Lookup for IP
- Use IP to Build TCP Connection on port 80
- Send HTTP Request
- Parse Servers Response
- Get Inline Resources
- Rendering UI
Domain name
DNS
- hkuspace.hku.hk ? ?10.10.100.103
IP
GET / HTTP/1.1
httpd
HTTP
80
httpd
TCP
IP
10.10.100.103
28HTTP Versions
- The original version now goes by the name HTTP
Version 0.9 - HTTP 0.9 was used for many years.
- Starting with HTTP 1.0 the version number is part
of every request. - tells the server what version the client can talk
(what options are supported, etc).
29HTTP 1.0 plus Request
Request-Line
Headers . . .
A Simplified Model good enough for us to
understand how it works.
- Lines of text (ASCII).
- Lines end with CRLF (control linefeed) \r\n
- First line is called Request-Line
blank line
Content...
30Request Line
- Method URI HTTP-Version\r\n
- The request line contains 3 tokens (words).
Depending on the front side bus (FSB) of the
machine, normally a word is 32-bit long. - space characters separate the tokens.
- Newline (\n) seems to work by itself (but the
protocol requires CRLF)
31Request Method
- The Request Method can be
- GET HEAD PUT
- POST DELETE TRACE
- OPTIONS
- future expansion is supported
32HTTP Methods
Browser
open
page1
- Message Request Response
- Start Line
- Header Fields
- Body
- Request GET Method
- Get a document from the server
- Start Line GET / HTTP/1.1
- Response
- Start Line HTTP/1.1 200 OK
page2
Session
close
33Methods
- GET retrieve information identified by the URI.
- HEAD retrieve meta-information about the URI.
- POST send information to a URI and retrieve
result.
34Methods (cont.)
- PUT Store information in location named by URI.
- DELETE remove entity identified by URI.
35More Methods
- TRACE used to trace HTTP forwarding through
proxies, tunnels, etc. - OPTIONS used to determine the capabilities of
the server, or characteristics of a named
resource.
36Requests
Method OPTIONS GET HEAD POST PUT DELETE TRACE CONN
ECT
- Start Line
- ltmethodgt lturigt HTTP/ltversiongt
- GET / HTTP/1.1
- GET /index.html HTTP/1.1
- Header Field
- ltnamegt ltvaluegt
- User-Agent Mozilla/4.0
- Host www.hku.hk
37Responses
Status Code 1xx Informational 2xx
Successful 3xx Redirection 4xx Client
Error 5xx Server Error
- Start Line
- ltstatus codegt ltreason phrasegt
- 200 OK
- Header Fields
- Cache
- Date Sun, 04 Jun 2006 125615 GMT
- Misc
- Server Apache/1.3.26 (Unix) PHP/4.2.1
- Entity
- Content-Type text/html
- Last-Modified Sat, 17 Mar 2001 155516 GMT
- ETag "2d693e-5d55-3ab388e4"
38HTTP Status Code
39Status Codes
- 1xx Informational
- 2xx Success
- 3xx Redirection
- 4xx Client Error
- 5xx Server Error
40Status Code List More details
- 404 - Not Found
- 405 - Method Not Allowed
- 406 - Not Acceptable
- 407 - Proxy Authentication Required
- 408 - Request Timeout
- 409 - Conflict
- 410 - Gone
- 411 - Length Required
- 412 - Precondition Failed
- 413 - Request Entity Too Large
- 414 - Request URI Too Long
- 415 - Unsupported Media Type
- 416 - Requested Range Not Certifiable
- 417 - Expectation Failed
- 500 - Internal Server Error
- 501 - Not Implemented
- 502 - Bad Gateway
- 503 - Service Unavailable
- 504 - Gateway Timeout
- 100 - Continue
- 101 - Switching Protocols
- 200 - OK
- 201 - Created
- 202 - Accepted
- 203 - Non-Authoritative Information
- 204 - No Content
- 205 - Reset Content
- 206 - Partial Content
- 207 - Multi-Status
- 300 - Multiple Choices
- 301 - Moved Permanently
- 302 - Found
- 303 - See Other
- 304 - Not Modified
- 305 - Use Proxy
- 306 - No Longer Used
- 307 - Temporary Redirect
- 400 - Bad Request
41Example Status Lines
- HTTP/1.0 200 OK
- HTTP/1.0 301 Moved Permanently
- HTTP/1.0 400 Bad Request
- HTTP/1.0 500 Internal Server Error
42Web Log Analysis
Some status seldom appears but it may be
important
43Response Headers
- Provide the client with information about the
returned entity (document). - what kind of document
- how big the document is
- how the document is encoded
- when the document was last modified
- Response headers end with blank line
44Web Log Analysis
4,078
Some status seldom appears but it may be
important
45Response Header Examples
- Date Wed, 30 Jan 2002 124817 EST
- Server Apache/1.17
- Content-Type text/html
- Content-Length 1756
- Content-Encoding gzip
46Content
- Content can be anything (sequence of raw bytes).
- Content-Length header is required for any
response that includes content. - Content-Type header also required.
47Single Request/Reply
- The client sends a complete request.
- The server sends back the entire reply.
- The server closes its socket.
- If the client needs another document it must open
a new connection.
This was the default for HTTP 1.0
48Persistent Connections
- HTTP 1.1 supports persistent connections (this is
the default). - Multiple requests can be handled over a single
TCP connection. - The Connection header is used to exchange
information about persistence (HTTP/1.1) - 1.0 Clients used a Keep-alive header
- It may however, waste up expensive network
bandwidth.
49GET vs POST
- A more detailed discussion
50GET or Post? Which to use?
- Whats the difference between GET and POST to the
beginner? - How is GET treated differently from POST
- Why would you use one over the other?
- Not many web programmers can really answer this
question?
51A Closer Look
- Lets backtrack a little and look at the form
elements method attribute - Form method"get" action""
- There are other methods but for the most part GET
and POST are your two basic alternatives. - This is the method that the form will use to send
the information to the server. Note the form data
will be sent in plain text regardless of whether
GET or POST is used.
52Explaining the GET Method
- The simple thing to note about GET is that when
you use GET the content of your form will become
URL encoded into a query string. - That means in the address bar of your browser
where you type in URLs the content of your form
will become a query string appended after a ? as
namevalue pairs. - For example if your form took your name and your
age the corresponding query string attached to
the URL would be - ?namestevenage43
- In general, GET is meant for when you get from
the server rather than POSTÂ being meant to
post to the server.
53Get Uses the Header
- One useful thing to note about query
strings appended to your URL and the GET method
is that search terms used with GET can be
bookmarked as a result set. - Its worth keeping in mind. Its perhaps worth
noting that GET data is sent in the header part
of a request to the server. - Also, if no method attribute is put
forward then the default method is GET. - A limitation of GET, to be aware of, is that its
size is limited to the buffer input size of the
server so you might send too much data in your
request.
54URL Encoding of GET
- So what is URL encoding? Well, URL encoding is an
important function that makes the query string
valid. If I entered my full name in the previous
example the space between steven and clark would
be URL encoded to a sign. - ?namestevenclarkage43
- To see this URL encoded output make a small form
with two or three fields and send it to your
email account using an action of mailto. - You can easily see the GET data turned into a
query string in the browser address bar whereas
the POST data is not turned into a query string
in the browser address bar.
55POST uses the Body
- POST, on the other hand, is sent in the body of
the request after the headers and is not visible
to the user as a query string. The content is
sent as namevalue pairs but not made visible in
the address bar of the browser. - In that way, although its still only text, it can
be a little bit more secure (from the person
reading your age over your shoulder) than GET. - The main thing to put in your head about using
methodpost is that you use it to POST data to
the server for processing - for example entry
into a database or contact form details.
56How does GET and POST exist on server-side?
- A further note, if youre looking at CGI
programming, GET and POST are treated
differently. GET is available as an environment
variable whereas POST is available through the
standard input stream (stdin). (Please revise
your C programming notes if you have forgotten
what is an input stream).
57A Rule of Thumb
- A good basic rule of thumb is
- If youre sending off form data you should be
using POST. - If you are just running search queries then GET
might be appropriate. - Please consult W3C for more accurate answers if
you wish.
58A Simple HTTP Lab
59 telnet
Optional
- Step 1 run telnet
- begin\run\executetelnet
- Step 2 Setting up Buffer Size (Optional)
- Pull Down Menu\Content\
- format Screen buffer Size\Resolution 500
- Option/Command Record
- Buffer Size 999 and number of connections 40
- Step 3 Establish Connection
- Microsoft Telnetgt open www.hku.hk 80
60Test it with telnet
Optional
- gt telnet www.hku.hk 80
- GET / HTTP/1.0
- HTTP/1.0 200 OK
- Server Apache
- ...
Request-line
Blank Line (end of headers)
Response
61Test it with telnet 1.1
Optional
- gt telnet www.hku.hk 80
- GET / HTTP/1.1
- Host www.hku.hk
- HTTP/1.0 200 OK
- Server Apache
- ...
Required!
62Reference
- W3C School
- ???Linux ???-- DNS Server
- DNS Resources Directory