Advertisement
rmh

Step by step Yadifa DNS Configuration

rmh
Feb 26th, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.83 KB | None | 0 0
  1. 01. Bikin file yatifad.conf. Feel free to use the following one slightly edited to serve as master:
  2. nano /usr/local/etc/(nama file yadifanya)
  3. nano /usr/local/etc/yatifad.conf
  4.  
  5. #
  6. # Example yadifa configuration file.
  7. #
  8.  
  9. <main>
  10. # Detach from the console
  11. daemon on
  12.  
  13. # Jail the application
  14. chroot off
  15.  
  16. # The path where all the log files will be written
  17. logpath "/usr/local/var/log"
  18.  
  19. # The path where the pid file will be written
  20. pidpath "/usr/local/var/run"
  21.  
  22. # The path where all zone files will be written
  23. datapath "/usr/local/var/zones"
  24.  
  25. # The path where the DNSSEC keys are found
  26. keyspath "/usr/local/var/zones/keys"
  27.  
  28. # The path where the transfer and journaling files will be written (AXFR &amp; IXFR)
  29. xfrpath "/usr/local/var/zones/xfr"
  30.  
  31. # The version returned by a query to version.yadifa. CH TXT
  32. version "1.0.0rc2"
  33.  
  34. # Enable EDNS0 support (?)
  35. edns0 on
  36.  
  37. # Set the maximum UDP packet size. Cannot be less than 512. Cannot be more than 65535. Typical choice is 4096.
  38. edns0-max-size 4096
  39.  
  40. # The maximum number of parallel TCP queries.
  41. max-tcp-queries 100
  42.  
  43. # The user id to use (an integer can be used)
  44. uid root
  45.  
  46. # The group id to use (an integer can be used)
  47. gid wheel
  48.  
  49. # The DNS port. Any DNS query will be made using that port unless a specific value is used.
  50. port 53
  51.  
  52. # The interfaces to listen to.
  53. listen 0.0.0.0
  54.  
  55. # Enable the collection and logging of statistics
  56. statistics on
  57.  
  58. # Choose the query log format (0 for none, 1 for YADIFA, 2 for BIND compatible, 3 for YADIFA and BIND)
  59. queries-log-type 1
  60. # Drop queries with erroneous content
  61. # answer-formerr-packets on
  62.  
  63. # Maximum number of records in an AXFR packet. Set to one for compatibility
  64. # with very old name servers
  65. # axfr-maxrecordbypacket 0
  66.  
  67. # Global Access Controlrules.
  68. #
  69. # Rules can be defined on network ranges, TSIG signatures, and ACL rules
  70.  
  71. # simple queries:
  72. allow-query any
  73.  
  74. # dynamic update of a zone
  75. allow-update none
  76.  
  77. # transfer of a zone (AXFR or IXFR)
  78. allow-transfer 192.168.6.33
  79.  
  80. # notify of a change in the master
  81. allow-notify 192.168.6.33
  82. </main>
  83.  
  84. #
  85. # Logging output channels configurations
  86. #
  87. # name stream-name arguments
  88. #
  89. # name is arbitrary
  90. # stream-name defines the output type (ie: a file name or syslog)
  91. # arguments is specific to the output type (ie: unix file access rights or syslog options and facilities
  92.  
  93. <channels>
  94. # name stream-name arguments
  95. database database.log 0644
  96. dnssec dnssec.log 0644
  97. server server.log 0644
  98. statistics statistics.log 0644
  99. system system.log 0644
  100. zone zone.log 0644
  101. queries queries.log 0644
  102. all all.log 0644
  103.  
  104. syslog syslog USER,CRON,PID
  105.  
  106. # although possible, these two do not do make much sense if daemon is enabled
  107.  
  108. stderr STDERR
  109. stdout STDOUT
  110. </channels>
  111.  
  112. # Logging input configurations
  113. #
  114. # name debug-level channels
  115. #
  116. # name is predefined
  117. # debuglevel uses the same names as syslog or * or all to filter the input
  118. # channels is a comma-separated list of channels
  119.  
  120. <loggers>
  121. # bundle debuglevel channels
  122. database * database,all
  123. dnssec * dnssec,all
  124. server * server,all
  125. statistics * statistics
  126. system * system,all
  127. zone * zone,all
  128. queries * queries
  129. </loggers>
  130.  
  131. #
  132. # TSIG Key configuration
  133. #
  134.  
  135. <key>
  136. name abroad-admin-key
  137. algorithm hmac-md5
  138. secret WorthlessKeyForExample==
  139. </key>
  140.  
  141. <key>
  142. name master-slave
  143. algorithm hmac-md5
  144. secret MasterAndSlavesTSIGKey==
  145. </key>
  146.  
  147. #
  148. # Access Control List definitions
  149. #
  150.  
  151. <acl>
  152. transferer key master-slave
  153. admins 192.168.6.0/24, 2001:db8::74
  154. master 192.168.6.32
  155. slave 192.168.6.33
  156. </acl>
  157.  
  158. #
  159. # Master domain zone config
  160. #
  161.  
  162. <zone>
  163. type master
  164. domain localhost
  165. file masters/localhost.zone
  166. allow-transfer slave
  167. allow-update none
  168. allow-update-forwarding none
  169. </zone>
  170.  
  171. <zone>
  172. type master
  173. domain localhost6
  174. file masters/localhost6.zone
  175. allow-transfer slave
  176. allow-update none
  177. allow-update-forwarding none
  178. </zone>
  179.  
  180. <zone>
  181. type master
  182. domain 0.0.127.in-addr.arpa
  183. file masters/0.0.127.in-addr.arpa.zone
  184. allow-transfer slave
  185. allow-update none
  186. allow-update-forwarding none
  187. </zone>
  188.  
  189. <zone>
  190. type master
  191. domain 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
  192. file masters/0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.zone
  193. allow-transfer slave
  194. allow-update none
  195. allow-update-forwarding none
  196. </zone>
  197.  
  198. <zone>
  199. # This server is master for that zone (mandatory)
  200. type master
  201.  
  202. # The domain name (mandatory)
  203. domain myzone.demo
  204.  
  205. # The zone file, relative to 'datapath'. (mandatory for a master)
  206. file masters/myzone.demo.zone
  207. allow-transfer slave
  208. </zone>
  209.  
  210. Other version: https://github.com/lye/yadifa/blob/master/etc/yadifad.conf.example
  211.  
  212.  
  213. 02. Jalankan/start Yadifa :
  214. start /usr/local/sbin/(nama yadifanya) ⇒ yadifad
  215. start /usr/local/sbin/yadifad
  216. service yadifad start
  217.  
  218. 03. Verifikasi Daemon :
  219. netstat -anfinet|grep '.53'
  220.  
  221. 04. Query YADIFA for myzone.demo :
  222. dig +norec @localhost -t ANY myzone.demo
  223.  
  224. 05. Edit konfigurasi Server sebagai Slave
  225. nano /usr/local/etc/(nama file yadifanya)
  226. nano /usr/local/etc/yadifad
  227.  
  228. #
  229. # Example yadifa configuration file.
  230. #
  231.  
  232. <main>
  233. # Detach from the console
  234. daemon on
  235.  
  236. # Jail the application
  237. chroot off
  238.  
  239. # The path where all the log files will be written
  240. logpath "/usr/local/var/log"
  241.  
  242. # The path where the pid file will be written
  243. pidpath "/usr/local/var/run"
  244.  
  245. # The path where all zone files will be written
  246. datapath "/usr/local/var/zones"
  247.  
  248. # The path where the DNSSEC keys are found
  249. keyspath "/usr/local/var/zones/keys"
  250.  
  251. # The path where the transfer and journaling files will be written (AXFR &amp; IXFR)
  252. xfrpath "/usr/local/var/zones/xfr"
  253.  
  254. # The version returned by a query to version.yadifa. CH TXT
  255. version "1.0.0rc2"
  256.  
  257. # Enable EDNS0 support (?)
  258. edns0 on
  259.  
  260. # Set the maximum UDP packet size. Cannot be less than 512. Cannot be more than 65535. Typical choice is 4096.
  261. edns0-max-size 4096
  262.  
  263. # The maximum number of parallel TCP queries.
  264. max-tcp-queries 100
  265.  
  266. # The user id to use (an integer can be used)
  267. uid root
  268.  
  269. # The group id to use (an integer can be used)
  270. gid wheel
  271.  
  272. # The DNS port. Any DNS query will be made using that port unless a specific value is used.
  273. port 53
  274.  
  275. # The interfaces to listen to.
  276. listen 0.0.0.0
  277.  
  278. # Enable the collection and logging of statistics
  279. statistics on
  280.  
  281. # Choose the query log format (0 for none, 1 for YADIFA, 2 for BIND compatible, 3 for YADIFA and BIND)
  282. queries-log-type 1
  283. # Drop queries with erroneous content
  284. # answer-formerr-packets on
  285.  
  286. # Maximum number of records in an AXFR packet. Set to one for compatibility
  287. # with very old name servers
  288. # axfr-maxrecordbypacket 0
  289.  
  290. # Global Access Controlrules.
  291. #
  292. # Rules can be defined on network ranges, TSIG signatures, and ACL rules
  293.  
  294. # simple queries:
  295. allow-query any
  296.  
  297. # dynamic update of a zone
  298. allow-update none
  299.  
  300. # transfer of a zone (AXFR or IXFR)
  301. allow-transfer none
  302.  
  303. # notify of a change in the master
  304. allow-notify none
  305. </main>
  306.  
  307. #
  308. # Logging output channels configurations
  309. #
  310. # name stream-name arguments
  311. #
  312. # name is arbitrary
  313. # stream-name defines the output type (ie: a file name or syslog)
  314. # arguments is specific to the output type (ie: unix file access rights or syslog options and facilities
  315.  
  316. <channels>
  317. # name stream-name arguments
  318. database database.log 0644
  319. dnssec dnssec.log 0644
  320. server server.log 0644
  321. statistics statistics.log 0644
  322. system system.log 0644
  323. zone zone.log 0644
  324. queries queries.log 0644
  325. all all.log 0644
  326.  
  327. syslog syslog USER,CRON,PID
  328.  
  329. # although possible, these two do not do make much sense if daemon is enabled
  330.  
  331. stderr STDERR
  332. stdout STDOUT
  333. </channels>
  334.  
  335. # Logging input configurations
  336. #
  337. # name debug-level channels
  338. #
  339. # name is predefined
  340. # debuglevel uses the same names as syslog or * or all to filter the input
  341. # channels is a comma-separated list of channels
  342.  
  343. <loggers>
  344. # bundle debuglevel channels
  345. database * database,all
  346. dnssec * dnssec,all
  347. server * server,all
  348. statistics * statistics
  349. system * system,all
  350. zone * zone,all
  351. queries * queries
  352. </loggers>
  353.  
  354. #
  355. # TSIG Key configuration
  356. #
  357.  
  358. <key>
  359. name abroad-admin-key
  360. algorithm hmac-md5
  361. secret WorthlessKeyForExample==
  362. </key>
  363.  
  364. <key>
  365. name master-slave
  366. algorithm hmac-md5
  367. secret MasterAndSlavesTSIGKey==
  368. </key>
  369.  
  370. #
  371. # Access Control List definitions
  372. #
  373.  
  374. <acl>
  375. transferer key master-slave
  376. admins 192.168.6.0/24, 2001:db8::74
  377. master 192.168.6.32
  378. slave 192.168.6.33
  379. </acl>
  380.  
  381. #
  382. # Master domain zone config
  383. #
  384.  
  385. <zone>
  386. type slave
  387. domain localhost
  388. file slaves/localhost.zone
  389. master 192.168.6.32
  390. </zone>
  391.  
  392. <zone>
  393. type slave
  394. domain localhost6
  395. file slaves/localhost6.zone
  396. master 192.168.6.32
  397. </zone>
  398.  
  399. <zone>
  400. type slave
  401. domain 0.0.127.in-addr.arpa
  402. file slaves/0.0.127.in-addr.arpa.zone
  403. master 192.168.6.32
  404. </zone>
  405.  
  406. <zone>
  407. type slave
  408. domain 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
  409. file slaves/0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.zone
  410. master 192.168.6.32
  411. </zone>
  412.  
  413. <zone>
  414. # This server is master for that zone (mandatory)
  415. type slave
  416.  
  417. # The domain name (mandatory)
  418. domain myzone.demo
  419.  
  420. # The zone file, relative to 'datapath'. (mandatory for a master)
  421. file slaves/myzone.demo.zone
  422. master 192.168.6.32
  423. </zone>
  424.  
  425. 06. Start Daemonnya :
  426. start /usr/local/sbin/(nama file yadifanya)
  427. start /usr/local/sbin/yadifad
  428.  
  429. 07. Verifikasi Yadifa :
  430. netstat -anfinet|grep '.53'
  431.  
  432. 08. Query slave server untuk myzone.demo
  433. dig +norec @localhost -t ANY myzone.demo
  434.  
  435. 09. Bikin file yadifad-master.conf
  436. nano /etc/yadifad-master.conf
  437.  
  438. <zone>
  439.     domain      myzone.demo
  440.     file        masters/myzone.demo.zone
  441.     type        master
  442. </zone>
  443.  
  444. 10. Bikin file yadifad-slave.conf
  445. nano /etc/yadifad-slave.conf
  446.  
  447. <zone>
  448.     domain      myzone.demo
  449.     file        slaves/myzone.demo.zone
  450.     type        slave
  451.     master      192.168.6.32
  452. </zone>
  453.  
  454. 11. Bikin file etc/yadifad.init
  455. nano etc/yadifad.init
  456.  
  457. #! /bin/sh
  458. #------------------------------------------------------------------------------
  459. ##
  460. ##
  461. #------------------------------------------------------------------------------
  462. ### BEGIN INIT INFO
  463. # Provides:          yadifad
  464. # Required-Start:    $local_fs $network
  465. # Required-Stop:
  466. # Should-Start:      udev module-init-tools
  467. # Should-Stop:       $named
  468. # Default-Start:     2 3 4 5
  469. # Default-Stop:
  470. # Short-Description: Starts the YADIFAD name server
  471. # Description:      Starts the YADIFAD name server
  472. ### END INIT INFO
  473.  
  474.  
  475. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  476. PREFIX="/usr/local-dev"
  477. NAME="yadifad"
  478. NAMED_USERNAME="root"
  479. DAEMON="/sbin/${NAME}"
  480.  
  481. SCRIPTNAME="/etc/init.d/${NAME}"
  482. PIDFILE="$PREFIX/var/run/yadifa.pid"
  483.  
  484. CHROOTS=0
  485. CHROOTDIR=$PREFIX
  486. YADIFA_CHROOT=/var
  487.  
  488. if [ "$DEBUG" = "" ]
  489. then
  490.     DEBUG=0
  491. fi
  492.  
  493. log()
  494. {
  495.     echo $*
  496.     logger -t $NAME-init-script -- $*
  497. }
  498.  
  499. debug()
  500. {
  501.     if [ $DEBUG -ne 0 ]
  502.     then
  503.         echo $*
  504.         logger -t $NAME-init-script -- $*
  505.     fi
  506. }
  507.  
  508. if [ $CHROOTS -ne 0 ]
  509. then
  510.     PREFIX=
  511. fi
  512.  
  513. VAR="$PREFIX/var"
  514. CONF="$PREFIX/etc/yadifad.conf"
  515.  
  516. if [ "$MAX_STOP_WAIT" = "" ]
  517. then
  518.     MAX_STOP_WAIT=5
  519. fi
  520.  
  521. # Inside the internal chroot
  522.  
  523. if [ "$CORE_PREFIX" = "" ]
  524. then
  525.     CORE_PREFIX=/log
  526. fi
  527.  
  528. if [ "$DUMPS_CORE" = "" ]
  529. then
  530.     DUMPS_CORE=1
  531. fi
  532.  
  533. if [ $DUMPS_CORE -ne 0 ]
  534. then
  535.     if [ ! -d $CHROOTDIR/$YADIFA_CHROOT/$CORE_PREFIX ]
  536.     then
  537.         log "Core dump enabled but '$CHROOTDIR/$YADIFA_CHROOT/$CORE_PREFIX' directory does not exists"
  538.         exit 1
  539.     fi
  540. fi
  541.  
  542. # not yet:
  543. #
  544. # CHECK="/sbin/yadifa-checkconf"
  545.  
  546.  
  547. # $? : supposed to be set
  548. # 1  : message
  549. # 2  : optional override code
  550. # 3  : what to do in case of error (command)
  551.  
  552. die_on_error()
  553. {
  554.         ERR="$?"
  555.        
  556.         if [ ! "" = "$2" ]
  557.         then
  558.             ERR="$2"
  559.         fi
  560.        
  561.        
  562.         if [ 0 -ne ${ERR} ]
  563.         then
  564.             if [ ! "" = "$3" ]
  565.             then
  566.                 $3
  567.             fi
  568.  
  569.                 log "error: '$1' ($ERR)"
  570.                 exit $err
  571.         fi
  572. }
  573.  
  574. #
  575. # Function that checks if yadifa is running
  576. #
  577.  
  578. do_status_internal()
  579. {
  580.     debug "checking for valid PIDFILE ${PIDFILE}"
  581.  
  582.     running=0
  583.  
  584.     if [ -f ${PIDFILE} ]
  585.     then
  586.         PID=$(cat ${PIDFILE})
  587.  
  588.         if [ "${PID}" != "" ]
  589.         then
  590.             PROC=$(ps -p ${PID} | tail -1| awk '{print $4}')
  591.  
  592.             if [ "$PROC" = "$NAME" ]
  593.             then
  594.                 running=1
  595.             else
  596.                 log "error : process with pid ${PID} is '$PROC' and not '$NAME' : deleting pid file"
  597.                 rm -f ${PIDFILE}
  598.             fi
  599.         else
  600.             log "error: empty '${PIDFILE}' : deleting pid file"
  601.             rm -f ${PIDFILE}
  602.         fi
  603.     fi
  604.  
  605.     return $running
  606. }
  607.  
  608. do_status()
  609. {
  610.     do_status_internal
  611.  
  612.     running=$?
  613.  
  614.     if [ $running -eq 1 ]
  615.     then
  616.         log "${NAME} seems to be already running."
  617.         exit 0
  618.     else
  619.         log "${NAME} does not seem to be running."
  620.         exit 1
  621.     fi
  622. }
  623.  
  624. #
  625. # Function that starts the daemon/service
  626. #
  627. do_start()
  628. {
  629.     log "Starting $NAME"
  630.  
  631.     debug "starting if no valid PIDFILE ${PIDFILE}"
  632.  
  633.     do_status_internal
  634.  
  635.     running=$?
  636.  
  637.     if [ $running -eq 1 ]
  638.     then
  639.         log "${NAME} seems to be already running."
  640.         exit 1
  641.     fi
  642.  
  643.     debug cd $CHROOTDIR/${PREFIX}
  644.     cd $CHROOTDIR/${PREFIX}
  645.  
  646.     debug prefix = ${PREFIX}
  647.     debug daemon = ${DAEMON}
  648.  
  649.     if [ $DUMPS_CORE -ne 0 ]
  650.     then
  651.         COREPATH="$CHROOTDIR/$YADIFA_CHROOT/$CORE_PREFIX/cores"
  652.  
  653.         log "enabling core dump in $COREPATH"
  654.  
  655.         ulimit -c unlimited
  656.  
  657.  
  658.         mkdir -p $COREPATH
  659.         chmod 0777 $COREPATH
  660.         chmod +t $COREPATH
  661.  
  662.         log "core dump will be stored in '$COREPATH' ($CORE_PREFIX/cores)"
  663.  
  664.         echo "$CORE_PREFIX/cores/core.%e.%p.%h.%t" > /proc/sys/kernel/core_pattern
  665.         echo 0x7 > /proc/self/coredump_filter
  666.         echo -n 1 > /proc/sys/kernel/core_uses_pid
  667.         echo -n 1 > /proc/sys/fs/suid_dumpable
  668.     fi
  669.  
  670.     CMD="${PREFIX}${DAEMON} -c ${CONF}"
  671.  
  672.     if [ $CHROOTS -ne 0 ]
  673.     then
  674.         CMD="chroot $CHROOTDIR $CMD"
  675.     fi
  676.  
  677.     debug $CMD
  678.  
  679.     $CMD
  680.  
  681.     die_on_error "${DAEMON} returned $?"
  682.  
  683.     exit 0
  684. }
  685.  
  686.  
  687. #
  688. # Function that stops the daemon/service
  689. #
  690. do_stop()
  691. {
  692.     log "Stopping $NAME"
  693.  
  694.     debug "stopping if valid PIDFILE ${PIDFILE}"
  695.  
  696.     if [ -f ${PIDFILE} ]
  697.     then
  698.         while [ -f ${PIDFILE} ]
  699.         do
  700.             PID=$(cat ${PIDFILE})
  701.  
  702.             if [ "${PID}" = "" ]
  703.             then
  704.                 log "error: empty '${PIDFILE}' : deleting pid file"
  705.                 rm -f ${PIDFILE}
  706.                 break
  707.             fi
  708.  
  709.             PROC=$(ps -p ${PID} | tail -1| awk '{print $4}')
  710.  
  711.             if [ "$PROC" != "$NAME" ]
  712.             then
  713.                 log "error : process with pid ${PID} is '$PROC' and not '$NAME' : deleting pid file"
  714.                 rm -f ${PIDFILE}
  715.                 break
  716.             fi
  717.  
  718.             kill ${PID} > /dev/null 2>&1
  719.  
  720.             for count in $(seq 0 $MAX_STOP_WAIT)
  721.             do
  722.                 if [ ! -f ${PIDFILE} ]
  723.                 then
  724.                     break
  725.                 fi
  726.  
  727.                 kill -0 ${PID} > /dev/null 2>&1
  728.  
  729.                 if [ $? -ne 0 ]
  730.                 then
  731.                     rm -f ${PIDFILE}
  732.                     break
  733.                 fi
  734.  
  735.                 log "waiting for the process to stop (waited $count seconds)"
  736.  
  737.                 sleep 1
  738.             done
  739.         done
  740.     else
  741.         log "${NAME} does not seem to be running ..."
  742.         debug "reason: ${PIDFILE} not found"
  743.     fi
  744. }
  745.  
  746. debug called with $1
  747.  
  748. case "$1" in
  749.   start)
  750.     do_start
  751.     ;;
  752.   stop)
  753.     do_stop
  754.     ;;
  755.   restart)
  756.     do_stop
  757.     do_start
  758.     ;;
  759.   status)
  760.     do_status
  761.     ;;
  762.   *)
  763.     log "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
  764.     exit 3
  765.     ;;
  766. esac
  767.  
  768. :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement