Advertisement
shokti

ubuntu dns server(bind9) installation

Sep 25th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. install bind9:
  2. sudo apt-get install bind9
  3.  
  4. add dns forwarders to /etc/bind/named.conf.options:
  5. sudo nano /etc/bind/named.conf.options
  6.  
  7. add internet provider dns server ip or other dns server like google in the forwarders section:
  8. forwarders
  9. {
  10. 8.8.8.8;
  11. 8.8.4.4;
  12. };
  13.  
  14. define forward lookup zone and reverse lookup zone to /etc/bind/named.conf.local:
  15. sudo nano /etc/bind/named.conf.local
  16.  
  17. for forward lookup zone whose network ip is 192.168.254.0:
  18. zone "myowndomain.com"
  19. {
  20. type master;
  21. file "/etc/bind/zones/myowndomain.com.db";
  22. };
  23.  
  24. for reverse lookup zone for the 192.168.254.0 network:
  25. zone "254.168.192.in-addr.arpa"
  26. {
  27. type master;
  28. file "rev.254.168.192.in-addr.arpa";
  29. };
  30.  
  31. create the zones folder:
  32. sudo mkdir /etc/bind/zones
  33.  
  34. create the forward lookup zone file myowndomain.com.db:
  35. sudo nano /etc/bind/zones/myowndomain.com.db
  36.  
  37. add the following entry to the file:
  38. the number value below is for serial#, refresh, retry, expire, minimum:
  39.  
  40. $TTL 3D
  41. @ IN SOA server1.myowndomain.com. admin.myowndomain.com. (
  42. 2007031001;
  43. 28800;
  44. 3600;
  45. 604800;
  46. 38400
  47. );
  48.  
  49. myowndomain.com. IN NS server1.myowndomain.com.
  50. server1 IN A 192.168.254.254
  51. server2 IN A 192.168.254.250
  52. gateway IN A 192.168.254.1
  53. www IN CNAME server1
  54.  
  55.  
  56. create the reverse lookup zone file rev.254.168.192.in-addr.arpa:
  57. sudo nano /etc/bind/zones/rev.254.168.192.in-addr.arpa
  58.  
  59. add the following entry to the file:
  60. the number value below is for serial#, refresh, retry, expire, minimum:
  61.  
  62. $TTL 3D
  63. @ IN SOA server1.myowndomain.com. admin.myowndomain.com. (
  64. 2007031001;
  65. 28800;
  66. 3600;
  67. 604800;
  68. 38400
  69. );
  70.  
  71. IN NS server1.myowndomain.com.
  72. 254 IN PTR server1.myowndomain.com.
  73. 250 IN PTR server2.myowndomain.com.
  74. 1 IN PTR gateway.myowndomain.com.
  75.  
  76.  
  77. edit resolv.conf:
  78. sudo nano /etc/resolv.conf
  79.  
  80. add dns suffix search:
  81. search myowndomain.com
  82. point dns resolution to the local dns server:
  83. nameserver 192.168.254.254
  84.  
  85. restart bind9:
  86. sudo /etc/init.d/bind9 restart
  87.  
  88. test dns resolution with nslookup:
  89. nslookup server1
  90. nslookup server2
  91. nslookup gateway
  92.  
  93. to check if the config files have no errors:
  94. named-checkconf /etc/bind/named.conf.options
  95. named-checkconf /etc/bind/named.conf.local
  96.  
  97. to check if the zone files have no errors:
  98. named-checkzone myowndomain.com /etc/bind/zones/myowndomain.com.db
  99. named-checkzone 254.168.192.in-addr.arpa /etc/bind/zones/rev.254.168.192.in-addr.arpa
  100. ---------------------------------------------------------------------------------------
  101. use dig command to check dns:
  102.  
  103. check via FQDN (check status, question section, answer section, authority section):
  104. dig server1.myowndomain.com | less
  105.  
  106. check via IP address (check status, question section, answer section, authority section, additional section):
  107. dig -x 192.168.254.254 | less
  108.  
  109. check SOA records of myowndomain.com (check status, question section, answer section, authority section, additional section):
  110. dig -t SOA mydomain.com | less
  111.  
  112. check zone transfers and all records:
  113. dig -t axfr myowndomain.com | less
  114. -----------------------------------------------------------------------------------------
  115. use host command to check dns:
  116.  
  117. check via FQDN:
  118. host server1.myowndomain.com
  119.  
  120. check via domain name:
  121. host myowndomain.com
  122.  
  123. check via IP address:
  124. host 192.168.254.254
  125. =========================================================================================
  126. FORWARD ZONE:
  127.  
  128. $ORIGIN .
  129. $TTL 86400 ; 1day
  130. myowndomain.com. IN SOA server1.myowndomain.com. hostmaster.myowndomain.com. (
  131. 2014012001 ; serial - YYYYMMDDII format
  132. 8H ; refresh
  133. 4H ; retry
  134. 3W ; expires
  135. 1D ; minimum
  136. )
  137.  
  138. myowndomain.com. IN NS server1.myowndoamin.com.
  139. myowndomain.com. IN MX 10 server1.myowndomain.com.
  140.  
  141. $ORIGIN myowndomain.com.
  142. server1 IN A 192.168.254.254
  143. server2 IN A 192.168.254.250
  144. gateway IN A 192.168.254.1
  145. www IN CNAME server1
  146.  
  147. ----------------------------------------------------------------------------------------
  148.  
  149. REVERSE ZONE:
  150.  
  151. @ IN SOA server1.myowndomain.com. hostmaster.myowndomain.com. (
  152. 2014012001 ; serial - YYYYMMDDII format
  153. 8H ; refresh
  154. 4H ; retry
  155. 3W ; expires
  156. 1D ; minimum
  157. )
  158.  
  159. IN NS server1.myowndomain.com.
  160. 254 IN PTR server1.myowndomain.com.
  161. 250 IN PTR server2.myowndomain.com.
  162. 1 IN PTR gateway.myowndomain.com.
  163.  
  164. =======================================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement