DNSmasq with puppet

Introductions

So I have started to look  a bit more on puppet and how it works and thought that why not use it for managing my home network and servers.

First thing the dhcp server and dns. If that is working it will be a good place to start.

For those that doesn´t know what puppet is, then you are missing out of a whole lot of fun. Puppet is a server/client management system where puppet slaves gets its configuration but sending facts about ist current state based on a catalog retrieved from the first time the puppet slave manual runs “puppet agent -t” after receiving a certificate with the command “puppet agent -t – -server puppet.local      – -waitforcert 60

Just remember then it is a new server to nano /etc/default/puppet

# Start puppet on boot?
START=yes
And et pluginsync=true in the /etc/puppet/puppet.conf

First I have use a module from puppetlabs from developer Lex.
Lex have excellent documentation on his module.

Configurations

I have started by defining the settings of my configuration

class { ‘dnsmasq’:
domain => ‘kirk’,
domain_needed => ‘true’,
port => ’53’,
expand_hosts => true,
bogus_priv => true,
cache_size => 1000,
restart => true,
resolv_file => ‘/etc/resolv.conf’,
}

So I have a domain for my network call kirk and it is set to need so it would not forward A and AAA with plain names without ‘.’ upstream. Dns port as standart 53.
Bogus_priv so it would answar with “no such domain” if it does a reverse lookup for a private ip that is not located in the /etc/hosts file. Sets a cache siza for the dns and the resolv_file tells dnsmasq where to look for upstream dns servers.

DHCP IP range and lease time

dnsmasq::dhcp { ‘dhcp’:
paramset => ‘kirk’, #optional
dhcp_start => ‘192.168.20.100’,
dhcp_end => ‘192.168.20.200’,
netmask => ‘255.255.255.0’,
lease_time => ’24h’
}

Sets a tag on the configuration with kirk. The rest should be self explained.

Default gateway setup

dnsmasq::dhcpoption { ‘option:router’:
content => ‘192.168.20.1’,
}

Static DHCP setup

dnsmasq::dhcpstatic { ‘apt-proxy’:
mac => ‘AE:85:DE:71:61:2C’,
ip => ‘192.168.20.3’,
}
dnsmasq::dhcpstatic { ‘puppet’:
mac => ’06:6b:38:70:85:1d’,
ip => ‘192.168.20.4’,
}

Resolv.conf file

Settting up the file creation if it not present with two name servers.
The local server and goolge. Then it notifys the service that it needs to restart.

file {‘resolv.conf’:
path => ‘/etc/resolv.conf’,
ensure => present,
mode => 0644,
content => “nameserver 192.168.20.2\nnameserver 8.8.8.8”,
notify => Service[“dnsmasq”],
}

Proxy setting
Adding the proxy setup that I previous talk about.

file {’02proxy’:
path => ‘/etc/apt/apt.conf.d/02proxy’,
ensure => present,
mode => 0644,
content => ‘Acquire::http { Proxy “http://192.168.20.3:3142”; };’,

DNSMASQ Conf file

dnsmasq.conf created by puppet and lex/dnsmasq module.

# MAIN CONFIG START
domain-needed
bogus-priv
strict-order
port=53

expand-hosts
domain=kirk
resolv-file=/etc/resolv.conf
cache-size=1000
conf-dir=/etc/dnsmasq.d
#MAIN CONFIG END

# EXTENDED CONFIG
# EXTENDED CONFIG END

dhcp-range=set:kirk,192.168.20.100,192.168.20.200,255.255.255.0,24h
dhcp-option=option:router,192.168.20.1
dhcp-host=AE:85:DE:71:61:2C,192.168.20.3,apt-proxy
dhcp-host=06:6b:38:70:85:1d,192.168.20.4,puppet

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.