-
Notifications
You must be signed in to change notification settings - Fork 0
/
forwarderSetup.sh
47 lines (36 loc) · 1.02 KB
/
forwarderSetup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/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 -y
# configure Bind9 for forwarding
sudo cat > named.conf.options << EndOFNamedConfOptions
acl goodclients {
172.16.0.0/24
$2;
localhost;
localnets;
};
options {
directory "/var/cache/bind";
recursion yes;
allow-query { goodclients; };
forwarders {
$1;
};
forward only;
dnssec-validation no; # needed for private dns zones
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