The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for...

36
The Domain Name System

Transcript of The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for...

Page 1: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

The Domain Name System

Page 2: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

2

Hostnames

• IP Addresses are great for computers– IP address includes information used for

routing.

• IP addresses are tough for humans to remember.

• IP addresses are impossible to guess.– ever guessed at the name of a WWW site?

Page 3: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

3

The Domain Name System

• The domain name system is usually used to translate a host name into an IP address .

• Domain names comprise a hierarchy so that names are unique, yet easy to remember.

Page 4: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

4

DNS Hierarchy

edu com org jp

rpi albany

Page 5: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

5

Host name structure• Each host name is made up of a sequence

of labels separated by periods.– Each label can be up to 63 characters– The total name can be at most 255 characters.

• Examples:– whitehouse.gov– barney.the.purple.dinosaur.com– monica.cs.rpi.edu

Page 6: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

6

Domain Name

• The domain name for a host is the sequence of labels that lead from the host (leaf node in the naming tree) to the top of the worldwide naming tree.

• A domain is a subtree of the worldwide naming tree.

Page 7: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

7

Top level domains

• edu, gov, com, net, org, mil, …

• Countries each have a top level domain (2 letter domain name).

• New top level domains include:.aero .biz .coop .info .name .pro

Page 8: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

8

DNS Organization• Distributed Database

– The organization that owns a domain name is responsible for running a DNS server that can provide the mapping between hostnames within the domain to IP addresses.

– So - some machine run by RPI is responsible for everything within the rpi.edu domain.

Page 9: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

9

rpi.eduDNS DB

rpi.eduDNS DB

DNS Distributed Database

• There is one primary server for a domain, and typically a number of secondary servers containing replicated databases.

rpi.eduDNS DB

Authoritative

rpi.eduDNS DB

Replicas

rpi.edu DNS server

Page 10: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

10

DNS Clients• A DNS client is called a resolver.

• A call to gethostbyname()is handled by a resolver (typically part of the client).

• Most Unix workstations have the file /etc/resolv.conf that contains the local domain and the addresses of DNS servers for that domain.

Page 11: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

11

/etc/resolv.conf

domain rpi.edu

128.113.1.5

128.113.1.3

Page 12: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

12

nslookup

• nslookup is an interactive resolver that allows the user to communicate directly with a DNS server.

• nslookup is usually available on Unix workstations.

Page 13: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

13

DNS Servers

• Servers handle requests for their domain directly.

• Servers handle requests for other domains by contacting remote DNS server(s).

• Servers cache external mappings.

Page 14: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

14

Server - Server Communication• If a server is asked to provide the

mapping for a host outside it’s domain (and the mapping is not in the server cache):– The server finds a nameserver for the

target domain.– The server asks the nameserver to provide

the host name to IP translation.

• To find the right nameserver, use DNS!

Page 15: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

15

DNS Data

• DNS databases contain more than just hostname-to-address records:– Name server records NS– Hostname aliases CNAME– Mail Exchangers MX– Host Information HINFO

Page 16: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

16

The Root DNS Server

• The root server needs to know the address of 1st (and many 2nd) level domain nameservers.

edu com org jp

albanyrpi

Page 17: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

17

Server Operation

• If a server has no clue about where to find the address for a hostname, ask the root server.

• The root server will tell you what nameserver to contact.

• A request may get forwarded a few times.

Page 18: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

18

DNS Message Format

HEADER

QUERIES

Response RESOURCE RECORDS

Response AUTHORITY RECORDS

Response ADDITIONAL INFORMATION

HEADER

QUERIES

Response RESOURCE RECORDS

Response AUTHORITY RECORDS

Response ADDITIONAL INFORMATION

Page 19: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

19

Question Format

• Name: domain name (or IP address)

• Query type (A, NS, MX, …)

Page 20: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

20

Response Resource Record

• Domain Name

• Response type

• Class (IP)

• Time to live (in seconds)

• Length of resource data

• Resource data

Page 21: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

21

UDP & TCP

• Both UDP and TCP are used:– TCP for transfers of entire database to

secondary servers (replication).– UDP for lookups– If more than 512 bytes in response -

requestor resubmits request using TCP.

Page 22: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

22

Name to Address Conversion

• There is a library of functions that act as DNS client (resolver).

Page 23: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

23

DNS Data Flow

Page 24: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

24

Example suranga.com

This is named.conf in /etc/ folderAccording to the following configuration I have created a zone called suranga.com and in that zone im3 is a host. Therefore the full name of that host would be im3.suranga.com. like that

you can have any amount of PCs in your domain. This will definitely works if you type

following according to your network.

Page 25: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

25

Example Network

Page 26: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

26

This is named.conf in /etc/ folder

