Skip to content

Instantly share code, notes, and snippets.

@facchinm
Created September 8, 2016 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save facchinm/8aee9f43fd354826267b85fb0dc0ab34 to your computer and use it in GitHub Desktop.
Save facchinm/8aee9f43fd354826267b85fb0dc0ab34 to your computer and use it in GitHub Desktop.
dnsmasq_install.sh
#!/bin/bash
set -e
# Raspberry Pi dnsmasq script
# Stephen Wood
# www.heystephenwood.com
#
# Usage: $ sudo ./raspberrypi_dnsmasq
#
# Net install:
# $ curl https://raw.github.com/stephendotexe/raspberrypi/master/roles/dnsmasq_server | sudo sh
# Must be run as root
if [[ `whoami` != "root" ]]
then
echo "This install must be run as root or with sudo."
exit
fi
apt-get update
apt-get install dnsmasq
cat - > /etc/dnsmasq.conf <<DNSMASQCONF
######### dns ########
# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces
bogus-priv
# dont read resolv.conf use the defined servers instead
no-resolv
server=8.8.8.8
server=8.8.4.4
# increase dns cache form 512 to 4096
cache-size=4096
######### dhcp ##########
# Add local-only domains here, queries in these domains are answered
# from /etc/hosts or DHCP only
local=/home/
# Set this (and domain: see below) if you want to have a domain
# automatically added to simple names in a hosts-file.
expand-hosts
# adds my localdomain to each dhcp host
domain=home
# my private dhcp range + subnetmask + 14d lease time
dhcp-range=192.168.178.10,192.168.178.99,255.255.255.0,14d
# set route to my local network router
dhcp-option=option:router,192.168.178.1
#windows 7 float fix
#http://brielle.sosdg.org/archives/522-Windows-7-flooding-DHCP-server-with-DHCPINFORM-messages.html
dhcp-option=252,"\n"
###### logging ############
# own logfile
log-facility=/var/log/dnsmasq.log
log-async
# log dhcp infos
log-dhcp
# debugging dns
#log-queries
DNSMASQCONF
service dnsmasq restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment