]> gitweb.fluxo.info Git - puppet-shorewall.git/commitdiff
Allow redirecting DNS requests to Tor for specific users or globally.
authorintrigeri <intrigeri@boum.org>
Sat, 7 Jan 2012 14:23:47 +0000 (15:23 +0100)
committerintrigeri <intrigeri@boum.org>
Sun, 11 Nov 2012 22:11:17 +0000 (23:11 +0100)
README
manifests/init.pp
manifests/rules/torify/redirect_dns_to_tor.pp [new file with mode: 0644]

diff --git a/README b/README
index 648eaf7744a02955683d635f54c459c540e6679a..816ed48370fdcf600ee64390d53077d2d7be2905 100644 (file)
--- a/README
+++ b/README
@@ -107,7 +107,18 @@ rejected. This is intentional: it does not make sense leaking -via DNS
 requests- network activity that would otherwise be torified. In that
 case you probably want to read proper documentation about such
 matters, enable the Tor DNS resolver and redirect DNS requests through
-it.
+it,
+
+either globally:
+
+  shorewall::rules::torify::redirect_dns_to_tor { '-': }
+
+or for specific users:
+
+  shorewall::rules::torify::redirect_dns_to_tor { ['bob', 'alice' ]: }
+
+The $tor_dns_host and $tor_dns_port variables must be set before
+these defines are setup.
 
 Example
 -------
index f69a6f26c12f2478c489bdb5ea4c5fce2fdf6cc4..5c9b602f6be88877f4f09e80fddf48242cde8b84 100644 (file)
@@ -28,6 +28,12 @@ class shorewall {
   case $tor_transparent_proxy_port {
     '': { $tor_transparent_proxy_port = '9040' }
   }
+  case $tor_dns_host {
+    '': { $tor_dns_host = '127.0.0.1' }
+  }
+  case $tor_dns_port {
+    '': { $tor_dns_port = '8853' }
+  }
   if $tor_user == '' {
     $tor_user = $dist_tor_user ? {
       ''      => 'tor',
diff --git a/manifests/rules/torify/redirect_dns_to_tor.pp b/manifests/rules/torify/redirect_dns_to_tor.pp
new file mode 100644 (file)
index 0000000..9c71204
--- /dev/null
@@ -0,0 +1,38 @@
+define shorewall::rules::torify::redirect_dns_to_tor() {
+
+  $user = $name
+
+  $destzone = $shorewall::tor_dns_host ? {
+    '127.0.0.1' => '$FW',
+    default     => 'net'
+  }
+
+  $tcp_rule = "redirect-tcp-dns-to-tor-user=${user}"
+  if !defined(Shorewall::Rule["$tcp_rule"]) {
+    shorewall::rule {
+      "$tcp_rule":
+        source          => '$FW',
+        destination     => "${destzone}:${shorewall::tor_dns_host}:${shorewall::tor_dns_port}",
+        proto           => 'tcp',
+        destinationport => 'domain',
+        user            => $user,
+        order           => 108,
+        action          => 'DNAT';
+    }
+  }
+
+  $udp_rule = "redirect-udp-dns-to-tor-user=${user}"
+  if !defined(Shorewall::Rule["$udp_rule"]) {
+    shorewall::rule {
+      "$udp_rule":
+        source          => '$FW',
+        destination     => "${destzone}:${shorewall::tor_dns_host}:${shorewall::tor_dns_port}",
+        proto           => 'udp',
+        destinationport => 'domain',
+        user            => $user,
+        order           => 108,
+        action          => 'DNAT';
+    }
+  }
+
+}