1 # Project Clearwater - IMS in the Cloud
2 # Copyright (C) 2015 Metaswitch Networks Ltd
4 # This program is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License as published by the
6 # Free Software Foundation, either version 3 of the License, or (at your
7 # option) any later version, along with the "Special Exception" for use of
8 # the program along with SSL, set forth below. This program is distributed
9 # in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 # A PARTICULAR PURPOSE. See the GNU General Public License for more
12 # details. You should have received a copy of the GNU General Public
13 # License along with this program. If not, see
14 # <http://www.gnu.org/licenses/>.
16 # The author can be reached by email at clearwater@metaswitch.com or by
17 # post at Metaswitch Networks Ltd, 100 Church St, Enfield EN2 6BQ, UK
20 # Metaswitch Networks Ltd grants you permission to copy, modify,
21 # propagate, and distribute a work formed by combining OpenSSL with The
22 # Software, or a work derivative of such a combination, even if such
23 # copying, modification, propagation, or distribution would otherwise
24 # violate the terms of the GPL. You must comply with the GPL in all
25 # respects for all of the code used other than OpenSSL.
26 # "OpenSSL" means OpenSSL toolkit software distributed by the OpenSSL
27 # Project and licensed under the OpenSSL Licenses, or a work based on such
28 # software and licensed under the OpenSSL Licenses.
29 # "OpenSSL Licenses" means the OpenSSL License and Original SSLeay License
30 # under which the OpenSSL Project distributes the OpenSSL toolkit software,
31 # as those licenses appear in the file LICENSE-OPENSSL.
33 heat_template_version: 2014-10-16
36 DNS server exposing dynamic DNS using DNSSEC
42 description: The VNF name provided by ONAP
46 description: The VNF ID provided by ONAP
50 description: The VNF module ID provided by ONAP
53 description: ID of public network
55 - custom_constraint: neutron.network
56 description: Must be a valid network ID
59 description: Name of server to use
62 description: Flavor to use
64 - custom_constraint: nova.flavor
65 description: Must be a valid flavor name
68 description: Name of image to use
71 description: Name of keypair to assign
73 - custom_constraint: nova.keypair
74 description: Must be a valid keypair name
80 description: DNSSEC private key (Base64-encoded)
85 type: OS::Heat::RandomString
90 type: OS::Neutron::SecurityGroup
92 description: security group
95 template: pre_base_rand
98 base: { get_param: vnf_name }
99 rand: { get_resource: dns_random_str }
101 {remote_ip_prefix: 0.0.0.0/0, protocol: tcp, port_range_min: 22, port_range_max: 22},
102 {remote_ip_prefix: 0.0.0.0/0, protocol: tcp, port_range_min: 53, port_range_max: 53},
103 {remote_ip_prefix: 0.0.0.0/0, protocol: udp, port_range_min: 53, port_range_max: 53},
104 {remote_ip_prefix: 0.0.0.0/0, protocol: icmp}]
107 type: OS::Neutron::Port
113 base: dns_admin_port_0
114 rand: { get_resource: dns_random_str }
115 network: { get_param: public_net_id }
116 security_groups: [{ get_resource: dns_security_group }]
119 type: OS::Nova::Server
123 template: pre_base_rand
126 base: { get_param: vnf_name }
127 rand: { get_resource: dns_random_str }
128 image: { get_param: dns_image_name }
129 flavor: { get_param: dns_flavor_name }
130 key_name: { get_param: key_name }
132 - port: { get_resource: dns_admin_port_0 }
133 metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }, vnf_name: { get_param: vnf_name }}
134 user_data_format: RAW
138 __zone__: { get_param: zone }
139 __dnssec_key__: { get_param: dnssec_key }
143 # Log all output to file.
144 exec > >(tee -a /var/log/clearwater-heat-dns.log) 2>&1
149 DEBIAN_FRONTEND=noninteractive apt-get install bind9 --yes
151 # Get the IP address from eth0
152 sudo apt-get install ipcalc
153 ADDR=`ip addr show eth0 | awk '/inet /{print $2}'`
154 PUBLIC_ADDR=`ipcalc -n -b $ADDR | awk '/Address:/{print $2}'`
156 # Update BIND configuration with the specified zone and key.
157 cat >> /etc/bind/named.conf.local << EOF
158 key __zone__. {properties
159 algorithm "HMAC-MD5";
160 secret "__dnssec_key__";
165 file "/var/lib/bind/db.__zone__";
172 # Function to give DNS record type and IP address for specified IP address
174 if echo $1 | grep -q -e '[^0-9.]' ; then
181 # Create basic zone configuration.
182 cat > /var/lib/bind/db.__zone__ << EOF
185 @ IN SOA ns admin\@__zone__. ( $(date +%Y%m%d%H) 1d 2h 1w 30s )
187 ns $(ip2rr $PUBLIC_ADDR)
189 chown root:bind /var/lib/bind/db.__zone__
191 # Now that BIND configuration is correct, kick it to reload.
197 description: IP address of DNS server
198 value: { get_attr: [ dns_server_0, networks, { get_param: public_net_id }, 0 ] }
200 description: DNS zone
201 value: { get_param: zone }
203 description: DNSSEC private key (Base64-encoded)
204 value: { get_param: dnssec_key }