# HG changeset patch # User Tero Marttila # Date 1425380851 -7200 # Node ID d3cea99888489824f64192bd2be8f54f02238437 # Parent 956fdb057cf035f3361c963fc473949db346c506# Parent 0816716c3f6684abff9a9e05c8dd2d3d962e7743 merge diff -r 956fdb057cf0 -r d3cea9988848 README.md --- a/README.md Tue Mar 03 13:07:17 2015 +0200 +++ b/README.md Tue Mar 03 13:07:31 2015 +0200 @@ -76,56 +76,54 @@ [foo] ip = 127.0.0.1 alias = test1 + alias4 = test [bar] ip = 127.0.0.2 alias = test2 + alias4 = test - $ bin/pvl.hosts-forward --forward-zone alias.test etc/hosts/alias.test + $ bin/pvl.hosts-forward etc/hosts/alias.test foo A 127.0.0.1 test1 CNAME foo + test A 127.0.0.1 bar A 127.0.0.2 test2 CNAME bar + test A 127.0.0.2 + +Normal CNAME aliases cannot overlap with other hosts, but the IPv4/IPv6-only `alias4`/`alias6` may overlap. ### Generated hosts The hosts file format supports something similar to bind9's $GENERATE directive for hosts: - [asdf{1-3}] - ip = 10.100.100.$ - - $ bin/pvl.hosts-dns --forward-zone=asdf etc/hosts/asdf - asdf1@asdf A 10.100.100.1 - asdf2@asdf A 10.100.100.2 - asdf3@asdf A 10.100.100.3 - -Note that the generate directives are interpreted and compiled directly by pvl.hosts. + [dyn{1-8}] + ip = 10.1.16.$ -Most of the $GENERATE options should be supported, with a little clever hackery: - - [asdf{1-5/2}{0,2}] - ip = 10.100.100.$${10} - - $ bin/pvl.hosts-dns --forward-zone=asdf2 etc/hosts/asdf2 - asdf01@asdf2 A 10.100.100.11 - asdf03@asdf2 A 10.100.100.13 - asdf05@asdf2 A 10.100.100.15 - + $ bin/pvl.hosts-forward etc/hosts/dyn.test + dyn1 A 10.1.16.1 + dyn2 A 10.1.16.2 + dyn3 A 10.1.16.3 + dyn4 A 10.1.16.4 + dyn5 A 10.1.16.5 + dyn6 A 10.1.16.6 + dyn7 A 10.1.16.7 + dyn8 A 10.1.16.8 + This feature can be used for generating reverse delegations: - [foo-{240-247}] forward = reverse = $.240/29.0.0.10.in-addr.arpa ip = 10.0.0.$ - - $ bin/pvl.hosts-dns --reverse-zone=10 etc/hosts/reverse - 240.0.0 CNAME 240.240/29.0.0.10.in-addr.arpa. - 241.0.0 CNAME 241.240/29.0.0.10.in-addr.arpa. - 242.0.0 CNAME 242.240/29.0.0.10.in-addr.arpa. - 243.0.0 CNAME 243.240/29.0.0.10.in-addr.arpa. - 244.0.0 CNAME 244.240/29.0.0.10.in-addr.arpa. - 245.0.0 CNAME 245.240/29.0.0.10.in-addr.arpa. - 246.0.0 CNAME 246.240/29.0.0.10.in-addr.arpa. - 247.0.0 CNAME 247.240/29.0.0.10.in-addr.arpa. + + $ bin/pvl.hosts-reverse --zone-prefix=10.0.0.0/16 etc/hosts/reverse.test + 240.0 CNAME 240.240/29.0.0.10.in-addr.arpa. + 241.0 CNAME 241.240/29.0.0.10.in-addr.arpa. + 242.0 CNAME 242.240/29.0.0.10.in-addr.arpa. + 243.0 CNAME 243.240/29.0.0.10.in-addr.arpa. + 244.0 CNAME 244.240/29.0.0.10.in-addr.arpa. + 245.0 CNAME 245.240/29.0.0.10.in-addr.arpa. + 246.0 CNAME 246.240/29.0.0.10.in-addr.arpa. + 247.0 CNAME 247.240/29.0.0.10.in-addr.arpa. ### DHCP Options The hosts need not specify any fixed ip address, leaving IP address allocation to dhcpd: @@ -133,7 +131,7 @@ [foo] ethernet = 00:11:22:33:44:55 - $ bin/pvl.hosts-dhcp etc/hosts/dhcp1 + $ bin/pvl.hosts-dhcp etc/hosts/dhcp.test host foo { option host-name foo; hardware ethernet 00:11:22:33:44:55; @@ -142,32 +140,45 @@ ### DHCP Boot options The hosts can specify DHCP boot server/file options: + boot.next-server = boot.test + [foo] - ethernet = 00:11:22:33:44:55 - boot = boot.lan:debian/wheezy/pxelinux.0 + ethernet = 00:11:22:33:44:55 + boot = boot2.test:/debian/wheezy/pxelinux.0 - $ bin/pvl.hosts-dhcp etc/hosts/boot.dhcp + [bar] + ethernet = 00:11:22:33:44:55 + boot.filename = /debian/jessie/pxelinux.0 + + $ bin/pvl.hosts-dhcp etc/hosts/boot.test host foo { option host-name foo; hardware ethernet 00:11:22:33:44:55; - next-server boot.lan; - filename debian/wheezy/pxelinux.0; + next-server boot2.test; + filename "/debian/wheezy/pxelinux.0"; + } + + host bar { + option host-name bar; + hardware ethernet 00:11:22:33:44:55; + next-server boot.test; + filename "/debian/jessie/pxelinux.0"; } ### DHCP hosts in multiple subnets/domains A host with different interfaces in multiple domains must specify unique interface names: - [foo.dhcp] + [foo] [[asdf]] ip = 10.1.0.1 ethernet.eth1 = 00:11:22:33:44:55 - [bar.dhcp] + [bar] [[asdf]] ip = 10.2.0.1 ethernet.eth2 = 55:44:33:22:11:00 - $ bin/pvl.hosts-dhcp etc/hosts/dhcp2 + $ bin/pvl.hosts-dhcp etc/hosts/dhcp-test host asdf-eth1 { option host-name asdf; hardware ethernet 00:11:22:33:44:55; @@ -180,6 +191,27 @@ fixed-address 10.2.0.1; } +### DHCP subgroups +Hosts can be assigned to DHCP subgroups by hardware ethernet: + +#### `dhcpd.conf` + class "test-hosts" { + match hardware; + } + +#### `etc/hosts/dhcp-classes.test` + [foo] + ethernet = 00:11:22:33:44:55 + dhcp:subclass = test-hosts + +#### `bin/pvl.hosts-dhcp etc/hosts/dhcp-classes.test` + host foo { + option host-name foo; + hardware ethernet 00:11:22:33:44:55; + } + + subclass "test-hosts" 1:00:11:22:33:44:55; + # `update` A script to drive the *pvl.hosts* tools for maintaing a set of zone/host files for a DNS/DHCP server. @@ -193,10 +225,11 @@ │   └── test │   ├── asdf.test -> ../../../hosts/asdf.test │   └── test -> ../../../hosts/test - └── reverse - └── 192.0.2 - ├── asdf.test -> ../../../hosts/asdf.test - └── test -> ../../../hosts/test + ├── reverse + │   └── 192.0.2 + │   ├── asdf.test -> ../../../hosts/asdf.test + │   └── test -> ../../../hosts/test + └── test Given a structure like above, the `pvl.hosts-forward` can generate a single forward zone containing all sub-domains: diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/alias.test --- a/etc/hosts/alias.test Tue Mar 03 13:07:17 2015 +0200 +++ b/etc/hosts/alias.test Tue Mar 03 13:07:31 2015 +0200 @@ -1,7 +1,9 @@ [foo] ip = 127.0.0.1 - alias = test + alias = test1 + alias4 = test [bar] ip = 127.0.0.2 - alias = test + alias = test2 + alias4 = test diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/asdf --- a/etc/hosts/asdf Tue Mar 03 13:07:17 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -[asdf{1-3}] - ip = 10.100.100.$ diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/boot.dhcp --- a/etc/hosts/boot.dhcp Tue Mar 03 13:07:17 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -[foo] - ethernet = 00:11:22:33:44:55 - boot = boot.lan:debian/wheezy/pxelinux.0 diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/boot.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/hosts/boot.test Tue Mar 03 13:07:31 2015 +0200 @@ -0,0 +1,9 @@ +boot.next-server = boot.test + +[foo] + ethernet = 00:11:22:33:44:55 + boot = boot2.test:/debian/wheezy/pxelinux.0 + +[bar] + ethernet = 00:11:22:33:44:55 + boot.filename = /debian/jessie/pxelinux.0 diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/dhcp-classes.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/hosts/dhcp-classes.test Tue Mar 03 13:07:31 2015 +0200 @@ -0,0 +1,4 @@ +[foo] + ethernet = 00:11:22:33:44:55 + dhcp:subclass = test-hosts + diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/dhcp-test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/hosts/dhcp-test Tue Mar 03 13:07:31 2015 +0200 @@ -0,0 +1,9 @@ +[foo] + [[asdf]] + ip = 10.1.0.1 + ethernet.eth1 = 00:11:22:33:44:55 + +[bar] + [[asdf]] + ip = 10.2.0.1 + ethernet.eth2 = 55:44:33:22:11:00 diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/dhcp.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/hosts/dhcp.test Tue Mar 03 13:07:31 2015 +0200 @@ -0,0 +1,2 @@ +[foo] + ethernet = 00:11:22:33:44:55 diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/dhcp1 --- a/etc/hosts/dhcp1 Tue Mar 03 13:07:17 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -[foo] - ethernet = 00:11:22:33:44:55 diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/dhcp2 --- a/etc/hosts/dhcp2 Tue Mar 03 13:07:17 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -[foo.dhcp] - [[asdf]] - ip = 10.1.0.1 - ethernet.eth1 = 00:11:22:33:44:55 - -[bar.dhcp] - [[asdf]] - ip = 10.2.0.1 - ethernet.eth2 = 55:44:33:22:11:00 diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/dyn.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/hosts/dyn.test Tue Mar 03 13:07:31 2015 +0200 @@ -0,0 +1,2 @@ +[dyn{1-8}] + ip = 10.1.16.$ diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/reverse --- a/etc/hosts/reverse Tue Mar 03 13:07:17 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -[foo-{240-247}] - forward = - reverse = $.240/29.0.0.10.in-addr.arpa - ip = 10.0.0.$ diff -r 956fdb057cf0 -r d3cea9988848 etc/hosts/reverse.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/hosts/reverse.test Tue Mar 03 13:07:31 2015 +0200 @@ -0,0 +1,4 @@ +[foo-{240-247}] + forward = + reverse = $.240/29.0.0.10.in-addr.arpa + ip = 10.0.0.$