中華技術學院 Linux 課程 中華技術學院 Linux 課程 Chap two : DNS 王俊城RHCE/RHCX
Agenda DNS overview Configuring BIND Creating BIND databases Additional DNS methods Using BIND tools
Domain Name System (DNS) forward lookup -> reverse lookup > Logically group by name domains Provides routing information
Name Server Hierarchy Master name server maintain zone file itself Slave name server Provides a backup to the master name server Synchronization with master or another slave name server Cache-only No any one zone file
DNS Server Server receives request If zone file have answer If cache have answer If forward assign Asks root name server /var/named/named.ca /var/named/named.ca
BIND Berkeley Internet Name Domain (BIND) BIND 9 /usr/share/doc/bind*/README IND
Service Profile : DNS Type:System V-manager service Packages:bind,bind-utils caching-nameserveropenssl Daemons:named Script:named Ports:UDP(53),TCP(53) Configs:/etc/named.conf /var/named/named.ca/var/named/* Log:/var/log/messages
Configuring BIND /etc/named.conf service named restart Text-file specifying directives:zones,options,access control lists,etc Comments can be in C,C++ or shell style /* C style comment */ // C++ style comment # shell style comment
Global Options acl "mynet" { /24; /24; }; /24; }; options { directory "/var/named"; forwards { ; }; forward only; forward only; allow-query { mynet; }; allow-transfer { mynet; }; };
BIND utlities host: gather host/domain information host example.com host – al example.com host – t mx example.com dig: send queries to name server directly nslookup is deprecated
LAB1-Cache-only DNS Server /var/named/chroot/etc/named.conf /etc/hosts /etc/resolv.conf service named restart host station251.example.com options { directory "/var/named/chroot/var/named"; forwarders { ; }; forward only; };
Slave Zones zone "example.com" { type slave; masters { ; }; file "example.com.zone-slave"; }; zone " in-addr.arpa" { type slave; masters { ; }; file " zone"; };
LAB2-Slave DNS Server /var/named/chroot/etc/named.conf /etc/hosts /etc/resolv.conf service named restart host station251.example.com zone "example.com" { type slave; masters { ; }; file "example.com.zone-slave"; }; zone " in-addr.arpa" { type slave; masters { ; }; file " zone"; };
Master Zones zone "domain251.example.com" { type master; type master; file "domain251.example.com.zone"; file "domain251.example.com.zone";}; zone " IN-ADDR.ARPA" { type master; type master; file " zone"; file " zone";};
Special Zones Root zone: “. ” zone "." { type hint; file "named.ca"; }; zone " in-addr.arpa" { type master; file " zone"; };
Zone Files /var/named/* ( or /var/named/chroot/var/named/*) Begin with $TTL (time to live) First resource record is zone`s start of authority(SOA) Zone data in additional resource records Comments can be “ ; ”
Example Zone Files SOA record NS records A records CNAME records MX records
Example Zone Files $TTL IN SOA station251.domain251.example.com. root.station251.domain251.example.com. ( ; Dont forget to increment the serial number ;serial number ;serial number 1H;refresh slave 1H;refresh slave 5M;retry refresh 5M;retry refresh 1W;expire zone 1W;expire zone 5M ;cache time-to-live for negative answers 5M ;cache time-to-live for negative answers) ; Name server resource records ( NS ) ; ownerTTL CL IN NSstation251.domain251.example.com. ; Mail exchanger resource records ( MX ) ; ownerTTL CL type RDATA domain251.example.com.IN MX 10 station251.domain251.example.com. ; Internet address resource records( A ) ; ownerTTLCL A station251.domain251.example.com.IN A
LAB2-Master DNS Server /var/named/chroot/etc/named.conf /etc/hosts /etc/resolv.conf service named restart host station251.example.com zone “ domain251.example.com" { type master; file "domain251.example.com.zone"; };
Delegating Subdomains Configure the subdomain as a zone on the new server On delegating server,set up NS record for the subdomain pointing to the new server If new server is in subdomain it manages,on delegating server need a “ glue ” A record for new server