#!/bin/sh # # only doing all the sudos as cloud-init doesn't run as root, likely better to use Azure VM Extensions # # $1 is the forwarder, $2 is the vnet IP range # touch /tmp/forwarderSetup_start echo "$@" > /tmp/forwarderSetup_params # Install Bind9 # https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-caching-or-forwarding-dns-server-on-ubuntu-14-04 sudo apt-get update -y sudo apt-get install bind9 bind9utils -y # configure Bind9 for forwarding sudo cat > named.conf.options << EndOFNamedConfOptions acl goodclients { $2; localhost; localnets; }; options { directory "/var/cache/bind"; recursion yes; allow-query { goodclients; }; forwarders { $1; }; forward only; dnssec-validation auto; auth-nxdomain no; # conform to RFC1035 listen-on { any; }; }; EndOFNamedConfOptions sudo cp named.conf.options /etc/bind sudo service bind9 restart touch /tmp/forwarderSetup_end