• options {• directory "/var/named";• // query-source address * port 53;• };• zone "." IN {• type hint;• file "named.ca";• };• zone "localhost" IN {• type master;• file "localhost.zone";• allow-update { none; };• };• zone "0.0.127.in-addr.arpa" IN {• type master;• file "named.local";• allow-update { none; };• };• zone "suranga.com" IN {• type master;• file "suranga.com.zone";• allow-update { none; };• };• zone "200.168.192.in-addr.arpa" IN {• type master;• allow-update { none; };• };

Page 27: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

27

BIND Files

• Following files should be created in /var/named/ folder we do not need to customize the default file named.ca in the /var/named/ folder.

• 1. 0.0.127.in-addr.arpa.zone• 2. 200.168.192.in-addr.arpa.zone• 3. suranga.com.zone• 4. localhost.zone• 5. named.local

Page 28: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

28

The contents of 0.0.127.in-addr.arpa.zone as follows

• $TTL 86400• @ IN SOA localhost. root.localhost (• 1 ; serial• 28800 ; refresh• 7200 ; retry• 604800 ; expire• 86400 ; ttk• )• @ IN NS localhost.• 1 IN PTR localhost.

Page 29: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

29

200.168.192.in-addr.arpa.zone file

• $TTL 86400• @ IN SOA 192.168.200.8. root.localhost (• 1 ; serial• 28800 ; refresh• 7200 ; retry• 604800 ; expire• 86400 ; ttk• )• @ IN NS localhost.• 1 IN PTR localhost.• 2 IN PTR im3.

Page 30: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

30

suranga.com.zone file

• $TTL 86400• @ IN SOA @ root.suranga.com (• 1 ; serial• 28800 ; refresh• 7200 ; retry• 604800 ; expire• 86400 ; ttl• )• IN NS suranga.com.• @ IN A 192.168.200.8• im3 IN A 192.168.200.250

Page 31: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

31

localhost.zone file

• $TTL 86400• @ IN SOA @ root.localhost (• 1 ; serial• 28800 ; refresh• 7200 ; retry• 604800 ; expire• 86400 ; ttl• )• IN NS localhost.• @ IN A 127.0.0.1

Page 32: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

32

named.localhost file

• $TTL 86400• @ IN SOA localhost. root.localhost. (• 1997022700 ; Serial• 28800 ; Refresh• 14400 ; Retry• 3600000 ; Expire• 86400 ) ; Minimum• IN NS localhost.• 1 IN PTR localhost.

Page 33: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

33

Results

• Now go to the prompt and type service named start and type nslookup commands to verify your domain as follows.

• #nslookup >suranga.com

• Server: 192.168.200.8Address: 192.168.200.8#53

Name: suranga.comAddress: 192.168.200.8

• >im3.suranga.com• Server: 192.168.200.8

Address: 192.168.200.8#53

Name: im3.suranga.comAddress: 192.168.200.250

Page 34: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

34

Configuration Files

• named configuration file (/etc/named.conf): • It basically defines the parameters that point to the sources of

domain database information, which can be local files or on remote servers.

• Hint file (cache file)(/var/named/named.ca): • It actually provides the name of root server which gets activated

in case the machine name, which is to be searched, is not there in user defined zone.

• localhost file (/var/named.local): • All configuration have a local domain Database for resolving

address to the host name localhost. • Zone: • Basically a zone that keeps the information about the domain

database.

Page 35: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

35

More on zone files

• @: It means from the origin to the lastname object that is suranga.com.

• IN: This stands for Internet servers • SOA: This stands for `Start Of Authority’. It marks the beginning

of a zone’s data and defines the parameter that affects the entire zone. Followed by the current machine name where the DNS server is maintained.

• 20000011301;serial: This is the serial number--a numeric value that tells or notifies the slave server, that the database has been updated. So slave server should also update it.

• 3600;refresh: This is the refresh cycle in seconds. In every refresh cycle the slave server comes to master server and checks for the updated database.

Page 36: The Domain Name System. CeylonLinux DNS concepts using BIND 2 Hostnames IP Addresses are great for computers –IP address includes information used for.

CeylonLinux DNS concepts using BIND

36

More on zone files

• 1800;retry: This particular line refers to the retry cycle which in turn means that the slave server should wait before asking the master server again in case master server doesn’t respond.

• 1209600;expire: This is the time for slave server to respond to queries of client for the expiration time if master server fails and has to be up and not getting up. After this period slave server also fails to solve the queries of clients and sits idle.

• 432100;default_ttl: This refers to the default time to leave, for this domain to work for, when named is once started. Remember the user doesn’t have to play with this unless he wants that the query time from the slave server should be somewhat less or more. In case we want to change, we should change only the refresh time in both master and slave. The best way is to make it 2, which means after each 2 seconds slave server will query to master server.