added dnsmasq

This commit is contained in:
Jonas Forsberg 2021-09-23 11:13:04 +02:00
parent b71b10076e
commit 7320bc64c8
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,7 @@
interface={{ interface }}
listen-address= {{ ip }}
bind-interfaces
server=1.1.1.1
domain-needed
bogus-priv
dhcp-range={{ ip[0:-1] }}50,{{ ip[0:-1] }}150,12h

View File

@ -0,0 +1,44 @@
Install dnsmasq:
pkg.installed:
- name: dnsmasq
{% set ip = pillar['network']['ip'] -%}
{% set interface = pillar['network']['interface']['internal'] -%}
configure dnsmasq for internal interface:
file.managed:
- name: /etc/dnsmasq.d/{{ interface }}.conf
- source: salt://dnsmasq/files/dnsmasq.conf.jinja
- template: jinja
- user: root
- group: root
- mode: "0644"
- context:
ip: {{ ip }}
interface: {{ interface }}
{% for vlan in pillar['network']['vlan'] -%}
{% set id = vlan['id'] -%}
{% set ip = vlan['address'] -%}
configure dnsmasq for vlan.{{ id }}:
file.managed:
- name: /etc/dnsmasq.d/vlan.{{ id }}.conf
- source: salt://dnsmasq/files/dnsmasq.conf.jinja
- template: jinja
- user: root
- group: root
- mode: "0644"
- context:
ip: {{ ip }}
interface: vlan.{{ id }}
{% endfor %}
Start dnsmasq:
service.running:
- name: dnsmasq
- enable: True
- watch:
- file: configure dnsmasq for internal interface
{% for vlan in pillar['network']['vlan'] -%}
{% set id = vlan['id'] -%}
- file: configure dnsmasq for vlan.{{ id }}
{% endfor %}