The DNS and FTP Protocols

The DNS and FTP Protocols

1. The DNS System

DNS Overview

DNS (Domain Name System) is a core service of the Internet, responsible for converting domain names into IP addresses.

The Hierarchical Name Space

The structure of a domain name:

  • The root domain: the highest level, written as ”.”
  • Top-level domains: country codes (such as .cn, .us) or organisation types (such as .com, .org)
  • Second-level domains: the name of an organisation or institution
  • Host names: the name of a particular host

Examples of domain names:

  • www.example.com
  • mail.google.com
  • ftp.microsoft.com

Name Servers

Root servers:

  • There are 13 root server addresses worldwide
  • They hold the information about the top-level domain servers
  • They answer queries for the top-level domains

Top-level domain servers:

  • They hold the information about the second-level domain servers
  • They administer a particular top-level domain
  • For example .com, .org, .cn

Authoritative servers:

  • They hold the IP addresses of the particular domains
  • They administer a particular domain
  • They provide the final resolution result

Caching servers:

  • They store the results of queries
  • They reduce repeated queries
  • They speed up resolution

The Name Resolution Process

Recursive query:

  1. The client queries the local DNS server
  2. The local DNS server queries a root server
  3. The root server returns the address of a top-level domain server
  4. The local DNS server queries the top-level domain server
  5. The top-level domain server returns the address of the authoritative server
  6. The local DNS server queries the authoritative server
  7. The authoritative server returns the IP address
  8. The local DNS server returns the result to the client

In a recursive query the local DNS server carries out the whole chain on the client’s behalf and hands back the final answer; the client makes a single request.

Iterative query:

  1. The client queries the local DNS server
  2. The local DNS server queries a root server
  3. The root server returns the address of a top-level domain server
  4. The local DNS server queries the top-level domain server
  5. The top-level domain server returns the address of the authoritative server
  6. The local DNS server queries the authoritative server
  7. The authoritative server returns the IP address
  8. The local DNS server returns the result to the client

In an iterative query each server returns a referral — the address of the next server to ask — and the local DNS server walks down the chain itself.

The DNS Protocol

Query types:

  • A record: a domain mapped to an IPv4 address
  • AAAA record: a domain mapped to an IPv6 address
  • CNAME record: an alias for a domain
  • MX record: the mail exchange record
  • NS record: the name server record

Port number: 53 (UDP/TCP)

2. The FTP Protocol

FTP Overview

FTP (File Transfer Protocol) is the standard protocol used for file transfer.

How FTP Works

The two-connection model:

  • The control connection: carries the commands and the responses
  • The data connection: carries the file data

Establishing the connections:

  1. The client establishes a control connection to the server
  2. The server responds to the connection request
  3. The client sends its credentials
  4. The server verifies the user’s identity
  5. A data connection is established for the file transfer

The Control Connection

Functions:

  • Carries the FTP commands
  • Carries the server’s responses
  • Manages the FTP session

Common commands:

  • USER: the user name
  • PASS: the password
  • LIST: list the files
  • RETR: download a file
  • STOR: upload a file
  • QUIT: close the connection

Response codes:

  • 200: the command succeeded
  • 220: the service is ready
  • 331: a user name is needed
  • 425: the data connection cannot be opened
  • 500: syntax error

The Data Connection

Functions:

  • Carries the file data
  • Carries the directory listings
  • Carries the file information

Transfer modes:

  • Active mode: the server connects to the client
  • Passive mode: the client connects to the server

Data formats:

  • ASCII mode: transfer of text files
  • Binary mode: transfer of binary files

Characteristics of FTP

Advantages:

  • High reliability: it runs over TCP, which guarantees reliable transfer
  • Complete function set: it supports upload, download, deletion, and so on
  • Broad compatibility: it runs on many operating systems
  • Authentication: it supports user name and password authentication

Disadvantages:

  • Weak security: the traffic is plaintext and easily eavesdropped
  • Firewall problems: the two-connection model is easily restricted by firewalls
  • Low efficiency: the protocol overhead is comparatively large

FTP Variants

SFTP:

  • Secure FTP based on SSH
  • The transfer is encrypted
  • It uses a single connection

FTPS:

  • FTP based on SSL/TLS
  • The transfer is encrypted
  • It keeps the original functions of FTP

3. DNS and FTP Applications

DNS Applications

