README.md 7.82 KB
Newer Older
Varac's avatar
Varac committed
1 2
Puppet Module for Shorewall
---------------------------
Varac's avatar
Varac committed
3 4
This module manages the configuration of Shorewall (http://www.shorewall.net/)

5 6 7
Requirements
------------

varac's avatar
varac committed
8 9 10
This module requires the augeas module, you can find that here:
https://gitlab.com/shared-puppet-modules-group/augeas.git

11 12
This module requires the concat module, you can find that here:
https://github.com/puppetlabs/puppetlabs-concat.git
13

14 15 16 17 18 19
Copyright
---------

Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
adapted by immerda project group - admin+puppet(at)immerda.ch
adapted by Puzzle ITC - haerry+puppet(at)puzzle.ch
20

21
Copyright (c) 2009 Riseup Networks - micah(shift+2)riseup.net
22

23 24 25 26 27 28 29 30 31
Copyright (c) 2010 intrigeri - intrigeri(at)boum.org
See LICENSE for the full license granted to you.

Based on the work of ADNET Ghislain <gadnet@aqueos.com> from AQUEOS
at https://reductivelabs.com/trac/puppet/wiki/AqueosShorewall

Merged from:
- git://git.puppet.immerda.ch/module-shorewall.git
- git://labs.riseup.net/module_shorewall
32 33
- https://gitlab.com/shared-puppet-modules-group/shorewall.git

34

Varac's avatar
Varac committed
35 36 37
Todo
----
- check if shorewall compiles without errors, otherwise fail !
38

39 40 41 42 43 44 45 46 47 48
Configuration
-------------

If you need to install a specific version of shorewall other than
the default one that would be installed by 'ensure => present', then
you can set the following variable and that specific version will be
installed instead:

    $shorewall_ensure_version = "4.0.15-1"

49 50 51 52 53
The main shorewall.conf is not managed by this module, rather the default one
that your operatingsystem provides is used, and any modifications you wish to do
to it should be configured with augeas, for example, to set IP_FORWARDING=Yes in
shorewall.conf, simply do this:

54 55 56 57 58 59
    augeas { 'enable_ip_forwarding':
      changes => 'set /files/etc/shorewall/shorewall.conf/IP_FORWARDING Yes',
      lens    => 'Shellvars.lns',
      incl    => '/etc/shorewall/shorewall.conf',
      notify  => Service[shorewall];
    }
60

61
NOTE: this requires the augeas ruby bindings newer than 0.7.3.
62

63 64
If you need to, you can provide an entire shorewall.conf by passing its
source to the main class:
65

66 67 68
    class{'shorewall':
      conf_source => "puppet:///modules/site_shorewall/${::fqdn}/shorewall.conf.${::operatingsystem}",
    }
69 70

NOTE: if you distribute a file, you cannot also use augeas, puppet and augeas
71 72 73 74 75
will fight forever. Secondly, you will *need* to make sure that if you are shipping your own
shorewall.conf that you have the following value set in your shorewall.conf otherwise this
module will not work:

    CONFIG_PATH="/etc/shorewall/puppet:/etc/shorewall:/usr/share/shorewall"
76

77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
Warnings
--------
There are some features that have been deprecated upstream that may still be
supported by this module on certain shorewall major version. Please note
the following:

* the blacklist file and option is deprecated and replaced by blrules
* the rfc1918 file and norfc1918 option are deprecated
* the tcrules file is deprecated, replaced by mangled
* the routestopped file is deprecated and replaced by stoppedrules
* as of shorewall 4.6.0, SECTION headers need a leading '?'

You should migrate your own calls to this module to move to the currently
supported methods, we will be dropping support for deprecated features as
the available distribution version permit it.
For more details see http://www.shorewall.net/upgrade_issues.htm

Varac's avatar
Varac committed
94 95
Documentation
-------------
96

Varac's avatar
Varac committed
97
see also: http://reductivelabs.com/trac/puppet/wiki/Recipes/AqueosShorewall
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

Torify
------

The shorewall::rules::torify define can be used to force some outgoing
TCP traffic through the Tor transparent proxy. The corresponding
non-TCP traffic is rejected accordingly.

Beware! This define only is part of a torified setup. DNS requests and
IPv6, amongst others, might leak network activity you would prefer not
to. You really need to read proper documentation about these matters
before using this feature e.g.:

  https://www.torproject.org/download/download.html.en#warning

The Tor transparent proxy location defaults to 127.0.0.1:9040 and can
be configured by setting the $tor_transparent_proxy_host and
$tor_transparent_proxy_port variables before including the main
shorewall class.

Example usage follows.

Torify any outgoing TCP traffic originating from user bob or alice and
aimed at 6.6.6.6 or 7.7.7.7:

123 124 125 126 127
    shorewall::rules::torify {
      'torify-some-bits':
        users        => [ 'bob', 'alice' ],
        destinations => [ '6.6.6.6', '7.7.7.7' ];
    }
128 129 130

Torify any outgoing TCP traffic to 8.8.8.8:

131 132 133 134
    shorewall::rules::torify {
      'torify-to-this-host':
        destinations  => [ '8.8.8.8' ];
    }
135 136 137 138 139 140 141 142 143 144 145 146

When no destination nor user is provided any outgoing TCP traffic (see
restrictions bellow) is torified. In that case the user running the
Tor client ($tor_user) is whitelisted; this variable defaults to
"debian-tor" on Debian systems and to "tor" on others. if this does
not suit your configuration you need to set the $tor_user variable
before including the main shorewall class.

When no destination is provided traffic directed to RFC1918 addresses
is by default allowed and (obviously) not torified. This behaviour can
be changed by setting the allow_rfc1918 parameter to false.

147
Torify any outgoing TCP traffic but connections to RFC1918 addresses:
148

149 150 151
    shorewall::rules::torify {
      'torify-everything-but-lan':
    }
152 153 154

Torify any outgoing TCP traffic:

155 156 157 158
    shorewall::rules::torify {
      'torify-everything:
        allow_rfc1918 => false;
    }
159 160 161 162 163 164 165 166 167

In some cases (e.g. when providing no specific destination nor user
and denying access to RFC1918 addresses) UDP DNS requests may be
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.

Varac's avatar
Varac committed
168 169 170
Example
-------

Varac's avatar
Varac committed
171 172
Example from node.pp:

173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
    node xy {
      class{'config::site_shorewall':
        startup => "0"  # create shorewall ruleset but don't startup
      }
      shorewall::rule {
        'incoming-ssh': source => 'all', destination => '$FW',  action  => 'SSH(ACCEPT)', order => 200;
        'incoming-puppetmaster': source => 'all', destination => '$FW',  action  => 'Puppetmaster(ACCEPT)', order => 300;
        'incoming-imap': source => 'all', destination => '$FW',  action  => 'IMAP(ACCEPT)', order => 300;
        'incoming-smtp': source => 'all', destination => '$FW',  action  => 'SMTP(ACCEPT)', order => 300;
      }
    }


    class config::site_shorewall($startup = '1') {
      class{'shorewall':
        startup => $startup
      }

      # If you want logging:
      #shorewall::params {
      # 'LOG':  value => 'debug';
      #}

      shorewall::zone {'net':
        type => 'ipv4';
      }

      shorewall::rule_section { 'NEW':
        order => 100;
      }

      shorewall::interface { 'eth0':
        zone    => 'net',
Matt Taggart's avatar
Matt Taggart committed
206
        options => 'tcpflags,nosmurfs';
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
      }

      shorewall::policy {
        'fw-to-fw':
          sourcezone              =>      '$FW',
          destinationzone         =>      '$FW',
          policy                  =>      'ACCEPT',
          order                   =>      100;
        'fw-to-net':
          sourcezone              =>      '$FW',
          destinationzone         =>      'net',
          policy                  =>      'ACCEPT',
          shloglevel              =>      '$LOG',
          order                   =>      110;
        'net-to-fw':
          sourcezone              =>      'net',
          destinationzone         =>      '$FW',
          policy                  =>      'DROP',
          shloglevel              =>      '$LOG',
          order                   =>      120;
      }


      # default Rules : ICMP
      shorewall::rule {
        'allicmp-to-host':
          source => 'all',
          destination => '$FW',
          order  => 200,
          action  => 'AllowICMPs/(ACCEPT)';
      }
    }
Varac's avatar
Varac committed
239 240