README.md
changeset 705 c399ca928704
parent 646 585fe8171ac6
child 706 0816716c3f66
equal deleted inserted replaced
704:1d5625a944fe 705:c399ca928704
    74 Hosts can specify DNS aliases:
    74 Hosts can specify DNS aliases:
    75 
    75 
    76     [foo]
    76     [foo]
    77         ip          = 127.0.0.1
    77         ip          = 127.0.0.1
    78         alias       = test1
    78         alias       = test1
       
    79         alias4      = test
    79 
    80 
    80     [bar]
    81     [bar]
    81         ip          = 127.0.0.2
    82         ip          = 127.0.0.2
    82         alias       = test2
    83         alias       = test2
    83 
    84         alias4      = test
    84     $ bin/pvl.hosts-forward --forward-zone alias.test etc/hosts/alias.test 
    85 
       
    86     $ bin/pvl.hosts-forward etc/hosts/alias.test 
    85     foo                               A     127.0.0.1
    87     foo                               A     127.0.0.1
    86     test1                             CNAME foo
    88     test1                             CNAME foo
       
    89     test                              A     127.0.0.1
    87     bar                               A     127.0.0.2
    90     bar                               A     127.0.0.2
    88     test2                             CNAME bar
    91     test2                             CNAME bar
       
    92     test                              A     127.0.0.2
       
    93 
       
    94 Normal CNAME aliases cannot overlap with other hosts, but the IPv4/IPv6-only `alias4`/`alias6` may overlap.
    89 
    95 
    90 ### Generated hosts
    96 ### Generated hosts
    91 The hosts file format supports something similar to bind9's $GENERATE directive for hosts:
    97 The hosts file format supports something similar to bind9's $GENERATE directive for hosts:
    92 
    98 
    93     [asdf{1-3}]
    99     [dyn{1-8}]
    94         ip  = 10.100.100.$
   100         ip  = 10.1.16.$
    95 
   101 
    96     $ bin/pvl.hosts-dns --forward-zone=asdf etc/hosts/asdf 
   102     $ bin/pvl.hosts-forward etc/hosts/dyn.test 
    97     asdf1@asdf                        A     10.100.100.1
   103     dyn1                              A     10.1.16.1
    98     asdf2@asdf                        A     10.100.100.2
   104     dyn2                              A     10.1.16.2
    99     asdf3@asdf                        A     10.100.100.3
   105     dyn3                              A     10.1.16.3
   100 
   106     dyn4                              A     10.1.16.4
   101 Note that the generate directives are interpreted and compiled directly by pvl.hosts. 
   107     dyn5                              A     10.1.16.5
   102 
   108     dyn6                              A     10.1.16.6
   103 Most of the $GENERATE options should be supported, with a little clever hackery:
   109     dyn7                              A     10.1.16.7
   104 
   110     dyn8                              A     10.1.16.8
   105     [asdf{1-5/2}{0,2}]
   111     
   106        ip  = 10.100.100.$${10}
       
   107 
       
   108     $ bin/pvl.hosts-dns --forward-zone=asdf2 etc/hosts/asdf2
       
   109     asdf01@asdf2                      A     10.100.100.11
       
   110     asdf03@asdf2                      A     10.100.100.13
       
   111     asdf05@asdf2                      A     10.100.100.15
       
   112 
       
   113 This feature can be used for generating reverse delegations:
   112 This feature can be used for generating reverse delegations:
   114 
       
   115     [foo-{240-247}]
   113     [foo-{240-247}]
   116         forward =
   114         forward =
   117         reverse = $.240/29.0.0.10.in-addr.arpa
   115         reverse = $.240/29.0.0.10.in-addr.arpa
   118         ip      = 10.0.0.$
   116         ip      = 10.0.0.$
   119     
   117 
   120     $ bin/pvl.hosts-dns --reverse-zone=10 etc/hosts/reverse 
   118     $ bin/pvl.hosts-reverse --zone-prefix=10.0.0.0/16 etc/hosts/reverse.test 
   121     240.0.0                           CNAME 240.240/29.0.0.10.in-addr.arpa.
   119     240.0                             CNAME 240.240/29.0.0.10.in-addr.arpa.
   122     241.0.0                           CNAME 241.240/29.0.0.10.in-addr.arpa.
   120     241.0                             CNAME 241.240/29.0.0.10.in-addr.arpa.
   123     242.0.0                           CNAME 242.240/29.0.0.10.in-addr.arpa.
   121     242.0                             CNAME 242.240/29.0.0.10.in-addr.arpa.
   124     243.0.0                           CNAME 243.240/29.0.0.10.in-addr.arpa.
   122     243.0                             CNAME 243.240/29.0.0.10.in-addr.arpa.
   125     244.0.0                           CNAME 244.240/29.0.0.10.in-addr.arpa.
   123     244.0                             CNAME 244.240/29.0.0.10.in-addr.arpa.
   126     245.0.0                           CNAME 245.240/29.0.0.10.in-addr.arpa.
   124     245.0                             CNAME 245.240/29.0.0.10.in-addr.arpa.
   127     246.0.0                           CNAME 246.240/29.0.0.10.in-addr.arpa.
   125     246.0                             CNAME 246.240/29.0.0.10.in-addr.arpa.
   128     247.0.0                           CNAME 247.240/29.0.0.10.in-addr.arpa.
   126     247.0                             CNAME 247.240/29.0.0.10.in-addr.arpa.
   129 
   127 
   130 ### DHCP Options
   128 ### DHCP Options
   131 The hosts need not specify any fixed ip address, leaving IP address allocation to dhcpd:
   129 The hosts need not specify any fixed ip address, leaving IP address allocation to dhcpd:
   132 
   130 
   133     [foo]
   131     [foo]
   134         ethernet    = 00:11:22:33:44:55 
   132         ethernet    = 00:11:22:33:44:55 
   135     
   133     
   136     $ bin/pvl.hosts-dhcp etc/hosts/dhcp1 
   134     $ bin/pvl.hosts-dhcp etc/hosts/dhcp.test 
   137     host foo {
   135     host foo {
   138         option host-name foo;
   136         option host-name foo;
   139         hardware ethernet 00:11:22:33:44:55;
   137         hardware ethernet 00:11:22:33:44:55;
   140     }
   138     }
   141 
   139 
   142 ### DHCP Boot options
   140 ### DHCP Boot options
   143 The hosts can specify DHCP boot server/file options:
   141 The hosts can specify DHCP boot server/file options:
   144 
   142 
   145     [foo]
   143     boot.next-server  = boot.test
   146         ethernet    = 00:11:22:33:44:55
   144 
   147         boot        = boot.lan:debian/wheezy/pxelinux.0
   145     [foo]
   148 
   146         ethernet        = 00:11:22:33:44:55
   149     $ bin/pvl.hosts-dhcp etc/hosts/boot.dhcp 
   147         boot            = boot2.test:/debian/wheezy/pxelinux.0
       
   148 
       
   149     [bar]
       
   150         ethernet        = 00:11:22:33:44:55
       
   151         boot.filename   = /debian/jessie/pxelinux.0
       
   152 
       
   153     $ bin/pvl.hosts-dhcp etc/hosts/boot.test 
   150     host foo {
   154     host foo {
   151         option host-name foo;
   155         option host-name foo;
   152         hardware ethernet 00:11:22:33:44:55;
   156         hardware ethernet 00:11:22:33:44:55;
   153         next-server boot.lan;
   157         next-server boot2.test;
   154         filename debian/wheezy/pxelinux.0;
   158         filename "/debian/wheezy/pxelinux.0";
       
   159     }
       
   160 
       
   161     host bar {
       
   162         option host-name bar;
       
   163         hardware ethernet 00:11:22:33:44:55;
       
   164         next-server boot.test;
       
   165         filename "/debian/jessie/pxelinux.0";
   155     }
   166     }
   156 
   167 
   157 ### DHCP hosts in multiple subnets/domains
   168 ### DHCP hosts in multiple subnets/domains
   158 A host with different interfaces in multiple domains must specify unique interface names:
   169 A host with different interfaces in multiple domains must specify unique interface names:
   159 
   170 
   160     [foo.dhcp]
   171     [foo]
   161         [[asdf]]
   172         [[asdf]]
   162             ip              = 10.1.0.1
   173             ip              = 10.1.0.1
   163             ethernet.eth1   = 00:11:22:33:44:55
   174             ethernet.eth1   = 00:11:22:33:44:55
   164 
   175 
   165     [bar.dhcp]
   176     [bar]
   166         [[asdf]]
   177         [[asdf]]
   167             ip              = 10.2.0.1
   178             ip              = 10.2.0.1
   168             ethernet.eth2   = 55:44:33:22:11:00
   179             ethernet.eth2   = 55:44:33:22:11:00
   169 
   180 
   170     $ bin/pvl.hosts-dhcp etc/hosts/dhcp2 
   181     $ bin/pvl.hosts-dhcp etc/hosts/dhcp-test 
   171     host asdf-eth1 {
   182     host asdf-eth1 {
   172         option host-name asdf;
   183         option host-name asdf;
   173         hardware ethernet 00:11:22:33:44:55;
   184         hardware ethernet 00:11:22:33:44:55;
   174         fixed-address 10.1.0.1;
   185         fixed-address 10.1.0.1;
   175     }
   186     }
   191     etc/zones/
   202     etc/zones/
   192     ├── forward
   203     ├── forward
   193     │   └── test
   204     │   └── test
   194     │       ├── asdf.test -> ../../../hosts/asdf.test
   205     │       ├── asdf.test -> ../../../hosts/asdf.test
   195     │       └── test -> ../../../hosts/test
   206     │       └── test -> ../../../hosts/test
   196     └── reverse
   207     ├── reverse
   197         └── 192.0.2
   208     │   └── 192.0.2
   198             ├── asdf.test -> ../../../hosts/asdf.test
   209     │       ├── asdf.test -> ../../../hosts/asdf.test
   199             └── test -> ../../../hosts/test
   210     │       └── test -> ../../../hosts/test
       
   211     └── test
   200 
   212 
   201 Given a structure like above, the `pvl.hosts-forward` can generate a single forward zone containing all sub-domains:
   213 Given a structure like above, the `pvl.hosts-forward` can generate a single forward zone containing all sub-domains:
   202 
   214 
   203     $ bin/pvl.hosts-forward --hosts-include etc/hosts/ etc/zones/forward/test/
   215     $ bin/pvl.hosts-forward --hosts-include etc/hosts/ etc/zones/forward/test/
   204     foo                               A     192.0.2.1
   216     foo                               A     192.0.2.1
   240 
   252 
   241     $ ./bin/update
   253     $ ./bin/update
   242     Commit...
   254     Commit...
   243     Using commit timestamp: 1425049508
   255     Using commit timestamp: 1425049508
   244     Updating forward host zones...
   256     Updating forward host zones...
   245       var/zones/forward/test: Generating forward hosts zone: etc/zones/forward/test/
   257       var/zones/forward/test: Generating forward hosts zone: etc/zones/forward/test
   246     Updating reverse host zones...
   258     Updating reverse host zones...
   247       var/zones/reverse/192.0.2: Generating reverse hosts zone: etc/zones/reverse/192.0.2/
   259       var/zones/reverse/192.0.2: Generating reverse hosts zone: etc/zones/reverse/192.0.2
   248     Updating DHCP hosts...
   260     Updating DHCP hosts...
   249     Copying zone includes...
   261     Copying zone includes...
   250     Updating zones...
   262     Updating zones...
   251       var/serials/test: Update serial: 1425049508 <- 1425049508
   263       var/serials/test: Update serial: 1425049508 <- 1425049508
   252       var/zones/test: Generate zone: etc/zones/test
   264       var/zones/test: Generate zone: etc/zones/test