lucab85.ansible_role_bind

Ansible Rolle: BIND

CI

Installiert und konfiguriert einen BIND9 DNS-Dienst auf Fedora/Centos/RHEL7/8 und Debian/Ubuntu als autoritativ für ein oder mehrere Domains (Master und/oder Slave) mit angepassten Zonen und Reverse.

Anforderungen

Keine speziellen Anforderungen; beachten Sie, dass diese Rolle Root-Zugriff benötigt. Führen Sie sie entweder in einem Playbook mit become: yes global aus oder rufen Sie die Rolle in Ihrem Playbook so auf:

- hosts: dns
  roles:
    - role: lucab85.ansible_role_bind
      become: yes

Rollenvariablen

Verfügbare Variablen sind im defaults/main.yml File zusammen mit Standardwerten aufgeführt.

Hauptkonfiguration

Alle Einstellungen in bind_main_config_settings werden in der Hauptkonfigurationsdatei /etc/named.conf für Fedora/CentOS/RHEL oder /etc/bind/named.conf für Debian/Ubuntu (plattformabhängig) angewendet. Alle Einstellungen in bind_main_options_settings werden in der Hauptkonfigurationsdatei innerhalb des options { } -Tags angewendet. Beispiel:

bind_main_options_settings:
  - option: listen-on port
    value: '53 { 127.0.0.1; 10.0.1.1; };'
  - option: allow-query
    value: '{ trusted; };'
  - option: forwarders
    value: '{ 8.8.8.8; 8.8.4.4; };'
  - option: listen-on-v6
    value: '{ any; };'
  - option: dnssec-validation
    value: 'auto;'

Bitte beachten Sie, dass in diesem Beispiel 10.0.1.1 die IPv4-Adresse der Zielmaschine ist, passen Sie sie nach Bedarf an.

bind_main_config_settings:
  - option: acl "trusted"
    value: '{ 10.0.1.1; 10.0.1.2; };'

In diesem Beispiel habe ich eine acl trusted mit zwei IPv4-Adressen definiert, die wir für unsere Policy verwenden könnten (siehe später), passen Sie sie nach Bedarf an.

Beispielausgabe:

#
# Von Ansible verwaltet: Diese Datei nicht manuell bearbeiten!
#
options {
    directory "/var/named";
    listen-on port 53 { 127.0.0.1; 10.0.1.1; };
    allow-query { trusted; };
    forwarders { 8.8.8.8; 8.8.4.4; };
    listen-on-v6 { any; };
    dnssec-validation auto;
};
acl "trusted" { 10.0.1.1; 10.0.1.2; };
include "/etc/named/named.conf.local";

Zonenkonfiguration

Die Zonen-Einstellungen werden in bind_zones_entries definiert und durch die Zonen-Definition-Vorlage zone.j2 angewendet. Die Zonen-Einstellungen werden in der Hilfskonfigurationsdatei /etc/named/named.conf.local für Fedora/CentOS/RHEL und Debian/Ubuntu (plattformabhängig) definiert. Die Zonen-Records werden in /var/named/[[ example.com.zone ]] für Fedora/CentOS/RHEL oder /var/lib/bind/[[ example.com.zone ]] für Debian/Ubuntu (plattformabhängig) gespeichert.

Beispiel:

bind_zones_entries:
  - name: "example.com"
    file: "example.com.zone"
    type: "master"
    options: "allow-update { none; };"
    ttl: 86400
    records:
     - name: "@"
       type: "SOA"
       value: "dns1.example.com. hostmaster.example.com. (2001062501 21600 3600 604800 86400)"
     - name: "@"
       type: "NS"
       value: "dns1.example.com."
     - name: "@"
       type: "NS"
       value: "dns2.example.com."
     - name: "dns1"
       type: "A"
       value: "10.0.1.1"
     - name: "dns2"
     [...]

Beispiel lokale Ausgabe: /etc/named/named.conf.local

