tero@438: = pvl-hosts = terom@34: tero@443: DNS/DHCP hosts management/integration for ISC bind9 and dhcpd. tero@443: tero@443: Also includes network SNMP discovery. tero@443: tero@443: == Hosts == tero@512: The `pvl.hosts-*` tools read hosts files as input, which have an ini format, using section names as hostnames to configure attributes for that host: tero@443: tero@443: [foo] tero@512: ip = 192.0.2.1 tero@452: ethernet = 00:11:22:33:44:55 tero@443: tero@443: [bar] tero@512: ip = 192.0.2.2 tero@452: ethernet = 01:23:45:67:89:ab tero@443: tero@512: The domain name for a host is determined from the basename of the config file, so this example file would generate something like the following output for use in a `zone "test" { ... }` zonefile: tero@512: tero@512: $ bin/pvl.hosts-forward --forward-zone example.com etc/hosts/example.com tero@512: foo A 192.0.2.1 tero@512: bar A 192.0.2.2 tero@443: tero@512: And correspondingly, the reverse zone for 192.0.2.0/24 tero@443: tero@512: $ bin/pvl.hosts-reverse --reverse-zone=192.0.2 etc/hosts/example.com tero@512: 1 PTR foo.example.com. tero@512: 2 PTR bar.example.com. tero@443: tero@452: And the associated DHCP hosts: tero@452: tero@512: $ bin/pvl.hosts-dhcp etc/hosts/example.com tero@452: host foo { tero@480: option host-name foo; tero@480: hardware ethernet 00:11:22:33:44:55; tero@512: fixed-address 192.0.2.1; tero@452: } tero@452: tero@452: host bar { tero@480: option host-name bar; tero@480: hardware ethernet 01:23:45:67:89:ab; tero@512: fixed-address 192.0.2.2; tero@452: } tero@452: tero@514: === Include directories === tero@507: Host configs can be included: tero@507: tero@514: $ cat etc/hosts/test/test tero@514: include = test.d/ tero@507: tero@514: $ cat etc/hosts/test/test.d/foo tero@507: ip = 192.0.2.1 tero@507: tero@514: $ cat etc/hosts/test/test.d/bar tero@507: ip = 192.0.2.2 tero@507: tero@514: $ bin/pvl.hosts-forward --forward-zone test etc/hosts/test/test tero@514: foo A 192.0.2.1 tero@514: bar A 192.0.2.2 tero@514: tero@514: And an entire directory of hosts-files, containing sub-domains, can be given: tero@514: tero@514: $ ls etc/hosts/test/ tero@514: asdf.test test test.d tero@514: tero@514: $ cat etc/hosts/test/asdf.test tero@514: [quux] tero@514: ip = 192.0.2.5 tero@514: tero@514: $ bin/pvl.hosts-forward --forward-zone test etc/hosts/test/ tero@514: foo A 192.0.2.1 tero@514: bar A 192.0.2.2 tero@514: quux.asdf A 192.0.2.5 tero@514: tero@514: Note that the (include) directory name itself is NOT treated as a domain name. However, the file names which are included are. tero@514: tero@514: Including a directory of files is equivalent to substituiting each file as a named section at the level of the include = statement. Note that this means that included files are treated directly as host definitions, IOW, you should NOT include a section name in an included host file unless you want to declare an additional subdomain: tero@514: tero@514: $ cat etc/hosts/wrong.test tero@514: include = wrong.d/ tero@514: tero@514: $ etc/hosts/wrong.d/host tero@514: [host] tero@514: ip = 192.0.2.6 tero@514: tero@514: $ bin/pvl.hosts-forward --forward-zone test etc/hosts/wrong.test tero@514: host.host.wrong A 192.0.2.6 tero@507: tero@484: === Host aliases === tero@484: Hosts can specify DNS aliases: tero@484: tero@484: [foo] tero@484: ip = 127.0.0.1 tero@484: alias = test1 tero@484: tero@484: [bar] tero@484: ip = 127.0.0.2 tero@484: alias = test2 tero@484: tero@484: $ bin/pvl.hosts-forward --forward-zone alias.test etc/hosts/alias.test tero@484: foo A 127.0.0.1 tero@484: test1 CNAME foo tero@484: bar A 127.0.0.2 tero@484: test2 CNAME bar tero@484: tero@447: === Generated hosts === tero@447: The hosts file format supports something similar to bind9's $GENERATE directive for hosts: tero@447: tero@447: [asdf{1-3}] tero@447: ip = 10.100.100.$ tero@447: tero@447: $ bin/pvl.hosts-dns --forward-zone=asdf etc/hosts/asdf tero@447: asdf1@asdf A 10.100.100.1 tero@447: asdf2@asdf A 10.100.100.2 tero@447: asdf3@asdf A 10.100.100.3 tero@447: tero@447: Note that the generate directives are interpreted and compiled directly by pvl.hosts. tero@447: tero@447: Most of the $GENERATE options should be supported, with a little clever hackery: tero@447: tero@447: [asdf{1-5/2}{0,2}] tero@447: ip = 10.100.100.$${10} tero@447: tero@447: $ bin/pvl.hosts-dns --forward-zone=asdf2 etc/hosts/asdf2 tero@447: asdf01@asdf2 A 10.100.100.11 tero@447: asdf03@asdf2 A 10.100.100.13 tero@447: asdf05@asdf2 A 10.100.100.15 tero@447: tero@448: This feature can be used for generating reverse delegations: tero@448: tero@448: [foo-{240-247}] tero@448: forward = tero@448: reverse = $.240/29.0.0.10.in-addr.arpa tero@448: ip = 10.0.0.$ tero@448: tero@448: $ bin/pvl.hosts-dns --reverse-zone=10 etc/hosts/reverse tero@448: 240.0.0 CNAME 240.240/29.0.0.10.in-addr.arpa. tero@448: 241.0.0 CNAME 241.240/29.0.0.10.in-addr.arpa. tero@448: 242.0.0 CNAME 242.240/29.0.0.10.in-addr.arpa. tero@448: 243.0.0 CNAME 243.240/29.0.0.10.in-addr.arpa. tero@448: 244.0.0 CNAME 244.240/29.0.0.10.in-addr.arpa. tero@448: 245.0.0 CNAME 245.240/29.0.0.10.in-addr.arpa. tero@448: 246.0.0 CNAME 246.240/29.0.0.10.in-addr.arpa. tero@448: 247.0.0 CNAME 247.240/29.0.0.10.in-addr.arpa. tero@480: tero@480: === DHCP Options === tero@480: The hosts need not specify any fixed ip address, leaving IP address allocation to dhcpd: tero@480: tero@480: [foo] tero@480: ethernet = 00:11:22:33:44:55 tero@480: tero@480: $ bin/pvl.hosts-dhcp etc/hosts/dhcp1 tero@480: host foo { tero@480: option host-name foo; tero@480: hardware ethernet 00:11:22:33:44:55; tero@480: } tero@480: tero@480: === DHCP Boot options === tero@480: The hosts can specify DHCP boot server/file options: tero@480: tero@480: [foo] tero@480: ethernet = 00:11:22:33:44:55 tero@480: boot = boot.lan:debian/wheezy/pxelinux.0 tero@480: tero@480: $ bin/pvl.hosts-dhcp etc/hosts/boot.dhcp tero@480: host foo { tero@480: option host-name foo; tero@480: hardware ethernet 00:11:22:33:44:55; tero@480: next-server boot.lan; tero@480: filename debian/wheezy/pxelinux.0; tero@480: } tero@480: tero@483: === DHCP hosts in multiple subnets/domains === tero@483: A host with different interfaces in multiple domains must specify unique interface names: tero@483: tero@483: [foo.dhcp] tero@483: [[asdf]] tero@483: ip = 10.1.0.1 tero@483: ethernet.eth1 = 00:11:22:33:44:55 tero@483: tero@483: [bar.dhcp] tero@483: [[asdf]] tero@483: ip = 10.2.0.1 tero@483: ethernet.eth2 = 55:44:33:22:11:00 tero@483: tero@483: $ bin/pvl.hosts-dhcp etc/hosts/dhcp2 tero@483: host asdf-eth1 { tero@483: option host-name asdf; tero@483: hardware ethernet 00:11:22:33:44:55; tero@483: fixed-address 10.1.0.1; tero@483: } tero@483: tero@483: host asdf-eth2 { tero@483: option host-name asdf; tero@483: hardware ethernet 55:44:33:22:11:00; tero@483: fixed-address 10.2.0.1; tero@483: } tero@483: