openshift-origin-dns-bind 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
data/COPYRIGHT ADDED
@@ -0,0 +1 @@
1
+ Copyright 2012 Red Hat, Inc. and/or its affiliates.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ Notice of Export Control Law
2
+
3
+ This software distribution includes cryptographic software that is subject to the U.S. Export Administration Regulations (the "*EAR*") and other U.S. and foreign laws and may not be exported, re-exported or transferred (a) to any country listed in Country Group E:1 in Supplement No. 1 to part 740 of the EAR (currently, Cuba, Iran, North Korea, Sudan & Syria); (b) to any prohibited destination or to any end user who has been prohibited from participating in U.S. export transactions by any federal agency of the U.S. government; or (c) for use in connection with the design, development or production of nuclear, chemical or biological weapons, or rocket systems, space launch vehicles, or sounding rockets, or unmanned air vehicle systems.You may not download this software or technical information if you are located in one of these countries or otherwise subject to these restrictions. You may not provide this software or technical information to individuals or entities located in one of these countries or otherwise subject to these restrictions. You are also responsible for compliance with foreign law requirements applicable to the import, export and use of this software and technical information.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ #require "bundler/gem_tasks"
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'test'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ t.verbose = true
9
+ end
@@ -0,0 +1,441 @@
1
+ Running a service which adds new hostnames to the internet requires a
2
+ Dynamic DNS service. The openshift-origin-dns-bind package provides the client side
3
+ of service interface for a Dynamic DNS based on ISC BIND DNS (or any
4
+ other DNS service which honors RFC 2136 and 3007 dynamic update
5
+ queries). If you're running a self-contained service for development
6
+ or testing, you'll need to have a local DNS service capable of
7
+ accepting updates and responding to queries for your test zones while
8
+ passing all other requests through to your external DNS servers.
9
+
10
+ This document describes how to configure a DNS service on a
11
+ self-contained system so that it can accept updates for local zones
12
+ but does not interfere with normal system operation.
13
+
14
+ The initial steps assume that the host has a static IP address.
15
+ Additional steps to configure a system with an IP address provided by
16
+ DHCP follow.
17
+
18
+ * Install BIND
19
+ * Generate update keys
20
+ * Create initial test zone files
21
+ * Configure named
22
+ ** dnssec
23
+ ** forwarding
24
+ ** control key
25
+ ** update keys
26
+ ** test zones
27
+ * Start named service
28
+ ** Test local queries
29
+ ** Test remote queries
30
+ ** Test updates
31
+ * Enable named service
32
+ * Set resolver order
33
+ * DHCP updates
34
+ ** SELinux
35
+ *** Compiling policy module
36
+ *** Installing policy module
37
+ ** Disable NetworkManager service
38
+ ** Enable network service
39
+ ** dhclient hooks (update forwarders)
40
+ ** named.conf: include forwarders
41
+ ** dhclient config (resolver prefix)
42
+
43
+ * Summary
44
+
45
+ This procedure will add a local named service which will accept
46
+ updates using RFC compliant queries. A tool in bind-utils named
47
+ nsupdate can be used to send updates for testing. The openshift-origin-dns-bind
48
+ Ruby module uses rubygem-dnsruby to do the same thing.
49
+
50
+ For this procedure, we're going to use a target domain of
51
+ 'example.com'. This domain is set aside by RFC 2606 for just this
52
+ purpose. When it is done you will be able to query the example.com
53
+ domain and get local answers. You will also be able to update the
54
+ contents of the local example.com domain. Modify any instance of
55
+ 'example.com' in the procedure below if you wish to use another domain
56
+ for your configuration.
57
+
58
+ Nearly all of the commands below must be run as root or using sudo(8).
59
+
60
+ All other queries will be forwarded to the normal external DNS service.
61
+
62
+ * Install BIND
63
+
64
+ You should just be able to request the 'bind' package. The bind-utils
65
+ package is needed for verification and testing.
66
+
67
+ yum install bind bind-utils
68
+
69
+ * Generate update keys
70
+
71
+ There are several good sites that go into details about how to create
72
+ DNSSEC keys. See the references section. For now I'm just going to
73
+ give one example.
74
+
75
+ Note that dnssec-keygen needs a source of "entropy". If it appears to
76
+ hang, log onto the host with another session and type or execute a few
77
+ commands until enough entropy has been generated to complete the key
78
+ generation.
79
+
80
+ dnssec-keygen -a HMAC-MD5 -b 512 -n USER example.com.
81
+
82
+ This will produce two files who's names look something like this:
83
+
84
+ Kexample.com.+157+30572.key
85
+ Kexample.com.+157+30572.private
86
+
87
+ The key string is in both files but you can extract it most easily
88
+ like this:
89
+
90
+ grep Key: Kexample.com.*.private | cut -d' ' -f 2
91
+
92
+ (assuming you only have one private key file in your current working directory)
93
+
94
+ Copy the files to /var/named for safe keeping. We'll need the key
95
+ string later for configuring /etc/named.conf
96
+
97
+ * Create initial test zone files
98
+
99
+ DNS updates have to be sent to a specific zone. You need to have the
100
+ example.com zone configured into your local named as a dynamic zone.
101
+ There is a sample initial example.com.db file included in this
102
+ directory.
103
+
104
+ One thing to note is that the example has the default TTL value set to
105
+ 1 second. This is to avoid testing errors caused by caching. If the
106
+ TTL is larger then changes will not be reflected until the record
107
+ times out. As it is, delete test queries should wait 2 seconds after
108
+ the delete operation completes to be sure to get a correct answer. You
109
+ would never use this value in production.
110
+
111
+ * Configure named
112
+
113
+ The master configuration file for ISC BIND named is /etc/named.conf.
114
+ There is an example in the directory which contains this README.
115
+ There are several significant settings in that file which bear
116
+ pointing out.
117
+
118
+ ** forwarding
119
+
120
+ The local server must be set to forward only. While recursion is
121
+ enabled, it will not be used. Requests for zones which are not
122
+ locally authoritative (basically everything but example.com) will be
123
+ forwarded to the upstream DNS server.
124
+
125
+ The forwarders clause in the configuration will be included from a
126
+ file named /var/named/forwarders.conf. This will allow you to update
127
+ the forwarders without editing the named.conf itself. This will
128
+ become important if you're getting your primary IP address from DHCP.
129
+
130
+ The forwarders section consists of the forwarders keyword and a block
131
+ of semi-colon terminated IP addresses. These addresses should be the
132
+ addresses you would normally have in your /etc/resolv.conf nameserver
133
+ list.
134
+
135
+ forwarders { <ip address 1> [ ; <ip address N ]... ; } ;
136
+
137
+ For now you can create /var/named/forwarders.conf by hand.
138
+
139
+ ** update keys
140
+
141
+ Each dynamic zone requires an associated update key. The nameserver
142
+ and client each have a copy of the same key. The keys have an id and
143
+ a value. The id is the string provided at the end of the
144
+ dnssec-keygen(8) command above and the value is the string we
145
+ extracted from the K*.private file.
146
+
147
+ The sample named.conf file includes the key configuration from a file
148
+ called 'example.com.key'.
149
+
150
+ include "example.com.key";
151
+
152
+ The key file contains the key definition section which looks like this:
153
+
154
+ key example.com {
155
+ algorithm HMAC-MD5 ;
156
+ secret "<key string>" ;
157
+ } ;
158
+
159
+ Substitute the key string from the private key file generated eariler
160
+ and place the key file in /var/named/example.com.key.
161
+
162
+ ** test zones
163
+
164
+ The test zones are set in the /etc/named.conf file with a zone
165
+ section. The zone file itself was describe above. Here we specify the
166
+ type of zone, the zone file location and the fact that it can be
167
+ updated using the key included in the previous section.
168
+
169
+ The sample named.conf has a zone section for the example.com zone:
170
+
171
+ zone "example.com" IN {
172
+ type master;
173
+ file "dynamic/example.com.db";
174
+ allow-update { key example.com ; } ;
175
+ };
176
+
177
+ * Start named service
178
+
179
+ First, you want to test that the configuration files are valid and
180
+ free of typos. You can start a named manually and observe the startup
181
+ using the -g option:
182
+
183
+ /usr/sbin/named -g
184
+
185
+ If there are any errors, check the log output and the contents of
186
+ /var/log/messages for syntax and configuration errors.
187
+
188
+ When you're satisfied that the configuration is correct, interrupt the
189
+ named with CTRL-C and start it as a proper service:
190
+
191
+ service named start
192
+
193
+ ** Test local queries
194
+
195
+ Once the named is running you can check that it is responding to
196
+ queries. The tools for that are in the bind-utils RPM. Install that
197
+ if you haven't yet. The two tools for testing ordinary queries are
198
+ dig(1) and host(1). Dig gives more detailed output and does not use
199
+ the domain or search lines from /etc/resolv.conf. You have to provide
200
+ fully qualified domain names for queries. Host gives more compact
201
+ simple output and does use resolv.conf to complete partial names.
202
+
203
+ Because the resolv.conf does not yet have 127.0.0.1 as the first
204
+ nameserver you have to specify the nameserver on the query command
205
+ line.
206
+
207
+ dig @127.0.0.1 example.com soa
208
+
209
+ host -t soa example.com 127.0.0.1
210
+
211
+ Those will show the Start Of Authority records for the example.com
212
+ zone. They should reflect the values in your local zone. Compare
213
+ them to the values you get from the same query on a host using normal
214
+ DNS.
215
+
216
+ ** Test remote queries
217
+
218
+ With forwarders configured, you should also be able to get responses
219
+ for zones outside your test zone.
220
+
221
+ dig @127.0.0.1 icann.org a
222
+
223
+ host -t a icann.org 127.0.0.1
224
+
225
+ These should complete promptly and show the normal IP address values.
226
+
227
+ ** Test updates
228
+
229
+ Update testing uses another tool from bind-utils named nsupdate(1).
230
+ nsupdate takes its input from standard input. It also requires the
231
+ key for authentication. You can test adding a record like this: (note
232
+ the extra spaces in the indentation of the example)
233
+
234
+ nsupdate -k /var/named/example.com.key <<EOF
235
+ server 127.0.0.1
236
+ update add testaddr.example.com 1 A 192.168.254.254
237
+ send
238
+ quit
239
+ EOF
240
+
241
+ following successful completion of that command you should be able to
242
+ query with dig(1) or host(1) and verify that the new record is there.
243
+
244
+ dig @127.0.0.1 testhost.example.com a
245
+
246
+ * Enable named service
247
+
248
+ When you're satsfied that the service is running and responding
249
+ correctly you can enable the system service so that it restarts on
250
+ reboot:
251
+
252
+ chkconfig named on
253
+
254
+ * Set resolver order
255
+
256
+ The final step to integrating the local named is to make it the
257
+ first nameserver in your resolver list. Once this is done all
258
+ queries will go to the local named first by default.
259
+
260
+ Add the following line to your /etc/resolv.conf file before any
261
+ other nameserver lines:
262
+
263
+ nameserver 127.0.0.1
264
+
265
+ * DHCP updates
266
+
267
+ For a self-contained service which would be typical for testing, or
268
+ for a virtual host environment like EC2 it is possible that the DNS
269
+ host will get it's IP address and DNS information from DHCP. In that
270
+ case each time the host renews it's DHCP lease it will overwrite the
271
+ /etc/resolv.conf file. It may also change its upstream nameserver
272
+ list. If that happens, the forwarders list for the named must also
273
+ change.
274
+
275
+ dhclient is the daemon that maintains DHCP controlled interfaces. It
276
+ has hooks which can be used to run scripts triggered on lease
277
+ renewals. However in RHEL and Fedora distributions the current
278
+ default manager for interfaces is NetworkManager. NetworkManager is
279
+ designed mostly for mobile device users and does not seem to provide
280
+ access to the kinds of control hooks that dhclient does.
281
+
282
+ To provide the control needed we're doing to disable NetworkManager
283
+ and let interface control fall back to the more primative network
284
+ service and the dhclient daemon.
285
+
286
+ Note that the forwarders update below will fail if you have SELinux
287
+ enabled. If you're running with SELinux disabled skip down past the SELinux
288
+ instructions.
289
+
290
+ If you consider it safe you can temporarily suspend SELinux and
291
+ re-enable it later.
292
+
293
+ setenforce 0
294
+
295
+ ** SELinux
296
+
297
+ If you are running your host with SELinux enabled then the dhclient
298
+ service will not have permission to write any file which the named
299
+ service has permission to read. You will need to extend the SELinux
300
+ policy to allow the dhclient-up-hooks script to write the
301
+ /var/named/forwarders.conf file and make it readable.
302
+
303
+ To compile and load the new policy you will need the selinux-policy
304
+ and policycoreutils RPMs installed. If you have SELinux enabled you
305
+ will certainly already have the selinux-policy package. You may still
306
+ need to install policycoreutils.
307
+
308
+ yum install selinux-policy policycoreutils
309
+
310
+ The examples directory contains two files which define a policy update that
311
+ does just that:
312
+
313
+ dhcpnamedforward.te
314
+ dhcpnamedforward.fc
315
+
316
+ The first is a set of new policy rules. The second defines the
317
+ default label for the /var/named/forwarders.conf file so that the
318
+ rules will apply.
319
+
320
+ *** Compiling policy module
321
+
322
+ Copy the policy files to /usr/share/selinux/packages.
323
+
324
+ Compile the policy module:
325
+
326
+ cd /usr/share/selinux/packages
327
+ make -f /usr/share/selinux/devel/Makefile
328
+
329
+ This will generate two additional files.
330
+
331
+ dhcpnamedforward.if
332
+ dhcpnamedforward.pp
333
+
334
+ The .if file is an empty "interface" template and can be ignored.
335
+
336
+ The .pp file is the compiled policy. This is what gets loaded.
337
+
338
+ *** Installing policy module
339
+
340
+ To load the policy module use semodule(8)
341
+
342
+ semodule -i /usr/share/selinux/packages/dhcpnamedforward.pp
343
+
344
+ This could take a couple of minutes. When it completes, check that
345
+ the module is installed:
346
+
347
+ semodule -l | grep dhcpnamedforward
348
+
349
+ At this point SELinux should allow the dhclient-up-hooks script to
350
+ write /var/named/forwarders.conf and the named service to read it.
351
+
352
+ ** Disable NetworkManager service
353
+
354
+ Attempt to disable NetworkManager service:
355
+
356
+ chkconfig NetworkManager off
357
+
358
+ If you get any errors it's likely that you don't have NetworkManager
359
+ installed and life is good.
360
+
361
+ Then enable the generic "network" service
362
+
363
+ chkconfig network on
364
+
365
+ And change any interfaces that think they're controlled by
366
+ NetworkManager and change them over:
367
+
368
+ grep -l NM_CONTROLLED /etc/sysconfig/network-scripts/ifcfg-* | \
369
+ xargs perl -p -i -e '/NM_CONTROLLED/ && s/yes/no/i'
370
+
371
+ ** dhclient config (resolver prefix)
372
+
373
+ As noted earlier, dhclient will rewrite the /etc/resolv.conf file each
374
+ time it renews the DHCP lease. You can configure it to put a value
375
+ before the other nameserver lines. Create a file named
376
+ /etc/dhcp/dhclient.conf and put this in it:
377
+
378
+ # prepend localhost for DNS lookup in dev and test
379
+ prepend domain-name-servers 127.0.0.1 ;
380
+
381
+ ** dhclient hooks (update forwarders)
382
+
383
+ dhclient also has the capability to run a script when an interface
384
+ comes up. If you place a bourne shell script at
385
+ /etc/dhcp/dhclient-up-hooks and make sure it's readable and
386
+ *executable* then it will be sourced when any interface renews its
387
+ lease.
388
+
389
+ The dhclient-up-hooks script in the directory which contains this
390
+ README will create a file named /var/named/forwarders.conf on lease
391
+ renew.
392
+
393
+ ** named.conf: include forwarders
394
+
395
+ If you followed the instructions initially your /etc/named.conf file
396
+ already includes the /var/named/forwarders.conf to set the forwarders
397
+ list. If not, do it now.
398
+
399
+ ** renewing the interface
400
+
401
+ Now if you force the external interface to renew (do this while logged
402
+ in via serial console!) you should be able to watch the forwarders be
403
+ updated and the named reloaded to get the update
404
+
405
+ service network restart
406
+
407
+ If you get an error or you don't see the timestamp change on
408
+ /var/named/forwarders.conf then check the execute bit on
409
+ /etc/dhcp/dhclient-up-hooks.
410
+
411
+ * References
412
+
413
+ - RFC 2136 Dynamic Updates in the Domain Name System (DNS UPDATE)
414
+ http://tools.ietf.org/rfc/rfc2136.txt
415
+
416
+ - RFC 2606 Reserved Top Level DNS Names
417
+ http://tools.ietf.org/rfc/rfc2606.txt
418
+
419
+ - RFC 3007 Secure Domain Name System (DNS) Dynamic Update
420
+ http://tools.ietf.org/rfc/rfc3007.txt
421
+
422
+ - Article: Painless Dynamic DNS,
423
+ Copyright © 2008 Jeff Garzik
424
+ http://linux.yyz.us/nsupdate/
425
+
426
+ - Article: Painless DDNS part 2: the server
427
+ Copyright © 2008 Jeff Garzik
428
+ http://linux.yyz.us/dns/ddns-server.html
429
+
430
+ - dhclient-script(8) man page
431
+ http://linux.die.net/man/8/dhclient-script
432
+
433
+
434
+ - ISC BIND documentation
435
+ http://www.isc.org/software/bind/documentation
436
+
437
+ - A step-by-step guide to building a new SELinux policy module,
438
+ Dan Walsh, Copyright © 2012 Red Hat, Inc.
439
+
440
+ - SELinux reference policy
441
+ http://oss.tresys.com/projects/refpolicy
@@ -0,0 +1,10 @@
1
+ $TTL 1 ; ONLY THIS SHORT FOR TESTING, changes are cached this long
2
+ $ORIGIN 0.168.192.IN-ADDR.ARPA.
3
+ @ 1D IN SOA ns1.example.com. mymail.example.com. (
4
+ 2002022401 ; serial
5
+ 3H ; refresh
6
+ 15 ; retry
7
+ 1w ; expire
8
+ 3h ; minimum
9
+ )
10
+ ; server host definitions
@@ -0,0 +1 @@
1
+ example.com. IN KEY 0 3 157 lOuqTjZbxrFwOodiqXMcBQ8J5bGNvU6xUgOQxOohSRmiSi49P56x/wVN d/0kqmLvUxjt3qzx0lVCsFnxaRgg7g==
@@ -0,0 +1,7 @@
1
+ Private-key-format: v1.3
2
+ Algorithm: 157 (HMAC_MD5)
3
+ Key: lOuqTjZbxrFwOodiqXMcBQ8J5bGNvU6xUgOQxOohSRmiSi49P56x/wVNd/0kqmLvUxjt3qzx0lVCsFnxaRgg7g==
4
+ Bits: AAA=
5
+ Created: 20120327235602
6
+ Publish: 20120327235602
7
+ Activate: 20120327235602
@@ -0,0 +1,44 @@
1
+ #!/bin/sh
2
+ #
3
+ # This file is sourced using (.) by /sbin/dhclient-script after the eth0
4
+ # interface is brought up.
5
+ #
6
+ # The code here creates a file named /var/named/forwarders.conf containing
7
+ # the nameservers listed in the DHCP response.
8
+ # This allows the local named to properly respond to queries for both local
9
+ # and remote zones.
10
+
11
+ # The environment is inherited from the context in the dhclient-script at the
12
+ # time when this file is sourced.
13
+
14
+ # The file operations here require the dhcpnamedforward SELinux module to
15
+ # succeed. If the file write fails, check that the policy is loaded.
16
+ #
17
+
18
+ FORWARD_CONF=${FORWARD_CONF:="/var/named/forwarders.conf"}
19
+
20
+ if [ -n "$new_domain_name_servers" ]
21
+ then
22
+ # remove the localhost reference if it's provided
23
+ NAME_SERVER_LIST=`echo ${new_domain_name_servers} | sed -e 's/127.0.0.1 *//g'`
24
+ logmessage "NAME_SERVER_LIST ${NAME_SERVER_LIST}"
25
+ FORWARDERS=""
26
+ for i in $NAME_SERVER_LIST; do
27
+ FORWARDERS="${FORWARDERS} $i ; "
28
+ done
29
+ FORWARDERS="${FORWARDERS} 8.8.8.8 ; 8.8.4.4 ;"
30
+ logmessage "set forwarders: ${FORWARDERS}"
31
+ cat > ${FORWARD_CONF} <<EOF
32
+ // created by /etc/dhcp/dhclient-up-hooks
33
+ // set named forwarders from the DHCP supplied name server list
34
+ forwarders { ${FORWARDERS} } ;
35
+ EOF
36
+
37
+ # reload the named configuration if needed
38
+ if service named status 2>&1 >/dev/null
39
+ then
40
+ service named reload
41
+ fi
42
+ else
43
+ logmessage "no new name servers provided by DHCP"
44
+ fi
@@ -0,0 +1,3 @@
1
+ # prepend localhost for DNS lookup in dev and test
2
+ # still bypassing local DNS - MAL 20120302
3
+ prepend domain-name-servers 127.0.0.1;
@@ -0,0 +1 @@
1
+ /var/named/forwarders.conf -- gen_context(system_u:object_r:named_forward_file_t,s0)
@@ -0,0 +1,26 @@
1
+ policy_module(dhcpnamedforward,0.0.10)
2
+
3
+ require {
4
+ type dhcpc_t;
5
+ type named_t;
6
+ type named_zone_t;
7
+ type named_initrc_exec_t;
8
+ type httpd_t;
9
+ }
10
+
11
+ # Create the new type
12
+ type named_forward_file_t;
13
+ files_type(named_forward_file_t)
14
+
15
+ filetrans_pattern(dhcpc_t, named_zone_t, named_forward_file_t, file)
16
+ manage_files_pattern(dhcpc_t, named_forward_file_t, named_forward_file_t)
17
+
18
+ allow named_t named_forward_file_t:file { getattr open read };
19
+ init_labeled_script_domtrans(dhcpc_t, named_initrc_exec_t)
20
+ #allow dhcpc_t named_initrc_exec_t:file { getattr execute };
21
+
22
+ ifdef(`corenet_udp_bind_all_ephemeral_ports',`
23
+ corenet_udp_bind_all_ephemeral_ports(named_t)
24
+ ')
25
+ corenet_udp_bind_all_unreserved_ports(named_t)
26
+ corenet_udp_bind_all_ports(httpd_t)
@@ -0,0 +1,14 @@
1
+ $ORIGIN .
2
+ $TTL 1 ; 1 seconds (for testing only)
3
+ example.com IN SOA ns1.example.com. hostmaster.example.com. (
4
+ 2011112904 ; serial
5
+ 60 ; refresh (1 minute)
6
+ 15 ; retry (15 seconds)
7
+ 1800 ; expire (30 minutes)
8
+ 10 ; minimum (10 seconds)
9
+ )
10
+ NS ns1.example.com.
11
+ MX 10 mail.example.com.
12
+ $ORIGIN example.com.
13
+ ns1 A 127.0.0.1
14
+
@@ -0,0 +1,50 @@
1
+ // named.conf
2
+ //
3
+ // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
4
+ // server as a caching only nameserver (as a localhost DNS resolver only).
5
+ //
6
+ // See /usr/share/doc/bind*/sample/ for example named configuration files.
7
+ //
8
+
9
+ options {
10
+ listen-on port 53 { any; };
11
+ listen-on port 953 { any; };
12
+ directory "/var/named";
13
+ dump-file "/var/named/data/cache_dump.db";
14
+ statistics-file "/var/named/data/named_stats.txt";
15
+ memstatistics-file "/var/named/data/named_mem_stats.txt";
16
+ allow-query { any; };
17
+ recursion yes;
18
+
19
+ /* Path to ISC DLV key */
20
+ bindkeys-file "/etc/named.iscdlv.key";
21
+
22
+ // set forwarding to the next nearest server (from DHCP response
23
+ forward only;
24
+ include "forwarders.conf";
25
+ };
26
+
27
+ logging {
28
+ channel default_debug {
29
+ file "data/named.run";
30
+ severity dynamic;
31
+ };
32
+ };
33
+
34
+ // use the default rndc key
35
+ include "/etc/rndc.key";
36
+
37
+ controls {
38
+ inet 127.0.0.1 port 953
39
+ allow { 127.0.0.1; } keys { "rndc-key"; };
40
+ };
41
+
42
+ include "/etc/named.rfc1912.zones";
43
+
44
+ include "example.com.key";
45
+
46
+ zone "example.com" IN {
47
+ type master;
48
+ file "dynamic/example.com.db";
49
+ allow-update { key example.com ; } ;
50
+ };
@@ -0,0 +1,10 @@
1
+ require "openshift-origin-common"
2
+
3
+ module OpenShift
4
+ module BindDnsModule
5
+ require 'openshift-origin-dns-bind/engine/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
6
+ end
7
+ end
8
+
9
+ require "openshift-origin-dns-bind/lib/openshift/bind_plugin.rb"
10
+ OpenShift::DnsService.provider=OpenShift::BindPlugin
@@ -0,0 +1,5 @@
1
+ BIND_SERVER="127.0.0.1"
2
+ BIND_PORT=53
3
+ BIND_KEYNAME="example.com"
4
+ BIND_KEYVALUE="base64-encoded key, most likely from /var/named/example.com.key."
5
+ BIND_ZONE="example.com"
@@ -0,0 +1,14 @@
1
+ require 'openshift-origin-common/config'
2
+
3
+ Broker::Application.configure do
4
+ conf = OpenShift::Config.new(File.join(OpenShift::Config::PLUGINS_DIR, File.basename(__FILE__, '.rb') + '.conf'))
5
+ defaults = OpenShift::Config.new(File.join(File.dirname(__FILE__), File.basename(__FILE__, '.rb') + '-defaults.conf'))
6
+
7
+ config.dns = {
8
+ :server => conf.get("BIND_SERVER") || defaults.get("BIND_SERVER"),
9
+ :port => (conf.get("BIND_PORT") || defaults.get("BIND_PORT")).to_i,
10
+ :keyname => conf.get("BIND_KEYNAME") || defaults.get("BIND_KEYNAME"),
11
+ :keyvalue => conf.get("BIND_KEYVALUE") || defaults.get("BIND_KEYVALUE"),
12
+ :zone => conf.get("BIND_ZONE") || defaults.get("BIND_ZONE")
13
+ }
14
+ end
@@ -0,0 +1,10 @@
1
+ require 'openshift-origin-controller'
2
+ require 'rails'
3
+
4
+ module OpenShift
5
+ class BindDnsEngine < Rails::Engine
6
+ paths.lib << "lib/openshift-origin-bind-dns/lib"
7
+ paths.config << "lib/openshift-origin-bind-dns/config"
8
+ config.autoload_paths += %W(#{config.root}/lib)
9
+ end
10
+ end
@@ -0,0 +1,123 @@
1
+ #
2
+ # Make OpenShift updates to a BIND DNS service
3
+ #
4
+ require 'rubygems'
5
+ require 'dnsruby'
6
+
7
+ module OpenShift
8
+ class BindPlugin < OpenShift::DnsService
9
+ @oo_dns_provider = OpenShift::BindPlugin
10
+
11
+ # DEPENDENCIES
12
+ # Rails.application.config.openshift[:domain_suffix]
13
+ # Rails.application.config.dns[...]
14
+
15
+ attr_reader :server, :port, :keyname, :keyvalue
16
+
17
+ def initialize(access_info = nil)
18
+ if access_info != nil
19
+ @domain_suffix = access_info[:domain_suffix]
20
+ elsif defined? Rails
21
+ # extract from Rails.application.config[dns,ss]
22
+ access_info = Rails.application.config.dns
23
+ @domain_suffix = Rails.application.config.openshift[:domain_suffix]
24
+ else
25
+ raise Exception.new("BIND DNS service is not initialized")
26
+ end
27
+ @server = access_info[:server]
28
+ @port = access_info[:port].to_i
29
+ @src_port = access_info[:src_port].to_i if access_info[:src_port].to_i
30
+ @keyname = access_info[:keyname]
31
+ @keyvalue = access_info[:keyvalue]
32
+ @zone = access_info[:zone]
33
+ end
34
+
35
+ def dns
36
+ if not @dns_con
37
+ @dns_con = Dnsruby::Resolver.new(:nameserver => @server, :port => @port)
38
+ @dns_con.src_port = @src_port if @src_port
39
+ end
40
+ @dns_con
41
+ end
42
+
43
+ def namespace_available?(namespace)
44
+ fqdn = "#{namespace}.#{@domain_suffix}"
45
+
46
+ # If we get a response, then the namespace is reserved
47
+ # An exception means that it is available
48
+ begin
49
+ dns.query(fqdn, Dnsruby::Types::TXT)
50
+ return false
51
+ rescue Dnsruby::NXDomain
52
+ return true
53
+ end
54
+ end
55
+
56
+ def register_namespace(namespace)
57
+ # create a TXT record for the namespace in the domain
58
+ fqdn = "#{namespace}.#{@domain_suffix}"
59
+ # enable updates with key
60
+ dns.tsig = @keyname, @keyvalue
61
+
62
+ update = Dnsruby::Update.new(@zone)
63
+ # update.absent(fqdn, 'TXT')
64
+ update.add(fqdn, 'TXT', 60, "Text record for #{namespace}")
65
+ dns.send_message(update)
66
+ end
67
+
68
+ def deregister_namespace(namespace)
69
+ # create a TXT record for the namespace in the domain
70
+ fqdn = "#{namespace}.#{@domain_suffix}"
71
+ # enable updates with key
72
+ dns.tsig = @keyname, @keyvalue
73
+
74
+ update = Dnsruby::Update.new(@zone)
75
+ update.delete(fqdn, 'TXT')
76
+ dns.send_message(update)
77
+ end
78
+
79
+ def register_application(app_name, namespace, public_hostname)
80
+ # create an A record for the application in the domain
81
+ fqdn = "#{app_name}-#{namespace}.#{@domain_suffix}"
82
+ # enable updates with key
83
+ dns.tsig = @keyname, @keyvalue
84
+
85
+ update = Dnsruby::Update.new(@zone)
86
+ update.add(fqdn, 'CNAME', 60, public_hostname)
87
+ dns.send_message(update)
88
+ end
89
+
90
+ def deregister_application(app_name, namespace)
91
+ begin
92
+ # delete the CNAME record for the application in the domain
93
+ fqdn = "#{app_name}-#{namespace}.#{@domain_suffix}"
94
+
95
+ # We know we only have one CNAME per app, so look it up
96
+ # We need it for the delete
97
+ # should be an error if there's not exactly one answer
98
+ current = dns.query(fqdn, 'CNAME')
99
+ cnamevalue = current.answer[0].rdata.to_s
100
+
101
+ # enable updates with key
102
+ dns.tsig = @keyname, @keyvalue
103
+ update = Dnsruby::Update.new(@zone)
104
+ update_response = update.delete(fqdn, 'CNAME', cnamevalue)
105
+ send_response = dns.send_message(update)
106
+ rescue Dnsruby::NXDomain
107
+ Rails.logger.debug "DEBUG: BIND: Could not find CNAME for #{fqdn} to delete"
108
+ end
109
+ end
110
+
111
+ def modify_application(app_name, namespace, public_hostname)
112
+ deregister_application(app_name, namespace)
113
+ register_application(app_name, namespace, public_hostname)
114
+ end
115
+
116
+ def publish
117
+ end
118
+
119
+ def close
120
+ end
121
+
122
+ end
123
+ end
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ lib_dir = File.join(File.join("lib", "**"), "*")
4
+ test_dir = File.join(File.join("test", "**"), "*")
5
+ bin_dir = File.join("bin", "*")
6
+ doc_dir = File.join(File.join("doc", "**"), "*")
7
+ spec_file = "rubygem-openshift-origin-dns-bind.spec"
8
+
9
+ Gem::Specification.new do |s|
10
+ s.name = "openshift-origin-dns-bind"
11
+ s.version = `rpm -q --qf "%{version}\n" --specfile #{spec_file}`.split[0]
12
+ s.license = `rpm -q --qf "%{license}\n" --specfile #{spec_file}`.split[0]
13
+ s.authors = ["Krishna Raman"]
14
+ s.email = ["kraman@gmail.com"]
15
+ s.homepage = `rpm -q --qf "%{url}\n" --specfile #{spec_file}`.split[0]
16
+ s.summary = `rpm -q --qf "%{description}\n" --specfile #{spec_file}`.split[0]
17
+ s.description = `rpm -q --qf "%{description}\n" --specfile #{spec_file}`.split[0]
18
+
19
+ s.rubyforge_project = "openshift-origin-dns-bind"
20
+
21
+ s.files = Dir[lib_dir] + Dir[doc_dir]
22
+ s.test_files = Dir[test_dir]
23
+ s.executables = Dir[bin_dir]
24
+ s.files += %w(README.md Rakefile Gemfile rubygem-openshift-origin-dns-bind.spec openshift-origin-dns-bind.gemspec LICENSE COPYRIGHT)
25
+ s.require_paths = ["lib"]
26
+
27
+ s.add_dependency('openshift-origin-controller')
28
+ s.add_dependency('json')
29
+ s.add_dependency('dnsruby')
30
+ s.add_development_dependency('rake')
31
+ s.add_development_dependency('rspec')
32
+ s.add_development_dependency('bundler')
33
+ s.add_development_dependency('mocha')
34
+ end
@@ -0,0 +1,139 @@
1
+ %global ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
2
+ %global gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
3
+ %global gemname openshift-origin-dns-bind
4
+ %global geminstdir %{gemdir}/gems/%{gemname}-%{version}
5
+
6
+ Summary: OpenShift plugin for BIND service
7
+ Name: rubygem-%{gemname}
8
+ Version: 0.8.12
9
+ Release: 1%{?dist}
10
+ Group: Development/Languages
11
+ License: ASL 2.0
12
+ URL: http://openshift.redhat.com
13
+ Source0: rubygem-%{gemname}-%{version}.tar.gz
14
+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
15
+ Requires: ruby(abi) >= 1.8
16
+ Requires: rubygems
17
+ Requires: rubygem(openshift-origin-common)
18
+ Requires: rubygem(json)
19
+ Requires: bind
20
+ Requires: bind-utils
21
+ Requires: rubygem(dnsruby)
22
+ Requires: openshift-origin-broker
23
+ Requires: selinux-policy-targeted
24
+ Requires: policycoreutils-python
25
+ Obsoletes: rubygem-uplift-bind-plugin
26
+
27
+ BuildRequires: ruby
28
+ BuildRequires: rubygems
29
+ BuildArch: noarch
30
+ Provides: rubygem(%{gemname}) = %version
31
+
32
+ %package -n ruby-%{gemname}
33
+ Summary: OpenShift plugin for Bind service
34
+ Requires: rubygem(%{gemname}) = %version
35
+ Provides: ruby(%{gemname}) = %version
36
+
37
+ %description
38
+ Provides a Bind DNS service based plugin
39
+
40
+ %description -n ruby-%{gemname}
41
+ Provides a Bind DNS service based plugin
42
+
43
+ %prep
44
+ %setup -q
45
+
46
+ %build
47
+
48
+ %install
49
+ rm -rf %{buildroot}
50
+ mkdir -p %{buildroot}%{gemdir}
51
+ mkdir -p %{buildroot}%{ruby_sitelib}
52
+
53
+ # Build and install into the rubygem structure
54
+ gem build %{gemname}.gemspec
55
+ gem install --local --install-dir %{buildroot}%{gemdir} --force %{gemname}-%{version}.gem
56
+
57
+ # Symlink into the ruby site library directories
58
+ ln -s %{geminstdir}/lib/%{gemname} %{buildroot}%{ruby_sitelib}
59
+ ln -s %{geminstdir}/lib/%{gemname}.rb %{buildroot}%{ruby_sitelib}
60
+
61
+ # Add documents/examples
62
+ mkdir -p %{buildroot}%{_docdir}/%{name}-%{version}/
63
+ cp -r doc/* %{buildroot}%{_docdir}/%{name}-%{version}/
64
+
65
+ # Compile SELinux policy
66
+ mkdir -p %{buildroot}/usr/share/selinux/packages/rubygem-openshift-origin-dns-bind
67
+ cp %{buildroot}%{gemdir}/gems/openshift-origin-dns-bind-*/doc/examples/dhcpnamedforward.* %{buildroot}/usr/share/selinux/packages/rubygem-openshift-origin-dns-bind
68
+
69
+ %clean
70
+ rm -rf %{buildroot}
71
+
72
+ %files
73
+ %defattr(-,root,root,-)
74
+ %doc %{_docdir}/%{name}-%{version}
75
+ %dir %{geminstdir}
76
+ %doc %{geminstdir}/Gemfile
77
+ %{gemdir}/doc/%{gemname}-%{version}
78
+ %{gemdir}/gems/%{gemname}-%{version}
79
+ %{gemdir}/cache/%{gemname}-%{version}.gem
80
+ %{gemdir}/specifications/%{gemname}-%{version}.gemspec
81
+ /usr/share/selinux/packages/rubygem-openshift-origin-dns-bind
82
+
83
+ %files -n ruby-%{gemname}
84
+ %{ruby_sitelib}/%{gemname}
85
+ %{ruby_sitelib}/%{gemname}.rb
86
+
87
+ %changelog
88
+ * Tue Oct 23 2012 Brenton Leanhardt <bleanhar@redhat.com> 0.8.12-1
89
+ - removing remaining cases of SS and config.ss (dmcphers@redhat.com)
90
+ - Making openshift-origin-msg-broker-mcollective a Rails engine so that it can
91
+ hook into Rails initializers Making openshift-origin-dns-bind a Rails engine
92
+ so that it can hook into Rails initializers (kraman@gmail.com)
93
+
94
+ * Thu Oct 11 2012 Brenton Leanhardt <bleanhar@redhat.com> 0.8.11-1
95
+ - Centralize plug-in configuration (miciah.masters@gmail.com)
96
+
97
+ * Tue Oct 09 2012 Brenton Leanhardt <bleanhar@redhat.com> 0.8.10-1
98
+ - Merge pull request #613 from kraman/master (openshift+bot@redhat.com)
99
+ - Module name and gem path fixes for auth plugins (kraman@gmail.com)
100
+
101
+ * Mon Oct 08 2012 Dan McPherson <dmcphers@redhat.com> 0.8.9-1
102
+ - Fixing obsoletes for openshift-origin-port-proxy (kraman@gmail.com)
103
+
104
+ * Fri Oct 05 2012 Krishna Raman <kraman@gmail.com> 0.8.8-1
105
+ - new package built with tito
106
+
107
+ * Thu Aug 30 2012 Brenton Leanhardt <bleanhar@redhat.com> 0.8.7-1
108
+ - adding dnsruby dependency in bind plugin gemspec and spec file
109
+ (abhgupta@redhat.com)
110
+
111
+ * Mon Aug 20 2012 Brenton Leanhardt <bleanhar@redhat.com> 0.8.6-1
112
+ - gemspec refactorings based on Fedora packaging feedback (bleanhar@redhat.com)
113
+ - allow ruby versions > 1.8 (mlamouri@redhat.com)
114
+ - setup broker/nod script fixes for static IP and custom ethernet devices add
115
+ support for configuring different domain suffix (other than example.com)
116
+ Fixing dependency to qpid library (causes fedora package conflict) Make
117
+ livecd start faster by doing static configuration during cd build rather than
118
+ startup Fixes some selinux policy errors which prevented scaled apps from
119
+ starting (kraman@gmail.com)
120
+ - Removing requirement to disable NetworkManager so that liveinst works Adding
121
+ initial support for dual interfaces Adding "xhost +" so that liveinst can
122
+ continue to work after hostname change to broker.example.com Added delay
123
+ befor launching firefox so that network is stable Added rndc key generation
124
+ for Bind Dns plugin instead of hardcoding it (kraman@gmail.com)
125
+ - Add modify application dns and use where applicable (dmcphers@redhat.com)
126
+ - MCollective updates - Added mcollective-qpid plugin - Added mcollective-
127
+ msg-broker plugin - Added mcollective agent and facter plugins - Added
128
+ option to support ignoring node profile - Added systemu dependency for
129
+ mcollective-client (kraman@gmail.com)
130
+
131
+ * Wed May 30 2012 Krishna Raman <kraman@gmail.com> 0.8.5-1
132
+ - Adding livecd build scripts Adding a text only minimal version of livecd
133
+ Added ability to access livecd dns from outside VM (kraman@gmail.com)
134
+
135
+ * Fri Apr 27 2012 Krishna Raman <kraman@gmail.com> 0.8.4-1
136
+ - cleaning up spec files (dmcphers@redhat.com)
137
+
138
+ * Sat Apr 21 2012 Krishna Raman <kraman@gmail.com> 0.8.3-1
139
+ - new package built with tito
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openshift-origin-dns-bind
3
+ version: !ruby/object:Gem::Version
4
+ hash: 39
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 8
9
+ - 12
10
+ version: 0.8.12
11
+ platform: ruby
12
+ authors:
13
+ - Krishna Raman
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-10-23 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: openshift-origin-controller
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: json
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: dnsruby
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: rake
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :development
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: rspec
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ type: :development
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
92
+ name: bundler
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ type: :development
104
+ version_requirements: *id006
105
+ - !ruby/object:Gem::Dependency
106
+ name: mocha
107
+ prerelease: false
108
+ requirement: &id007 !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
116
+ version: "0"
117
+ type: :development
118
+ version_requirements: *id007
119
+ description: Provides
120
+ email:
121
+ - kraman@gmail.com
122
+ executables: []
123
+
124
+ extensions: []
125
+
126
+ extra_rdoc_files: []
127
+
128
+ files:
129
+ - lib/openshift-origin-dns-bind/engine/engine.rb
130
+ - lib/openshift-origin-dns-bind/config/initializers/openshift-origin-dns-bind.rb
131
+ - lib/openshift-origin-dns-bind/config/initializers/openshift-origin-dns-bind-defaults.conf
132
+ - lib/openshift-origin-dns-bind/lib/openshift/bind_plugin.rb
133
+ - lib/openshift-origin-dns-bind.rb
134
+ - doc/examples/Kexample.com.+157+37399.private
135
+ - doc/examples/192.168.0.reverse.db
136
+ - doc/examples/dhclient.conf
137
+ - doc/examples/dhcpnamedforward.te
138
+ - doc/examples/example.com.db
139
+ - doc/examples/Kexample.com.+157+37399.key
140
+ - doc/examples/dhcpnamedforward.fc
141
+ - doc/examples/dhclient-up-hooks
142
+ - doc/examples/named.conf
143
+ - doc/README.local_dns
144
+ - README.md
145
+ - Rakefile
146
+ - Gemfile
147
+ - rubygem-openshift-origin-dns-bind.spec
148
+ - openshift-origin-dns-bind.gemspec
149
+ - LICENSE
150
+ - COPYRIGHT
151
+ has_rdoc: true
152
+ homepage: http://openshift.redhat.com
153
+ licenses:
154
+ - ASL
155
+ post_install_message:
156
+ rdoc_options: []
157
+
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ hash: 3
166
+ segments:
167
+ - 0
168
+ version: "0"
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ none: false
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ hash: 3
175
+ segments:
176
+ - 0
177
+ version: "0"
178
+ requirements: []
179
+
180
+ rubyforge_project: openshift-origin-dns-bind
181
+ rubygems_version: 1.3.7
182
+ signing_key:
183
+ specification_version: 3
184
+ summary: Provides
185
+ test_files: []
186
+