;; -*- coding: utf-8 -*-
;; 20070118 Edited for intergruas.com
;; 20070116 Extracted from informatimago.lisp

(FORMAT *TRACE-OUTPUT* "~&Loading intergruas.lisp~%")
(EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE)
  (DEFVAR PRIVATE NIL)
  (DEFPARAMETER *WILL-CHANGE* NIL)

  (SETF *ZONE-DIR*
        (MERGE-PATHNAMES
         (MAKE-PATHNAME :DIRECTORY '(:ABSOLUTE "var" "lib" "named")) (EXT:CD)))
  #+TEST
  (SETF *ZONE-DIR*
        (MERGE-PATHNAMES
         (MAKE-PATHNAME :DIRECTORY '(:ABSOLUTE "home""pjb""src""domains"))
         (EXT:CD)))

  (SETF *CONF-DIR* *ZONE-DIR*)

  (DEFPARAMETER *SERIAL-DATA-FILE*
    (MERGE-PATHNAMES (MAKE-PATHNAME :NAME "serial" :TYPE "data") *ZONE-DIR*))
  (DEFPARAMETER SERIAL (NEXT-SERIAL *SERIAL-DATA-FILE*))


  (IF *WILL-CHANGE*
      (PROGN (DEFPARAMETER REFRESH     "1200")
             (DEFPARAMETER RETRY        "300")
             (DEFPARAMETER EXPIRE      "1800")
             (DEFPARAMETER DEFAULT-TTL   "60"))
      (PROGN (DEFPARAMETER REFRESH        "2D")
             (DEFPARAMETER RETRY          "1H")
             (DEFPARAMETER EXPIRE         "6W")
             (DEFPARAMETER DEFAULT-TTL  "300")))


  ;; 192.168.167.2 is the address where the public address
  ;; 62.93.173.252 is redirected to.  The DNS server on that
  ;; redirected address publishes the public address.
  ;;
  ;; 192.168.167.3 is the private DNS server address. The DNS server
  ;; on that address publishes the private address 192.168.167.2 (so
  ;; the other servers can listen to only one address).


  (DEFPARAMETER private-ADDR  '192.168.167.3)
  (DEFPARAMETER PUBLIC-ADDR   '62.93.173.252)
  (DEFPARAMETER PUBLIC-NAME   'correo.intergruas.com)
  (DEFPARAMETER HOSTMASTER    'HOSTMASTER.intergruas.com)

  );; eval-when


(DEFMACRO DEFINE-SOA (DOMAIN)
  `(DEFINE-ZONE ,DOMAIN ('dns.intergruas.com
                         HOSTMASTER SERIAL
                         REFRESH RETRY EXPIRE DEFAULT-TTL)
     ;; Name servers:
     'dns.intergruas.com
     ,@(unless private '('LARISSA.INFORMATIMAGO.COM))))


(RESET)

(ADD-NAME  'LARISSA.INFORMATIMAGO.COM '62.93.174.78) ; used only to generate

;;;------------------------------------------------------------------------
;;; intergruas.com
;;;------------------------------------------------------------------------

;; Don't use REGISTER-REVERSE;
;; it's for the arpa -> CNAME -> byte.domain -> PTR name trick.
;; (REGISTER-REVERSE '(167 168 192)  'LAN.intergruas.COM)


(DEFINE-SOA 'INTERGRUAS.COM)
(define-soa '167.168.192.IN-ADDR.ARPA)


(ADD-RECORD 'INTERGRUAS.COM `(MX 1   ,public-name)               :INFERIORS)
(ADD-RECORD 'INTERGRUAS.COM '(MX 100 LARISSA.INFORMATIMAGO.COM)  :INFERIORS)
(ADD-RECORD 'INTERGRUAS.COM '(LOC   37 37 30 N   0 46 30 W  30M) :INFERIORS)

(ADD-RECORD                'INTERGRUAS.COM `(CNAME ,public-name))
(ADD-RECORD            'ftp.INTERGRUAS.COM `(CNAME ,public-name))
(ADD-RECORD            'pop.INTERGRUAS.COM `(CNAME ,public-name))
(ADD-RECORD            'www.INTERGRUAS.COM `(CNAME ,public-name))
(ADD-RECORD           'imap.INTERGRUAS.COM `(CNAME ,public-name))
(ADD-RECORD           'mail.INTERGRUAS.COM `(CNAME ,public-name))
(ADD-RECORD           'smtp.INTERGRUAS.COM `(CNAME ,public-name))
(ADD-RECORD      'LOCALHOST.INTERGRUAS.COM '(A 127.0.0.1))
(ADD-RECORD  'LOCALHOST.LAN.INTERGRUAS.COM '(A 127.0.0.1))


(ADD-name      'ROUTER.INTERGRUAS.COM  (if private '192.168.167.1 public-addr))
(add-name      'CORREO.INTERGRUAS.COM  (if private '192.168.167.2 public-addr))
(add-name         'dns.intergruas.com  (if private  private-addr  public-addr))


(ADD-RECORD      'router.lan.INTERGRUAS.COM '(CNAME router.intergruas.com))
(ADD-RECORD      'correo.lan.INTERGRUAS.COM '(CNAME correo.intergruas.com))
(ADD-RECORD         'dns.lan.INTERGRUAS.COM '(CNAME    dns.intergruas.com))

(ADD-NAME       'printer.LAN.INTERGRUAS.COM '192.168.167.38)

(add-name       'boletus.lan.intergruas.com '192.168.167.65)
(add-name      'charming.lan.intergruas.com '192.168.167.66)
(add-name     'mare-azul.lan.intergruas.com '192.168.167.67)
(add-name 'blanche-neige.lan.intergruas.com '192.168.167.68)
(add-name       'plantus.lan.intergruas.com '192.168.167.69)

(ADD-NAME        'triton.LAN.INTERGRUAS.COM '192.168.167.75)
(ADD-NAME        'kuiper.LAN.INTERGRUAS.COM '192.168.167.76)

;; charming      PowerBook 12"
;; boletus       iMac  LCD 17"
;; mare-azul     iBook blue
;; blanche-neige iBook 15"
;; plantus       G5 17"


(loop
   :for i :from 129 :to 254
   :do  (add-name (name-append (format nil "ORDENADOR-~2,'0X" i)
                               'lan.intergruas.com)
                  (name-append '192.168.167 i)))



;; ----------------------------------------------------------------------
;; Generation
;; ----------------------------------------------------------------------

(DEFUN GENERATE ()
  (FORMAT *TRACE-OUTPUT* "~&Generating ~:[public~;private~] zones.~%" PRIVATE)
  (IF PRIVATE
      (GENERATE-FILES "intra"  "intergruas" (LIST private-addr))
      (GENERATE-FILES "public" "intergruas" (LIST PUBLIC-ADDR)))
  (FORMAT *TRACE-OUTPUT* "Complete.~%"))
ViewGit