#!/bin/bash # dnsmasq DNS server with cache installation on Raspbian # # Copyleft 2017 by Ignacio Nunez Hernanz # GPL licensed (see end of file) * Use at your own risk! # # Usage: # # ./installer.sh dnsmasq.sh () # # See installer.sh instructions for details # More at: https://ownyourbits.com/2017/03/09/dnsmasq-as-dns-cache-server-for-nextcloudpi-and-raspbian/ # ACTIVE_=no DOMAIN_=mycloud.ownyourbits.com DNSSERVER_=8.8.8.8 CACHESIZE_=150 DESCRIPTION="DNS server with cache" show_info() { whiptail --yesno \ --backtitle "NextCloudPi configuration" \ --title "Info" \ "Remember to point your PC and devices DNS to your Raspberry Pi IP" \ 20 90 } install() { apt-get update apt-get install --no-install-recommends -y dnsmasq update-rc.d dnsmasq disable } configure() { [[ $ACTIVE_ != "yes" ]] && { service dnsmasq stop; update-rc.d dnsmasq disable; return; } local IFACE=$( ip r | grep "default via" | awk '{ print $5 }' ) local IP=$( ip a | grep "global $IFACE" | grep -oP '\d{1,3}(\.\d{1,3}){3}' | head -1 ) [[ "$IP" == "" ]] && { echo "could not detect IP"; return 1; } cat > /etc/dnsmasq.conf <