From 958036fae07091cb77070a2fdf97c353ab0f246d Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Sun, 31 Mar 2019 19:31:38 +0200 Subject: space_server: dhcpd: update dhcpd.conf Host declerations are global and dhcpd has been warning about this for some time. --- roles/space_server/templates/dhcpd.conf.j2 | 177 ++++++++--------------------- roles/space_server/vars/main.yml | 2 +- 2 files changed, 49 insertions(+), 130 deletions(-) (limited to 'roles') diff --git a/roles/space_server/templates/dhcpd.conf.j2 b/roles/space_server/templates/dhcpd.conf.j2 index 1b832e1..e071a88 100644 --- a/roles/space_server/templates/dhcpd.conf.j2 +++ b/roles/space_server/templates/dhcpd.conf.j2 @@ -12,9 +12,12 @@ ddns-update-style none; # option definitions common to all supported networks... #option domain-name "labitat.dk"; +abandon-lease-time 86400; default-lease-time 3600; max-lease-time 7200; min-lease-time 600; +dynamic-bootp-lease-length 86400; +db-time-format local; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. @@ -24,180 +27,96 @@ authoritative; # have to hack syslog.conf to complete the redirection). log-facility daemon; - # Admin net subnet 10.42.0.0 netmask 255.255.255.0 { + server-identifier 10.42.0.1; range 10.42.0.50 10.42.0.69; range 10.42.0.71 10.42.0.250; option routers 10.42.0.1; option domain-name-servers 185.38.175.0; #option ntp-servers 90.185.0.18; -{% for host in local_hosts %} -{% if host.ips | ipaddr('10.42.0.0/24') %} -{% if 'mac' in host %} - -{% if 'description' in host %} - # {{ host.description }} -{% endif %} - host {{ host.name }} { - hardware ethernet {{ host.mac }}; - fixed-address {{ host.ips | ipaddr('10.42.0.0/24') | first }}; -{% if 'filename' in host %} - filename "{{ host.filename }}"; -{% endif %} - } -{% else %} - -{% if 'description' in host %} - # {{ host.description }} -{% endif %} - #host {{ host.name }} { - # fixed-address {{ host.ips | ipaddr('10.42.0.0/24') | first }}; - #} -{% endif %} -{% endif %} -{% endfor %} - host spacewand { - hardware ethernet 00:1f:7b:b4:0e:00; - fixed-address 10.42.0.70; - } + deny bootp; + allow duplicates; + allow declines; + allow leasequery; } - # Wired net subnet 10.42.1.0 netmask 255.255.255.0 { + server-identifier 10.42.1.1; range dynamic-bootp 10.42.1.50 10.42.1.250; option routers 10.42.1.1; option domain-name-servers 185.38.175.0; #option ntp-servers 90.185.0.18; next-server 10.42.1.1; filename "pxelinux.0"; -{% for host in local_hosts %} -{% if host.ips | ipaddr('10.42.1.0/24') %} -{% if 'mac' in host %} -{% if 'description' in host %} - # {{ host.description }} -{% endif %} - host {{ host.name }} { - hardware ethernet {{ host.mac }}; - fixed-address {{ host.ips | ipaddr('10.42.1.0/24') | first }}; -{% if 'filename' in host %} - filename "{{ host.filename }}"; -{% endif %} - } -{% else %} - -{% if 'description' in host %} - # {{ host.description }} -{% endif %} - #host {{ host.name }} { - # fixed-address {{ host.ips | ipaddr('10.42.1.0/24') | first }}; - #} -{% endif %} -{% endif %} -{% endfor %} + allow bootp; + allow duplicates; + allow declines; + allow leasequery; } - # Private wifi subnet 10.42.2.0 netmask 255.255.255.0 { - range 10.42.2.50 10.42.2.250; + server-identifier 10.42.2.1; + range dynamic-bootp 10.42.2.50 10.42.2.250; option routers 10.42.2.1; option domain-name-servers 185.38.175.0; #option ntp-servers 90.185.0.18; next-server 10.42.2.1; filename "pxelinux.0"; -{% for host in local_hosts %} -{% if host.ips | ipaddr('10.42.2.0/24') %} -{% if 'mac' in host %} - -{% if 'description' in host %} - # {{ host.description }} -{% endif %} - host {{ host.name }} { - hardware ethernet {{ host.mac }}; - fixed-address {{ host.ips | ipaddr('10.42.2.0/24') | first }}; -{% if 'filename' in host %} - filename "{{ host.filename }}"; -{% endif %} - } -{% else %} -{% if 'description' in host %} - # {{ host.description }} -{% endif %} - #host {{ host.name }} { - # fixed-address {{ host.ips | ipaddr('10.42.2.0/24') | first }}; - #} -{% endif %} -{% endif %} -{% endfor %} + allow bootp; + allow duplicates; + allow declines; + allow leasequery; } # Free wifi subnet 10.42.3.0 netmask 255.255.255.0 { - range 10.42.3.50 10.42.3.250; + server-identifier 10.42.3.1; + range dynamic-bootp 10.42.3.50 10.42.3.250; option routers 10.42.3.1; option domain-name-servers 185.38.175.0; #option ntp-servers 90.185.0.18; -{% for host in local_hosts %} -{% if host.ips | ipaddr('10.42.3.0/24') %} -{% if 'mac' in host %} -{% if 'description' in host %} - # {{ host.description }} -{% endif %} - host {{ host.name }} { - hardware ethernet {{ host.mac }}; - fixed-address {{ host.ips | ipaddr('10.42.3.0/24') | first }}; -{% if 'filename' in host %} - filename "{{ host.filename }}"; -{% endif %} - } -{% else %} - -{% if 'description' in host %} - # {{ host.description }} -{% endif %} - #host {{ host.name }} { - # fixed-address {{ host.ips | ipaddr('10.42.3.0/24') | first }}; - #} -{% endif %} -{% endif %} -{% endfor %} + allow bootp; + allow duplicates; + deny declines; + deny leasequery; } -# Password protected wifi -subnet 10.42.4.0 netmask 255.255.255.0 { - range 10.42.4.50 10.42.4.250; - option routers 10.42.4.1; - option domain-name-servers 185.38.175.0; - #option ntp-servers 90.185.0.18; +## Password protected wifi +#subnet 10.42.4.0 netmask 255.255.255.0 { +# server-identifier 10.42.4.1; +# range dynamic-bootp 10.42.4.50 10.42.4.250; +# option routers 10.42.4.1; +# option domain-name-servers 185.38.175.0; +# #option ntp-servers 90.185.0.18; +# +# allow bootp; +# allow duplicates; +# allow declines; +# allow leasequery; +#} + +group { + use-host-decl-names on; {% for host in local_hosts %} -{% if host.ips | ipaddr('10.42.4.0/24') %} -{% if 'mac' in host %} -{% if 'description' in host %} +{% if 'mac' in host %} +{% if 'description' in host %} # {{ host.description }} -{% endif %} +{% endif %} host {{ host.name }} { hardware ethernet {{ host.mac }}; - fixed-address {{ host.ips | ipaddr('10.42.4.0/24') | first }}; -{% if 'filename' in host %} + fixed-address {{ host.ips | first }}; +{% if 'filename' in host %} filename "{{ host.filename }}"; -{% endif %} +{% endif %} } -{% else %} - -{% if 'description' in host %} - # {{ host.description }} -{% endif %} - #host {{ host.name }} { - # fixed-address {{ host.ips | ipaddr('10.42.4.0/24') | first }}; - #} -{% endif %} -{% endif %} +{% endif %} {% endfor %} } diff --git a/roles/space_server/vars/main.yml b/roles/space_server/vars/main.yml index 3274193..40f4251 100644 --- a/roles/space_server/vars/main.yml +++ b/roles/space_server/vars/main.yml @@ -20,7 +20,7 @@ dnf_packages: 'dosfstools': present 'btrfs-progs': present 'ansible': present - 'python3-netaddr': present # for dhcpd template + 'python3-netaddr': present # for avahi-hosts template 'git': present 'htop': present 'man-db': present -- cgit v1.2.1