#
# Von Ansible verwaltet: Diese Datei nicht manuell bearbeiten!
#
zone "example.com" IN {
    type master;
    file "example.com.zone";
    allow-update { none; };
};
zone "1.0.10.in-addr.arpa" IN {
    type master;
    file "example.com.rr.zone";
    allow-update { none; };
};

Beispielausgabe: /var/named/example.com.zone

$ORIGIN example.com.
$TTL 86400;
@  IN  SOA dns1.example.com. hostmaster.example.com. (2001062501 21600 3600 604800 86400)
@  IN  NS dns1.example.com.
@  IN  NS dns2.example.com.
dns1  IN  A 10.0.1.1
dns2  IN  A 10.0.1.2
@  IN  MX 10 mail1.example.com.
@  IN  MX 20 mail2.example.com.
mail1  IN  A 10.0.1.5
mail2  IN  A 10.0.1.6
services  IN  A 10.0.1.10
services  IN  A 10.0.1.11
ftp  IN  CNAME services.example.com.
www  IN  CNAME services.example.com.

Reverse-Zonenkonfiguration

Auf die gleiche Weise wie bei der "Zonen-Konfiguration" können Sie auch eine Reverse-Zone konfigurieren.

Beispiel:

- name: "1.0.10.in-addr.arpa"
  file: "example.com.rr.zone"
  type: "master"
  options: "allow-update { none; };"
  ttl: 86400
  records:
   - name: "@"
     type: "SOA"
     value: "dns1.example.com. hostmaster.example.com. (2001062501 21600 3600 604800 86400)"
   - name: "@"
     type: "NS"
     value: "dns1.example.com."
   - name: "@"
     type: "NS"
     value: "dns2.example.com."
   - name: "1"
     type: "PTR"
     value: "dns1.example.com."
     [...]

Beispielausgabe: /var/named/example.com.rr.zone

$ORIGIN 1.0.10.in-addr.arpa.
$TTL 86400;
@  IN  SOA dns1.example.com. hostmaster.example.com. (2001062501 21600 3600 604800 86400)
@  IN  NS dns1.example.com.
@  IN  NS dns2.example.com.
@  IN  NS dns1.example.com.
1  IN  PTR dns1.example.com.
2  IN  PTR dns2.example.com.
5  IN  PTR mail1.example.com.
6  IN  PTR mail2.example.com.
10  IN  PTR services.example.com.
11  IN  PTR services.example.com.

Bitte beziehen Sie sich auf die BIND-Dokumentation für spezifische Record-Definitionen.

Abhängigkeiten

Keine.

Beispiel-Playbook

- hosts: dns
  become: yes
  vars_files:
    - vars/main.yml
  roles:
    - lucab85.ansible_role_bind

Passen Sie Variablen in vars/main.yml an:

bind_zones_entries:
  - name: "example.com"
    file: "example.com.zone"
    type: "master"
    options: "allow-update { none; };"
    ttl: 86400
    records:
     - name: "@"
       type: "SOA"
       value: "dns1.example.com. hostmaster.example.com. (2001062501 21600 3600 604800 86400)"
     - name: "@"
       type: "NS"
       value: "dns1.example.com."
     - name: "@"
       type: "NS"
       value: "dns2.example.com."
     - name: "dns1"
       type: "A"
       value: "10.0.1.1"
     - name: "dns2"
     [...]

Lizenz

MIT / BSD

Autoreninformation

Diese Rolle wurde 2021 von Luca Berton erstellt, Autor von Ansible Pilot.

Ansible Pilot

Weitere Informationen:

Spenden

Vielen Dank für Ihre Unterstützung:

Über das Projekt

Setup a BIND9 DNS service on Fedora/Centos/RHEL7/8 and Debian/Ubuntu target as authoritative for one or more domains (master and/or slave) with customized zone and reverse.

Installieren
ansible-galaxy install lucab85.ansible_role_bind
GitHub Repository
Lizenz
mit
Downloads
311
Besitzer
Ansible Automation Engineer with Open Source passion: (Ansible, Progressive Web Applications, Cloud Computing, IoT, GNU/Linux)