Name resolution:

  • Converts domain names into IP addresses
  • Supports IPv4 and IPv6
  • Provides load balancing

Mail routing:

  • MX records designate the mail servers
  • They support a priority order among mail servers
  • They provide the mail routing service

Security services:

  • DNSSEC provides authenticated verification
  • It prevents DNS hijacking
  • It keeps the resolution of a name secure

FTP Applications

File transfer:

  • Uploading files to a server
  • Downloading files from a server
  • Deleting files on a server

File management:

  • Listing the contents of a directory
  • Creating and deleting directories
  • Renaming files

Batch operations:

  • Uploading many files at once
  • Downloading many files at once
  • Automated scripts

Exercises

Exercise 1

What are the main steps in the DNS name resolution process?

dnsname resolutiondomain name system

Approach

Walk down the hierarchy in the order the queries travel — client, local server, root, top-level domain, authoritative server — and then describe the return path.

Steps

  1. Describe the client query.
  2. Describe the local DNS server lookup and its cache check.
  3. Describe the root server lookup.
  4. Describe the top-level domain server lookup.
  5. Describe the authoritative server lookup.
  6. Describe the return of the result.

Answer

The DNS name resolution process consists of the following main steps:

  1. The client query:

    • The client sends a query request to the local DNS server
    • The query carries the domain name to be resolved
  2. The local DNS server lookup:

    • The local DNS server checks its cache
    • If there is a cached result, it is returned directly
    • If not, it queries a root server
  3. The root server lookup:

    • The local DNS server queries a root server
    • The root server returns the addresses of the top-level domain servers
    • For example the addresses of the .com and .org servers
  4. The top-level domain server lookup:

    • The local DNS server queries a top-level domain server
    • It returns the address of the authoritative server
    • For example the authoritative server for example.com
  5. The authoritative server lookup:

    • The local DNS server queries the authoritative server
    • The authoritative server returns the final IP address
    • The conversion from a domain name to an IP address is complete
  6. The result is returned:

    • The local DNS server returns the result to the client
    • The client obtains the IP address of the target server
    • A connection can now be established

Exercise 2

Why does FTP distinguish between the control connection and the data connection?

ftpcontrol connectiondata connection

Approach

Explain the separation in terms of function first, then give the practical consequences: fewer connection setups, the ability to run several transfers at once, independent control over security, and recovery from a failure of either connection.

Steps

  1. Explain the separation of function.
  2. Explain the effect on efficiency.
  3. Explain the flexibility it allows.
  4. Explain the effect on security.
  5. Explain the effect on reliability.
  6. Explain the design rationale.

Answer

FTP distinguishes the control connection from the data connection for these reasons:

  1. Separation of function:

    • The control connection carries the commands and the responses
    • The data connection carries the file data
    • The responsibilities are clear and do not interfere with each other
  2. Higher efficiency:

    • The control connection stays open as a long-lived connection
    • The data connection is established on demand
    • The cost of establishing connections is reduced
  3. Flexibility:

    • Several file transfers can run at the same time
    • Different transfer modes are supported
    • It adapts to different network environments
  4. Security:

    • The control connection can be encrypted
    • The data connection can be controlled independently
    • Better security control is possible
  5. Reliability:

    • A failure of the control connection does not stop the data transfer
    • A failed data connection can be re-established
    • The overall reliability is improved
  6. Protocol design:

    • It follows the principle of layering
    • It makes the protocol easier to extend
    • It improves the maintainability of the protocol

Glossary

TermAbbreviationExplanation
Domain Name SystemDNSThe name resolution system
Domain name-The hierarchical name of a host
Top-level domainTLDThe highest level of a domain name
Root name server-The topmost level of the DNS hierarchy
Authoritative name server-The server that stores the records for a domain
Recursive query-One of the ways of querying DNS
Iterative query-One of the ways of querying DNS
Time to liveTTLHow long a DNS cache entry stays valid
File Transfer ProtocolFTPThe file transfer protocol
Control connection-The FTP command channel (port 21)
Data connection-The FTP data channel (port 20)
Active modePORTThe FTP active transfer mode
Passive modePASVThe FTP passive transfer mode
Anonymous FTP-FTP access that needs no authentication
Trivial File Transfer ProtocolTFTPThe simple file transfer protocol

Found an issue with this content?

Tell us what could be improved.