Compare commits

..

386 Commits

Author SHA1 Message Date
Tom Eastep
e4830f6342 Compensate for silly RHEL bug
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-19 06:43:25 -07:00
Tom Eastep
99efb518bd Add the HELPER column to the rules files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-18 12:05:42 -07:00
Tom Eastep
f273fdfda8 Merge branch 'master' of ssh://shorewall.git.sourceforge.net/gitroot/shorewall/shorewall
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-18 08:00:56 -07:00
Tom Eastep
1b7a7d0fdf Remove some more hard-coded directory names from the installers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-17 14:24:52 -07:00
Tom Eastep
7ac9e46e1f Add a comment
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-16 15:49:33 -07:00
Tom Eastep
0a4f26a318 Correct handling of existing notrack file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-16 14:46:48 -07:00
Tom Eastep
8d3cf6428f Install the conntrack file unconditionally.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-16 10:50:23 -07:00
Tom Eastep
f6c4650624 Allow a notrack with nothing but FORMAT and COMMENT lines to be removed.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-16 10:49:59 -07:00
Tom Eastep
3c35af9d8c Merge branch 'master' into 4.5.7 2012-08-16 08:34:54 -07:00
Tom Eastep
1e11109bb2 Don't combine rules with '-m policy'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-16 08:34:30 -07:00
Tom Eastep
f59612671b Don't optimize chains with '-m ipsec'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-16 07:33:01 -07:00
Tom Eastep
da4f7ee524 Handle ppp devices correctly in the 'enable' command.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-16 06:59:35 -07:00
Tom Eastep
b132176dae Correct reference adjustment in new opt4 code
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-14 13:36:39 -07:00
Tom Eastep
1f59e4f449 Update case in conditionals.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-14 11:42:46 -07:00
Tom Eastep
8487c78a0a Adjust reference counts when splicing in short chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-14 08:34:51 -07:00
Tom Eastep
fdc45a990d Arrange for HELPER to match in the RELATED section.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-13 15:44:19 -07:00
Tom Eastep
44a550870c Add HELPER action.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-13 13:23:38 -07:00
Tom Eastep
bd3295b0e3 Remove temporary hack
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-13 08:55:43 -07:00
Tom Eastep
f1fbb95d48 Update documentation for content merged from the 4.5.8 (master) path
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-13 08:16:36 -07:00
Tom Eastep
45288f5927 Revise notrack/conntrack handling:
- Purge empty notrack files.
- Process both files.
2012-08-13 07:28:07 -07:00
Tom Eastep
75b830b10e Merge branch 'master' into 4.5.7 2012-08-13 06:57:54 -07:00
Tom Eastep
4b2d48d621 Hardwire AUTOHELPERS until 4.5.8.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-13 06:48:19 -07:00
Tom Eastep
50362040d7 Enable automatic helper association during 'stop'.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-12 08:46:06 -07:00
Tom Eastep
2f1d59366c Unconditionally disable kernel automatic helper association during start.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-12 08:43:28 -07:00
Tom Eastep
b372163122 Enable automatic helper association during 'stop'.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-12 08:42:53 -07:00
Tom Eastep
50bd1d6398 Add AUTOHELPER option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-12 07:25:11 -07:00
Tom Eastep
e6ef32ebc2 Make conditional directives case insensitive
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-11 08:48:35 -07:00
Tom Eastep
a5824dc2d4 Optimize extension
- Eliminate short chains with a single reference.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-11 08:47:10 -07:00
Tom Eastep
b5af6f03fb Create better rules when a HELPER appears in an action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-11 07:48:03 -07:00
Tom Eastep
50dfffec94 Eliminate duplicate rules in raw-table chains when optimize level 16.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-10 07:09:01 -07:00
Tom Eastep
ad818c071a Generate omnibus tracking rules when NAT/ACCEPT with helper appears in an action.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-10 06:55:18 -07:00
Tom Eastep
e84ee76c7d Add helpers to macros
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-09 10:32:34 -07:00
Tom Eastep
2ab50e65d7 Make conditional directives case insensitive
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-09 10:30:02 -07:00
Tom Eastep
2690243e3c Add helpers in the macros
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-09 07:36:04 -07:00
Tom Eastep
8f71797a48 Update upgrade doc to mention both SHA and SHA1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-08 10:51:06 -07:00
Tom Eastep
4d3fbd1dfa Allow '?IF 0'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-08 07:24:17 -07:00
Tom Eastep
e8a4728981 Allow '?IF 0'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-08 07:23:43 -07:00
Tom Eastep
ee28638604 Add HELPERS to rules file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-08 07:23:20 -07:00
Tom Eastep
a8495626b0 Merge branch '4.5.6' into 4.5.7 2012-08-07 15:10:15 -07:00
Tom Eastep
c6186571e5 Handle raw table zones from VSERVERS
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-07 15:09:40 -07:00
Tom Eastep
ccf517307e Handle raw table zones from VSERVERS
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-07 14:51:58 -07:00
Tom Eastep
88dabde9c9 Update upgrade-issues doc
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-07 09:10:21 -07:00
Tom Eastep
e00616a1fe Don't release blacklist files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-07 07:56:16 -07:00
Tom Eastep
c007f847a0 Handle disabled helpers in pre-3.5 kernels.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-06 15:54:45 -07:00
Tom Eastep
4b4e30d4e1 Handle disabled helpers in pre-3.5 kernels.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-06 13:10:15 -07:00
Tom Eastep
56caf3687f Factor out the ?IF __CT_TARGET tests in the conntrack files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-06 09:26:14 -07:00
Tom Eastep
b4c812b676 Correct helper parsing in the Raw module.
- Require (...) around multiple ctevents
- Detect invalid options

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-05 08:09:17 -07:00
Tom Eastep
9a0d53194a Correct Helper detection in the compiler.
Use CT_MATCH when available.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-05 08:08:20 -07:00
Tom Eastep
49fb2799e9 Correct detection of 'netbios-ns' in the CLIs.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-05 08:07:19 -07:00
Tom Eastep
6c97e13107 Use -j CT for helper detection, when available
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-04 11:36:03 -07:00
Tom Eastep
cfe2f36320 Delete duplicate entry in the Shorewall[6] install.sh
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-04 08:23:08 -07:00
Tom Eastep
6fbb578ce6 Add Helpers Document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-04 07:28:13 -07:00
Tom Eastep
093985dd93 Use HELPERS to enable/disable helper association.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-03 19:26:02 -07:00
Tom Eastep
72307df6d2 Replace the AUTOHELPERS option with the HELPERS option.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-03 10:53:20 -07:00
Tom Eastep
7689b1e84b Remove the 'zone' helper option for now.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-03 06:39:58 -07:00
Tom Eastep
9ceff3c213 Display KERNELVERSION and CAPVERSION in 'show capabilities'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-02 17:38:41 -07:00
Tom Eastep
82c057d1ed Fix *VERSION handling.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-02 16:44:02 -07:00
Tom Eastep
21770a89d6 Detect which matches are available.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-02 15:38:23 -07:00
Tom Eastep
223ed5b3a3 More additions to the helper table and to the conntrack files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-02 13:25:44 -07:00
Tom Eastep
2ae59bb3cd Add COMMENT directives to conntrack file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-02 11:58:00 -07:00
Tom Eastep
c2cd031285 Mention the conntrack file in the config basics doc.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-02 11:31:25 -07:00
Tom Eastep
9ba0c07956 Redesign the CT:helper feature.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-02 11:10:08 -07:00
Tom Eastep
7d32258e6e Correct Helpers Module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-02 11:09:34 -07:00
Tom Eastep
07e56d129a Add AUTOHELPERS option.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-02 11:09:18 -07:00
Tom Eastep
62d6d2558e Rename AUTO_COMMENT to AUTOCOMMENT
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-02 11:06:41 -07:00
Tom Eastep
833e54c9c3 Rename the notrack file to conntrack
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-02 11:02:17 -07:00
Tom Eastep
f2dd43855e Correct typo in warning message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-01 13:13:18 -07:00
Tom Eastep
eaf238fa66 Merge branch '4.5.6' 2012-08-01 10:37:45 -07:00
Tom Eastep
542f279544 Don't allow a source interface in a DNAT/REDIRECT rule with source == firewall
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-08-01 10:01:08 -07:00
Tom Eastep
917e2980a4 Correct error message generation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-30 09:22:43 -07:00
Tom Eastep
c8ea03bf8c Update help text
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-30 07:23:53 -07:00
Tom Eastep
ac6e67e371 Correct typo in rules manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-30 07:23:40 -07:00
Tom Eastep
735b7c2cf5 Add support for nfacct
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-28 11:21:16 -07:00
Tom Eastep
87c0f934aa Add NFacct Match capability
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-28 08:19:05 -07:00
Tom Eastep
55519bd9ac Revise instructions for disabling iptables
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-17 16:48:15 -07:00
Tom Eastep
c0e4d4093c Clarify TOS value
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-16 15:53:22 -07:00
Tom Eastep
55b527d065 Eliminate a local variable.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-15 20:22:19 -07:00
Tom Eastep
620d8f1cd0 Add an Anti-spoofing document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-15 11:26:16 -07:00
Tom Eastep
e1e7ab42c1 Make 'routefilter' and 'sfilter' mutually exclusive
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-15 10:37:56 -07:00
Tom Eastep
65b16a1acf Compensate for bugs in the latest CPerl emacs extension
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-15 10:07:06 -07:00
Tom Eastep
1db79a91eb 'rpfilter' option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-15 10:05:32 -07:00
Tom Eastep
e7cd84a72c Implement rpfilter match capability
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-15 07:54:46 -07:00
Tom Eastep
691a9bf793 Correct installation on systems with systemd
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-14 14:38:30 -07:00
Tom Eastep
2cce81cfc1 Revert 83a8c7eda3
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-09 10:58:15 -07:00
Tom Eastep
9f4ca3ebc5 Additional simplification of evaluate_expression()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-08 07:48:27 -07:00
Tom Eastep
3c2385de06 Merge branch '4.5.6' 2012-07-08 07:36:15 -07:00
Tom Eastep
6ce3d0180e Ensure a defined value for __IPV[46]
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-07 09:47:10 -07:00
Tom Eastep
83a8c7eda3 When TC_ENABLED=No, require providers to process tcrules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-07 08:02:57 -07:00
Tom Eastep
aa652fda1b Add FAQ 99
- Empty ruleset after boot even though Shorewall runs.
2012-07-07 07:55:17 -07:00
Tom Eastep
66f3df4570 Correct typo in ISO 366O doc.
- changed tcrules to rules

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-07 07:38:27 -07:00
Tom Eastep
5616c96745 Merge branch '4.5.6' 2012-07-06 12:30:52 -07:00
Tom Eastep
18f947eb2f Apply patch from Daniel Meißner
- Corrects STARTUP_ENABLED=No error message

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-06 07:28:29 -07:00
Tom Eastep
83df8a4e39 Avoid a call to eval() for simple expressions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-06 07:26:54 -07:00
Tom Eastep
e9d8228b6f Simplify handling of __IPVn in conditional directives.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-06 06:43:15 -07:00
Tom Eastep
65d8341c6c Correct a comment
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-05 15:43:20 -07:00
Tom Eastep
61a9584433 Only require MANGLE_ENABLED to process the tcrules file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-04 14:45:24 -07:00
Tom Eastep
1b1d38a808 Merge branch '4.5.6' 2012-07-03 08:07:54 -07:00
Tom Eastep
000cc6978a Add missing 'sleep' when waiting for wildcard interface to come up
- Also reverse the order of test and sleep when waiting for a regular
  interface to come up.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-03 08:06:30 -07:00
Tom Eastep
a073258e15 Add missing 'sleep' when waiting for wildcard interface to come up
- Also reverse the order of test and sleep when waiting for a regular
  interface to come up.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-03 07:16:16 -07:00
Tom Eastep
e4d66fb5fc Back out redundant part of recent patch
- setup_traffic_shaping is only called when there are tc devices so the
  test of @tcdevices in that function is redundant.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-03 06:33:46 -07:00
Tom Eastep
537f6c157c Allow the compiler version to be tested in ?IF/?ELSIF
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-02 11:53:32 -07:00
Tom Eastep
a5b637b2a7 Use the correct filename in ?IF/?ELSIF exec call.
- Also extend a comment in the TC module

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-02 11:53:01 -07:00
Tom Eastep
74f831a73e Improve the readability of the ?ELSIF example
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-02 11:51:14 -07:00
Tom Eastep
f0b5ee4cdb Correct a typo in NewRelease.xml
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-02 11:50:38 -07:00
Tom Eastep
09c00cf425 Don't print phoney progress message
- The 'Setting up Traffic Shaping' progress message was being issued when
  traffic shaping was not enabled.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-07-01 08:27:07 -07:00
Tom Eastep
6ddaa0190e Improve USER/GROUP validation.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-30 14:46:50 -07:00
Tom Eastep
5c176c64b7 Add an ORIGINAL DEST column to /etc/shorewall/masq
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-29 15:32:01 -07:00
Tom Eastep
b195884b1f Insure that the correct filename/linenumber are printed in error messages out of process_conditional()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-29 09:01:26 -07:00
Tom Eastep
56d5ae2d41 Ensure that exclusion chains have DONT_MOVE
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-27 18:06:38 -07:00
Tom Eastep
41c7c8f923 Make the Invalid Drop rules uniform across sample files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-27 15:16:16 -07:00
Tom Eastep
0bf2753472 Re-implement conditional inclusion
- Correct defects
- Add ?ELSIF support
- Allow Perl-compatible expressions in ?IF
2012-06-27 15:15:44 -07:00
Tom Eastep
c90006ecf8 Correct another logical name bug -- this time in TC
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-27 11:34:19 -07:00
Tom Eastep
17d22fb5b8 Prevent multiple 'tproxy' providers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-23 17:26:18 -07:00
Tom Eastep
af302900c6 Prevent multiple 'tproxy' providers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-23 17:09:46 -07:00
Tom Eastep
9aa78656ec Add TPROXY_MARK to the output of 'shorewall show marks'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-23 07:57:39 -07:00
Tom Eastep
b9d59bc60c Document that 'classify' with marks is now allowed.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-22 10:17:26 -07:00
Tom Eastep
1b7601cb19 Update all samples to specify OPTIMIZE=31
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-21 11:48:48 -07:00
Tom Eastep
640d34cecd Remove old advice from the Aliased Interface Article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-20 16:39:12 -07:00
Tom Eastep
9d3766b77f Allow fwmarks with 'classify' interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-20 14:04:48 -07:00
Tom Eastep
24ddae6ede Don't use '--ctmark' when saving marks
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-20 13:30:27 -07:00
Tom Eastep
7b6f329830 Document UID/GID ranges
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-19 14:05:38 -07:00
Tom Eastep
4d336ed8d6 Rewrite handling of the USER/GROUP column
- Remove code that handled '+program' as that support was removed from
  the kernel in 2.6.14.
2012-06-19 08:14:31 -07:00
Tom Eastep
da3e1b720c Apply user/group Id range patch from Gergely Risko
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-19 06:17:13 -07:00
Tom Eastep
a38f773ab1 Clarify comment in macro.mDNS
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-18 14:20:10 -07:00
Tom Eastep
7b4e5828e0 Clean up handling of RED options.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-18 12:17:22 -07:00
Tom Eastep
a2f6236e82 Add bi-directional mDNS macro
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-18 09:16:30 -07:00
Tom Eastep
50bd126b11 Reverse change to macro.mDNS and add a comment about $FW being the SOURCE
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-18 09:16:11 -07:00
Tom Eastep
4a55705b9a Update tcclasses manpages titles to include HFSC
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-18 07:54:25 -07:00
Tom Eastep
0a928cb034 Add tc-red(8) as reference to the tcclasses manpages. 2012-06-17 10:03:19 -07:00
Tom Eastep
d1627efe5a Add a complex QOS Example
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-17 09:57:31 -07:00
Tom Eastep
4c10fcd503 Complain if a RED_NONE option has a value specified.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-16 15:51:20 -07:00
Tom Eastep
2807502836 More tcclasses manpage cleanup.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-16 06:50:23 -07:00
Tom Eastep
5f81ab7b31 make mDNS macro bi-directional
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-15 10:39:11 -07:00
Tom Eastep
780e7014d4 Cleanup of tcclasses manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-15 10:34:09 -07:00
Tom Eastep
5fc295e8cc Fix handling of stab 'tsize' option.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-14 15:44:15 -07:00
Tom Eastep
c5ba167a3e Make CEIL optional
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-14 13:10:09 -07:00
Tom Eastep
9159372897 Fix a typo in the tcfilters manpages.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-14 13:08:37 -07:00
Tom Eastep
6c47349689 Support 'red' queuing discipline
- Also added 'ls' support for HFSC

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-13 14:29:13 -07:00
Tom Eastep
d2c415c580 Make IFB work with logical interface names.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-13 13:48:12 -07:00
Tom Eastep
28ab3749ca Allow fractional delays in TC
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-13 13:47:31 -07:00
Tom Eastep
a29dbf4ff8 Fix for linklayer
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-12 11:48:12 -07:00
Tom Eastep
f92a9fa0d6 Update traffic shaping doc with linklayer options
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-12 09:40:33 -07:00
Tom Eastep
cbba5741ce Correct typos in tcdevices manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-12 09:40:15 -07:00
Tom Eastep
4a51241c40 Merge branch '4.5.5' 2012-06-12 08:12:26 -07:00
Tom Eastep
b2c96970ee Add cls_basic to recommended TC modules in FAQ 67
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-12 08:11:17 -07:00
Tom Eastep
19cace7e8d Merge branch '4.5.5'
Conflicts:
	Shorewall/Perl/Shorewall/Providers.pm
2012-06-11 17:02:59 -07:00
Tom Eastep
4791a8ca66 Don't delete default routes when 'fallback' is specified.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-11 16:57:49 -07:00
Tom Eastep
844f6c63e4 Add support for TC size tables.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-11 15:45:47 -07:00
Tom Eastep
08db919479 Merge branch '4.5.5' 2012-06-11 13:55:47 -07:00
Tom Eastep
2dd9e6c91f Don't delete default routes when 'fallback' is specified.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-11 13:53:53 -07:00
Tom Eastep
2e05b81443 Apply patch from Ronan Amicel
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-11 11:26:49 -07:00
Tom Eastep
c57f627a21 Add some comments.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-11 11:25:19 -07:00
Tom Eastep
1d0ab43fbb Change indentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-10 15:38:09 -07:00
Tom Eastep
5f051fc61b Unify document indexes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-10 15:31:31 -07:00
Tom Eastep
61d4363865 Update Netfilter overview with Raw and Rawpost tables
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-10 15:30:39 -07:00
Tom Eastep
705744fd8c Convert Frequently-used Articles section into a table
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-10 07:36:32 -07:00
Tom Eastep
b5bba40344 Merge branch '4.5.5' 2012-06-10 07:35:51 -07:00
Tom Eastep
724f3cbd76 Unify documentation indexes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-10 07:22:14 -07:00
Tom Eastep
1f54d19981 Split add_input_jumps() into two functions
- Added add_forward_jump()
- Added lots of comments

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-09 17:21:59 -07:00
Tom Eastep
00f7b9d0dd More useful trace of enable/disable optimization
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-09 15:36:29 -07:00
Tom Eastep
6d3ebd5b56 Improve DIGEST handling.
- Compile compiler.pl when DIGEST specified.
- Report the digest being used.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-09 09:34:28 -07:00
Tom Eastep
bc5e0f4851 Don't store the DIGEST setting in shorewallrc.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-09 08:32:15 -07:00
Tom Eastep
2bf16016c1 Add --digest to configure scripts.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-09 07:24:23 -07:00
Tom Eastep
f86476a43c Remove SYSCONFDIR aliasing from Install.xml
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-09 07:18:53 -07:00
Tom Eastep
1ed6769b14 Fix broken URL in logging doc
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-09 07:18:17 -07:00
Tom Eastep
73325c579e Merge branch '4.5.4' 2012-06-09 06:27:53 -07:00
Tom Eastep
9197cdc9bd Merge branch '4.5.4' into 4.5.5 2012-06-09 06:27:22 -07:00
Tom Eastep
9c486e62e5 Correct handling of SYSCONFDIR
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-09 06:26:03 -07:00
Tom Eastep
a2f32f25c5 Add some comments.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-09 06:20:40 -07:00
Tom Eastep
ae66d7d7a5 Eliminate the hideously complex forwarding code in generate_matrix()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-08 08:29:36 -07:00
Tom Eastep
63eb0bee5b Break up and eliminate handle_pio_jumps()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-08 07:40:26 -07:00
Tom Eastep
8a9427ebff Merge branch '4.5.4' 2012-06-07 14:12:48 -07:00
Tom Eastep
4a383540be Merge branch '4.5.4' into 4.5.5 2012-06-07 14:12:10 -07:00
Tom Eastep
db6a7276ec Don't optimize chains with commands
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-07 14:11:44 -07:00
Tom Eastep
d771c6b2c2 Delete the 'dnat' nat-table chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-07 13:44:03 -07:00
Tom Eastep
fe7d0730d5 Break up generate_matrix()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-07 07:47:33 -07:00
Tom Eastep
38adf3d186 Set 'sourceroute=0' on all sample net interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-06 14:30:00 -07:00
Tom Eastep
a2a9ef0958 Rename OPTIMIZE_MASK1 to OPTIMIZE_MASK2n4
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-06 13:08:45 -07:00
Tom Eastep
21eda5daec Fix multiple iprange matches without kludgefree.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-06 11:26:52 -07:00
Tom Eastep
58a0ebccb2 Clarify CONFIG_PATH setting using -lite products
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-06 11:26:40 -07:00
Tom Eastep
6cd71ef4dd Fix IPv6 shorecap
- copied the CLI program initialization steps to shorecap
- Modified install.sh to modify the location of shrorewallrc if needed
2012-06-06 11:26:17 -07:00
Tom Eastep
49d361e44f Correct another problem with the Shorewall-core installer
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-06 11:25:58 -07:00
Tom Eastep
6bd81145e9 Fix single-line embedded Perl
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-06 11:23:33 -07:00
Tom Eastep
49050e61de Fix multiple iprange matches without kludgefree.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-06 10:50:16 -07:00
Tom Eastep
5c7a4b579c Clarify CONFIG_PATH setting using -lite products
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-05 17:23:13 -07:00
Tom Eastep
bc2e7487db Fix IPv6 shorecap
- copied the CLI program initialization steps to shorecap
- Modified install.sh to modify the location of shrorewallrc if needed
2012-06-05 15:22:08 -07:00
Tom Eastep
9faaab41f4 Correct another problem with the Shorewall-core installer
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-05 12:52:12 -07:00
Tom Eastep
225101b802 Rename OPTIMIZE_MASK1 to OPTIMIZE_MASK2n4
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-05 12:51:52 -07:00
Tom Eastep
fa3164fb1b Re-enable single-line embedded SHELL and PERL
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-05 12:51:16 -07:00
Tom Eastep
3294f7c4c3 Add a comment
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-05 09:02:29 -07:00
Tom Eastep
654f7dd805 Fix single-line embedded Perl
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-05 09:02:12 -07:00
Tom Eastep
ee467a4877 Allow embedded shell/Perl directives to have leading '?'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-05 07:32:43 -07:00
Tom Eastep
170875c7dd Convert the 'ignore' interface to be multi-valued
-Allows 'ignore=1' to only exempt interface from updown processing

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-05 07:23:23 -07:00
Tom Eastep
c8156cfdb1 Correct typo
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-04 08:18:57 -07:00
Tom Eastep
57a9feaf2f Correct typo
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-04 08:00:07 -07:00
Tom Eastep
92a13ec87c Merge branch '4.5.4'
Conflicts:
	Shorewall/Perl/Shorewall/Config.pm
2012-06-03 18:51:03 -07:00
Tom Eastep
040f693583 Cosmetic changes in code from when I was still learning Perl
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-03 17:50:34 -07:00
Tom Eastep
69387b9099 Make 'check -r' work like 'compile' WRT optimization
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-03 15:43:43 -07:00
Tom Eastep
28f0a066da Make 'check -r' work like 'compile' WRT optimization
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-03 15:15:11 -07:00
Tom Eastep
621aa3fc6a Another approach to reporting errors from process_conditional()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-03 13:47:38 -07:00
Tom Eastep
9869420106 Check for conditional directives prior to continuation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-03 09:05:09 -07:00
Tom Eastep
39b3a0da65 Check for conditional directives prior to continuation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-03 08:43:48 -07:00
Tom Eastep
121d34aed0 Add constant LOG_OPTIONS capability
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-02 14:06:31 -07:00
Tom Eastep
4b69216c83 Relocate lib.core in the Source Tree
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-02 12:46:35 -07:00
Tom Eastep
7ff15b0625 Merge branch '4.5.4'
Conflicts:
	Shorewall/Perl/Shorewall/Zones.pm
2012-06-02 11:41:45 -07:00
Tom Eastep
41dcd5826f Minimize the list of plain interfaces
Omit bridge ports and interfaces that match a wildcard.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-02 11:39:16 -07:00
Tom Eastep
26502034ec Minimize the list of plain interfaces
Omit bridge ports and interfaces that match a wildcard.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-02 11:17:10 -07:00
Tom Eastep
baa2c4f5eb Merge branch '4.5.4' 2012-06-02 09:30:47 -07:00
Tom Eastep
9e9c44d4ac Handle Debian pre-down/post-down correctly
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-02 09:26:00 -07:00
Tom Eastep
579104833e Restore installation of the ifupdown script in if-post-down.d on Debian
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-02 09:25:20 -07:00
Tom Eastep
099133f7ff Clear PHASE on non-Debian systems in the ifupdown script
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-02 09:23:31 -07:00
Tom Eastep
67883a369c Add logrotate file to Shorewall-init
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-02 08:26:06 -07:00
Tom Eastep
01eb1a580b Merge branch '4.5.4' 2012-06-02 08:20:40 -07:00
Tom Eastep
b3316d755a Correct silly typo in Providers.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 17:14:08 -07:00
Tom Eastep
73274b9b0b Correct progress message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 15:55:22 -07:00
Tom Eastep
f7104b3d26 Add LOGFILE option to Shorewall-init configuration.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 15:54:03 -07:00
Tom Eastep
c823b0e41e More Shorewall-init fixes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 14:04:08 -07:00
Tom Eastep
fe5d89b243 Install the ifupdown script in if-down.d rather than if-post-down.d on Debian
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 14:03:57 -07:00
Tom Eastep
78f9b76dae Move mutex handling to the main program.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 14:03:47 -07:00
Tom Eastep
402e155148 More Shorewall-init fixes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 14:01:58 -07:00
Tom Eastep
f266d9a4dc Install the ifupdown script in if-down.d rather than if-post-down.d on Debian
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 11:56:48 -07:00
Tom Eastep
9c4a01bcdd Move mutex handling to the main program.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 11:47:58 -07:00
Tom Eastep
21b9a194ca Merge branch '4.5.4' 2012-06-01 11:30:35 -07:00
Tom Eastep
312efe5c7b Use enable/disable for up and down of provider interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 11:27:57 -07:00
Tom Eastep
f25187adb1 Move compile_updown() from the Zones module to the Providers module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 08:12:07 -07:00
Tom Eastep
70e6bda3bb Fix a couple of problems in Shorewall-init
- Remove fly speck from installer
- Don't bother to save/restore VARDIR

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-06-01 08:10:41 -07:00
Tom Eastep
df1efb2a25 Merge branch '4.5.4' 2012-05-31 19:24:33 -07:00
Tom Eastep
02006288b0 Fixes for Shorewall-init
- Enable at boot on debian
- Clear environment for each product
2012-05-31 19:15:23 -07:00
Tom Eastep
9866bcbc9e Correct install of shorewall-init
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-31 16:54:30 -07:00
Tom Eastep
eb03168685 Cleanup of process_rules1() breakup
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-31 15:32:16 -07:00
Tom Eastep
69badac72f Merge branch '4.5.4'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-30 14:43:05 -07:00
Tom Eastep
de184b32bc Fix sectioned IPSEC accounting.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-30 14:37:29 -07:00
Tom Eastep
ea173ab628 Correct IPSEC accounting manpages.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-30 14:09:41 -07:00
Tom Eastep
303c661409 Eliminate bogus term in an expression.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-30 12:49:18 -07:00
Tom Eastep
e88c2c8cd3 Move rules file nat handling to the Nat module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-30 09:01:24 -07:00
Tom Eastep
67932f2d42 Break up expand_rule()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-30 06:49:00 -07:00
Tom Eastep
eb63745352 Merge branch '4.5.4' 2012-05-29 06:48:04 -07:00
Tom Eastep
32e0f154b5 Correct pptpserver tunnel configuration.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-29 06:46:40 -07:00
Tom Eastep
db50454afc Complete removal of optimize level 4 when level 4 is set.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-25 15:42:34 -07:00
Tom Eastep
ed352f60b6 Complete removal of optimize level 4 when level 4 is set.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-25 15:41:55 -07:00
Tom Eastep
3a5875dc73 Add MSSQL Macro
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-25 07:09:23 -07:00
Tom Eastep
5211b32aa6 Remove quotes from GEOIPDIR setting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-25 07:09:07 -07:00
Tom Eastep
c37beacd95 Add MSSQL Macro
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-25 07:07:14 -07:00
Tom Eastep
5b891f1072 Remove quotes from GEOIPDIR setting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-25 07:05:38 -07:00
Tom Eastep
fc97f6d00e Implement LOG target option control.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-24 13:54:59 -07:00
Tom Eastep
6142d4d535 Fix typo
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-23 07:55:07 -07:00
Tom Eastep
1f2ca30ebd Infrastructure for iRule-based logging.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-22 16:46:11 -07:00
Tom Eastep
92ce190bf0 Remove Geoip from Shorewall6/actions.std.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-21 12:31:01 -07:00
Tom Eastep
182a4c3080 Correct 'compile' usage text
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-21 07:10:38 -07:00
Tom Eastep
ab2376d61d Document 15-cc limit.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-21 07:03:53 -07:00
Tom Eastep
f147046288 Change 'cc' to 'country-code' in invalid cc list error message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-21 07:01:07 -07:00
Tom Eastep
daaf3c031f Change the 'no isocodes' error message to include the address family.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-20 09:40:37 -07:00
Tom Eastep
73e5bb0374 Expand the GEOIP documentation to describe GEOIPDIR option.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-20 09:40:00 -07:00
Tom Eastep
6b23eff650 Add a comment
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-20 09:05:42 -07:00
Tom Eastep
ef974b5c8d Clear the DEFAULT table if no FALLBACK providers are up.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-20 09:00:22 -07:00
Tom Eastep
d8ec051114 Load the geoip cc's dynamically.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-20 08:59:59 -07:00
Tom Eastep
84f92aa87c Don't capture result of an RE match. Correct a comment
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-20 07:06:59 -07:00
Tom Eastep
70e4c26df1 Delete a comment
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-19 16:46:57 -07:00
Tom Eastep
db96f6ead2 Reject long CC lists.
- include offending CC in 'Invalid or Unknown' error

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-19 12:44:24 -07:00
Tom Eastep
f0a3e1652a Bracket non-trivial cc lists with [...]
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-19 09:39:49 -07:00
Tom Eastep
56b8a9b9fa Some code cleanup:
- Store config value in a local rather than repeatedly referencing the
  %config hash.
- Centralize generation of the valid table array

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-19 09:02:44 -07:00
Tom Eastep
231c5dbca0 Eliminate need to call optimize_policy_chains() when OPTIMIZE 4 is selected
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-19 08:15:20 -07:00
Tom Eastep
1a9789a3da Optimization tracing
- Correct tracing in optimize_chain()
- Add tracing to new level 4 optimization

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-19 07:54:50 -07:00
Tom Eastep
f15e6d3995 Additional optimization in level 4.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-18 16:50:08 -07:00
Tom Eastep
3f42350a7b Don't overwrite empty mark geometry settings.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-18 11:37:49 -07:00
Tom Eastep
e8648c993d Use blackhole routes rather than unreachable.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-18 10:50:13 -07:00
Tom Eastep
cb72948739 Add Geoip match to config basics doc. Clarify variable search algorithm.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-18 07:27:33 -07:00
Tom Eastep
55c88e8e81 Replace curly brace enclosure with a preceding caret to avoid ambiguity.
- {...} is used to enclose a set of column/value pairs and it is certain
  that the two will become confused.
2012-05-17 15:26:16 -07:00
Tom Eastep
e086067567 Reverse logic in the installer to allow for Digest::SHA being the default now
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-17 14:29:57 -07:00
Tom Eastep
f5f80d2ccc Re-arrange enforcement of restrictions on geoip.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-17 13:59:56 -07:00
Tom Eastep
d1519345c4 Add TOC Link to ISO-3661.html; Correct typo in ISO-3661 page.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-17 12:26:02 -07:00
Tom Eastep
3436fbd6ad Don't use ?INCLUDE in modules files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-17 10:45:12 -07:00
Tom Eastep
d220d3d9d5 Abandon action.GeoIP in favor of extended syntax in the SOURCE and DEST columns.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-17 10:44:02 -07:00
Tom Eastep
6148c909f2 fix multiple ipsets in an imatch
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-16 19:52:41 -07:00
Tom Eastep
cc07e74532 Correct typo in TPROXY documentation.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-16 15:56:19 -07:00
Tom Eastep
2eb25f3f6a Correct the grammar in an error message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-16 07:52:42 -07:00
Tom Eastep
0673898e85 GeoIP tweaks:
- Error if no CC
- switch an 'if' expression to 'unless'.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-16 07:52:19 -07:00
Tom Eastep
43d882db2b Cosmetic cleanup
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-15 16:44:35 -07:00
Tom Eastep
78af118b9a Quote original list when a translated list is ill-formed.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-15 16:39:46 -07:00
Tom Eastep
85f58d6906 Avoid funny-looking ERROR: messages out of Embedded Perl.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-15 16:38:56 -07:00
Tom Eastep
885830b67c Correct configure and configure.pl to output SPARSE
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-15 12:27:16 -07:00
Tom Eastep
17e25932f0 Fixes for GeoIP
- Correct check for valid ACTION
- Add to Shorewall6/actions.std
- Only use geoip once per invocation

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-15 11:14:28 -07:00
Tom Eastep
63ae00e4a4 Fix bug in 'interface_is_usable'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-15 06:58:03 -07:00
Tom Eastep
ac2ed505bb Add GeoIP support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-14 17:12:46 -07:00
Tom Eastep
926e589414 Exit the tcpost chain if a connection mark is restored
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-14 10:35:42 -07:00
Tom Eastep
9f1c920a39 Don't allow RSTs to be REJECTed 2012-05-14 10:34:11 -07:00
Tom Eastep
9ea233d55f Split a couple of functions with address-family dependent logic.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-13 15:53:02 -07:00
Tom Eastep
60bde6231a Improve interface_is_usable()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-13 13:49:59 -07:00
Tom Eastep
3d575a45bd Re-code interface_is_usable()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-13 11:56:52 -07:00
Tom Eastep
1f621002b7 Ignore 'isusable' on 'enable'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-12 19:38:18 -07:00
Tom Eastep
cd150af790 Update .status file on disable
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-12 07:44:46 -07:00
Tom Eastep
cd98266396 Correct add of default IPv6 route when no gateway specified
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-12 07:15:24 -07:00
Tom Eastep
3d541f50c8 Use "(S)" consistently in column headings.
- add synonyms so both the singular and plural forms are accepted.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-11 12:42:04 -07:00
Tom Eastep
bad8b9bddb Improve TPROXY documentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-11 11:39:15 -07:00
Tom Eastep
f77b350a7b Clear the 'balance' table if no balanced providers.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-11 11:28:06 -07:00
Tom Eastep
bed4457e0e Delete jump to 'tproxy'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-11 09:00:09 -07:00
Tom Eastep
2d5269be7b Fix another conditional compilation bug.
?IF $false
   ?IF $false
      ...
   ?ENDIF
   foo <------- This line is not omitted!
?ENDIF

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-11 07:44:46 -07:00
Tom Eastep
a05b3afd7f Eliminate the 'tproxy' chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-11 07:42:44 -07:00
Tom Eastep
9e743451f6 Add FORMAT 2 to tcrules files. Initialize $format in Tc.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-11 07:08:06 -07:00
Tom Eastep
cb7fc31f0b Restore 4.5.3 compatibility
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-10 14:23:33 -07:00
Tom Eastep
69d735ea0a Make TPROXY actually work!
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-10 11:19:23 -07:00
Tom Eastep
4d4fc315e0 More TPROXY changes
- Combine identical DIVERT chains.
- Add --transparent to -m socket
- Reserve a TPROXY bit in the fwmark

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-10 07:25:07 -07:00
Tom Eastep
820c965b72 Allow Shorewall::Config::in_hex() to accept an argument already expressed in hex.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-09 13:51:49 -07:00
Tom Eastep
605ef6ef86 Tweak to DIVERT plus correct TPROXY in man pages.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-09 13:10:51 -07:00
Tom Eastep
2eb7af23dc Merge branch 'master' into 4.5.3 2012-05-09 10:03:43 -07:00
Tom Eastep
582d025f58 Add DIVERT action to tcrules.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-09 09:41:58 -07:00
Tom Eastep
b55d8c04e4 Do logical->physical mapping in rtrules.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-08 14:52:18 -07:00
Tom Eastep
3b6f5b2d8a Finish alternative balancing
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-08 13:55:13 -07:00
Tom Eastep
6639b3534e Close all input files in Shorewall::Config::cleanup()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-08 08:58:14 -07:00
Tom Eastep
59bf343521 Leave first filename and linenumber on the same line as error text.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-08 08:55:24 -07:00
Tom Eastep
089d980dae Document the --shorewallrc parameter to compiler.pl
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-08 07:59:22 -07:00
Tom Eastep
1d6e6b65db Finish a comment
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-07 17:06:35 -07:00
Tom Eastep
2224fdbc65 Correct help text in compiler.pl
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-07 16:55:51 -07:00
Tom Eastep
fd1d6cf935 Handle default shorewallrc location
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-07 16:55:17 -07:00
Tom Eastep
5d7442e9e9 Correct typo in converted blrules file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-07 12:13:26 -07:00
Tom Eastep
ef90006334 Avoid reference to unitialized variable on bogus FORMAT in interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-07 12:00:21 -07:00
Tom Eastep
2cbf1e86ad Allow synonyms for column names in alternate specification formats
- gateway and gateways in the tunnels file
- mark and action in the tcrules file

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-07 11:59:47 -07:00
Tom Eastep
dd8e9ff09d Fix 'COMMENT' along in the tunnels file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-07 11:58:37 -07:00
Tom Eastep
4320150dc4 Add alternate specification in tunnels file ('gateways')
- Make similar change in tcrules file with 'action'

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-07 07:43:11 -07:00
Tom Eastep
7453b70666 Add emphasis to the 'required' option in the config basics doc
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-07 07:14:56 -07:00
Tom Eastep
003daec41c Remove a couple of hard-coded '/usr/share' in Shorewall::Config
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-06 17:30:17 -07:00
Tom Eastep
cb159eba2e Add RST action.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-06 12:14:30 -07:00
Tom Eastep
aac00c3cc7 Pop open stack in run_user_exit1 and run_user_exit2
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-05 10:31:55 -07:00
Tom Eastep
cd35b6a13f Modify macro.BLACKLIST to use blacklog when appropriate
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-05 08:56:55 -07:00
Tom Eastep
af228806fc Allow manual changes to be used in macros.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-05 08:56:26 -07:00
Tom Eastep
69f6aae982 Delete extra copy of macro.BLACKLIST
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-05 08:40:25 -07:00
Tom Eastep
53d66833b2 Document how to avoid dhcp client setting default route
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-04 08:28:06 -07:00
Tom Eastep
1d90ee174c Cleanup of ERROR/WARNING message enhancement.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-04 07:01:08 -07:00
Tom Eastep
097ab853db Apply Tuomo Soini's tunnels patch
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-04 06:18:22 -07:00
Tom Eastep
3e37f47fb5 Print out the include/open stack in WARNING and ERROR messages.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-03 17:17:55 -07:00
Tom Eastep
bd30d59f3d Fix annotated interfaces files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-03 14:09:49 -07:00
Tom Eastep
e4c4900b32 Add recent changes to a couple of config files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-03 12:32:47 -07:00
Tom Eastep
4d23ec2c48 Belatedly document FORMAT-2 interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-03 10:07:36 -07:00
Tom Eastep
15aa1dae62 Enhancements to the 'refresh' command.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-02 13:48:18 -07:00
Tom Eastep
894931731b Merge branch 'master' of ssh://shorewall.git.sourceforge.net/gitroot/shorewall/shorewall 2012-05-02 07:04:30 -07:00
Tom Eastep
3333486c9d Another change to Debian startup at boot
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-01 10:55:29 -07:00
Tom Eastep
2dd82a9898 Update Multi-ISP documentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-01 10:28:12 -07:00
Tom Eastep
45c637ad6b Fix Debian boot startup (again)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-05-01 10:15:39 -07:00
Tom Eastep
731b310359 Use --hashlimit-upto when available.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-30 13:45:09 -07:00
Tom Eastep
35c08c109e Fix IPv4 'reset'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-30 07:54:40 -07:00
Tom Eastep
766771d812 Remove absurd test
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-30 07:48:07 -07:00
Tom Eastep
b9e6349994 Add some comments
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-29 09:07:34 -07:00
Tom Eastep
9efb60c53a Move init.slackware.firewall.sh to Shorewall-core
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-27 16:15:04 -07:00
Tom Eastep
e0570cc35e Install fixes for Slackware
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-27 07:16:11 -07:00
Tom Eastep
9612044933 Make products start automatically at boot on Debian and derivatives
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-25 11:49:22 -07:00
Tom Eastep
3a362a7004 Update FAQ 17
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-25 09:44:24 -07:00
Tom Eastep
c9b4d3d8c8 Add/improve comments.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-25 09:44:08 -07:00
Tom Eastep
dc63efdbfd Use ?INCLUDE in modules files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-25 07:33:40 -07:00
Tom Eastep
d904a2de86 Search and destroy trailing whitespace
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-24 14:52:57 -07:00
Tom Eastep
f860cd037d Change a comment in generate_matrix() to acknowledge 'KLUDGEFREE'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-24 13:34:56 -07:00
Tom Eastep
0f53c3cc7d Convert all interfaces files to format-2 only
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-24 10:53:09 -07:00
Tom Eastep
3bdf703522 Allow TC experts to SAVE/RESTORE all parts of the packet mark
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-24 09:19:38 -07:00
Tom Eastep
8211c5de35 Add a comment about 'find_tables()'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-24 09:15:29 -07:00
Tom Eastep
dc85d4a844 Do SHA/SHA1 test if $BUILD = $TEST, independent of $DESTDIR
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-24 08:52:17 -07:00
Tom Eastep
a50bb407aa Patch from Roberto
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-21 17:51:54 -07:00
Tom Eastep
f40144f6af Corret tcrules manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-21 09:53:00 -07:00
Tom Eastep
0adbdbb101 Add TCP to macro.Amanda
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-20 09:46:13 -07:00
Tom Eastep
34f5838365 Allow multiple GATEWAYS to be listed in the tunnels file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-18 09:28:37 -07:00
Tom Eastep
2b7e5dd9d8 Suppress duplicate option when not KLUDGEFREE
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-17 07:35:37 -07:00
Tom Eastep
44c8ef2ede Correct ill-advised change to push_matches()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-17 07:30:17 -07:00
Tom Eastep
52ebca3fe1 Merge branch '4.5.2'
Conflicts:
	Shorewall-core/lib.cli
	Shorewall/Perl/Shorewall/Config.pm

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-16 13:47:05 -07:00
Tom Eastep
02342d5833 Make 'show routing work with iproute 20111117
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-16 08:20:21 -07:00
Tom Eastep
805166a354 Ressurect LOCKFILE
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-16 07:21:06 -07:00
Tom Eastep
aaab505006 Improve the debuggability of failed assertions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-14 17:57:49 -07:00
Tom Eastep
c3e575baf7 Merge branch 'master' of ssh://shorewall.git.sourceforge.net/gitroot/shorewall/shorewall 2012-04-14 15:58:42 -07:00
Tom Eastep
63a2a32b4b Suppress trailing whitespace.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-14 13:50:59 -07:00
Tom Eastep
eb7a21030d Correct Makefiles
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-14 12:03:51 -07:00
Tom Eastep
1bc03123b9 Delete code to modify Makefile
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-14 12:03:08 -07:00
Tom Eastep
e6aabec7ef Install correct Makefile
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-14 12:03:00 -07:00
Tom Eastep
31752d9ee1 Move macro.BLACKLIST to where it belongs
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-14 08:14:45 -07:00
Tom Eastep
24e2fe4a04 Make options argument to read_a_line manditory
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-14 08:04:28 -07:00
Tom Eastep
2d1a12f016 Correct the output of 'version -a'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-12 18:56:36 -07:00
Tom Eastep
f88584b916 Merge branch '4.5.2'
Conflicts:
	Shorewall-core/configure.pl

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-12 14:48:56 -07:00
Tom Eastep
4ff93bccf0 Remove blank line in shorewallrc.suse
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-12 06:54:19 -07:00
Tom Eastep
355f8e195c Fix configure.pl
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-12 06:53:58 -07:00
Tom Eastep
439fe77d1c Merge branch '4.5.2'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-12 06:26:56 -07:00
Tom Eastep
6b980d6e6a Merge branch '4.5.2' 2012-04-11 15:41:48 -07:00
Tom Eastep
59d1a57f06 Add the -T option to the load, reload, restart and start commands.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-11 14:28:44 -07:00
Tom Eastep
42950e53cd Use logical add rather than arithmetic add for uniformity
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-11 14:28:09 -07:00
Tom Eastep
ae9f538ef8 Simplify an assertion
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-11 14:27:48 -07:00
Tom Eastep
e880d2fd84 Remove some whitespace
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-11 08:03:02 -07:00
Tom Eastep
6404c57cf8 Clean up configure.pl
- Remove blank lines at the end
- Simply the handling of vendor

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-11 08:01:49 -07:00
Tom Eastep
e791a63671 Merge branch '4.5.2'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-11 07:13:40 -07:00
Tom Eastep
07ff3f294d Fix INCLUDE inside an ?IF ... ?ENDIF
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-10 17:27:23 -07:00
Tom Eastep
6ba69c9540 Eliminate read_a_line1()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-10 17:01:38 -07:00
Tom Eastep
5ee554708c Control the proliferation of arguments to read_a_line() by using
a bit-mapped single argument.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2012-04-10 13:51:25 -07:00
191 changed files with 9764 additions and 3534 deletions

View File

@@ -81,9 +81,6 @@ for p in $@; do
DATADIR) DATADIR)
pn=SHAREDIR pn=SHAREDIR
;; ;;
SYSCONFDIR)
pn=CONFDIR
;;
esac esac
params[${pn}]="${pv}" params[${pn}]="${pv}"
@@ -132,7 +129,7 @@ if [ -z "$vendor" ]; then
vendor=${params[HOST]} vendor=${params[HOST]}
elif [ $vendor = linux ]; then elif [ $vendor = linux ]; then
rcfile=$shorewallrc.default; rcfile=shorewallrc.default;
else else
rcfile=shorewallrc.$vendor rcfile=shorewallrc.$vendor
if [ ! -f $rcfile ]; then if [ ! -f $rcfile ]; then
@@ -181,6 +178,7 @@ for on in \
SYSTEMD \ SYSTEMD \
SYSCONFFILE \ SYSCONFFILE \
SYSCONFDIR \ SYSCONFDIR \
SPARSE \
ANNOTATED \ ANNOTATED \
VARDIR VARDIR
do do

View File

@@ -39,8 +39,7 @@ my %options;
my %aliases = ( VENDOR => 'HOST', my %aliases = ( VENDOR => 'HOST',
SHAREDSTATEDIR => 'VARDIR', SHAREDSTATEDIR => 'VARDIR',
DATADIR => 'SHAREDIR', DATADIR => 'SHAREDIR' );
SYSCONFDIR => 'CONFDIR' );
for ( @ARGV ) { for ( @ARGV ) {
die "ERROR: Invalid option specification ( $_ )" unless /^(?:--)?(\w+)=(.*)$/; die "ERROR: Invalid option specification ( $_ )" unless /^(?:--)?(\w+)=(.*)$/;
@@ -140,6 +139,7 @@ for ( qw/ HOST
SYSTEMD SYSTEMD
SYSCONFFILE SYSCONFFILE
SYSCONFDIR SYSCONFDIR
SPARSE
ANNOTATED ANNOTATED
VARDIR / ) { VARDIR / ) {

View File

@@ -307,6 +307,16 @@ chmod 755 ${DESTDIR}${SBINDIR}
mkdir -p ${DESTDIR}${MANDIR} mkdir -p ${DESTDIR}${MANDIR}
chmod 755 ${DESTDIR}${MANDIR} chmod 755 ${DESTDIR}${MANDIR}
if [ -n "${INITFILE}" ]; then
mkdir -p ${DESTDIR}${INITDIR}
chmod 755 ${DESTDIR}${INITDIR}
if [ -n "$AUXINITSOURCE" -a -f "$AUXINITSOURCE" ]; then
install_file $AUXINITSOURCE ${DESTDIR}${INITDIR}/$AUXINITFILE 0544
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${INITDIR}/$AUXINITFILE
echo "$Product script installed in ${DESTDIR}${INITDIR}/$AUXINITFILE"
fi
fi
# #
# Note: ${VARDIR} is created at run-time since it has always been # Note: ${VARDIR} is created at run-time since it has always been
# a relocatable directory on a per-product basis # a relocatable directory on a per-product basis

View File

@@ -28,7 +28,7 @@
# #
SHOREWALL_LIBVERSION=40502 SHOREWALL_LIBVERSION=40502
SHOREWALL_CAPVERSION=40502 SHOREWALL_CAPVERSION=40507
[ -n "${g_program:=shorewall}" ] [ -n "${g_program:=shorewall}" ]
@@ -130,71 +130,6 @@ combine_list()
echo $o echo $o
} }
#
# Call this function to assert mutual exclusion with Shorewall. If you invoke the
# /sbin/shorewall program while holding mutual exclusion, you should pass "nolock" as
# the first argument. Example "shorewall nolock refresh"
#
# This function uses the lockfile utility from procmail if it exists.
# Otherwise, it uses a somewhat race-prone algorithm to attempt to simulate the
# behavior of lockfile.
#
mutex_on()
{
local try
try=0
local lockf
lockf=${LOCKFILE:=${VARDIR}/lock}
local lockpid
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
if [ $MUTEX_TIMEOUT -gt 0 ]; then
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
if [ -f $lockf ]; then
lockpid=`cat ${lockf} 2> /dev/null`
if [ -z "$lockpid" -o $lockpid = 0 ]; then
rm -f ${lockf}
error_message "WARNING: Stale lockfile ${lockf} removed"
elif ! qt ps p ${lockpid}; then
rm -f ${lockf}
error_message "WARNING: Stale lockfile ${lockf} from pid ${lockpid} removed"
fi
fi
if qt mywhich lockfile; then
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
chmod u+w ${lockf}
echo $$ > ${lockf}
chmod u-w ${lockf}
else
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
sleep 1
try=$((${try} + 1))
done
if [ ${try} -lt ${MUTEX_TIMEOUT} ] ; then
# Create the lockfile
echo $$ > ${lockf}
else
echo "Giving up on lock file ${lockf}" >&2
fi
fi
fi
}
#
# Call this function to release mutual exclusion
#
mutex_off()
{
rm -f ${LOCKFILE:=${VARDIR}/lock}
}
[ -z "$LEFTSHIFT" ] && . ${g_basedir}/lib.common
# #
# Validate an IP address # Validate an IP address
# #
@@ -323,6 +258,8 @@ ip_range_explicit() {
done done
} }
[ -z "$LEFTSHIFT" ] && . ${g_basedir}/lib.common
# #
# Netmask to VLSM # Netmask to VLSM
# #

View File

@@ -615,6 +615,20 @@ show_connections_filter() {
fi fi
} }
show_nfacct() {
if [ -n "$NFACCT" -a ! -x "$NFACCT" ]; then
error_message "WARNING: NFACCT=$NFACCT does not exist or is not executable"
NFACCT=
else
NFACCT=$(mywhich nfacct)
[ -n "$NFACCT" ] || echo "No NF Accounting defined (nfacct not found)"
fi
if [ -n "$NFACCT" ]; then
$NFACCT list
echo
fi
}
# #
# Show Command Executor # Show Command Executor
# #
@@ -920,6 +934,12 @@ show_command() {
echo echo
[ -f ${VARDIR}/marks ] && cat ${VARDIR}/marks; [ -f ${VARDIR}/marks ] && cat ${VARDIR}/marks;
;; ;;
nfacct)
[ $# -gt 1 ] && usage 1
echo "$g_product $SHOREWALL_VERSION NF Accounting at $g_hostname - $(date)"
echo
show_nfacct
;;
*) *)
case "$g_program" in case "$g_program" in
*-lite) *-lite)
@@ -1202,6 +1222,9 @@ do_dump_command() {
perip_accounting perip_accounting
fi fi
heading "NF Accounting"
show_nfacct
if qt mywhich setkey; then if qt mywhich setkey; then
heading "PFKEY SPD" heading "PFKEY SPD"
setkey -DP setkey -DP
@@ -1994,6 +2017,24 @@ determine_capabilities() {
IMQ_TARGET= IMQ_TARGET=
DSCP_MATCH= DSCP_MATCH=
DSCP_TARGET= DSCP_TARGET=
GEOIP_MATCH=
RPFILTER_MATCH=
NFACCT_MATCH=
AMANDA_HELPER=
FTP_HELPER=
FTP0_HELPER=
IRC_HELPER=
IRC0_HELPER=
NETBIOS_NS_HELPER=
H323_HELPER=
PPTP_HELPER=
SANE_HELPER=
SANE0_HELPER=
SIP_HELPER=
SIP0_HELPER=
SNMP_HELPER=
TFTP_HELPER=
TFTP0_HELPER=
chain=fooX$$ chain=fooX$$
@@ -2106,6 +2147,19 @@ determine_capabilities() {
qt $g_tool -A $chain -j ACCEPT -m comment --comment "This is a comment" && COMMENTS=Yes qt $g_tool -A $chain -j ACCEPT -m comment --comment "This is a comment" && COMMENTS=Yes
if [ -n "$NFACCT" -a ! -x "$NFACCT" ]; then
error_message "WARNING: NFACCT=$NFACCT does not exist or is not executable"
NFACCT=
else
NFACCT=$(mywhich nfacct)
fi
if [ -n "$NFACCT" ] && qt $NFACCT add $chain; then
qt $g_tool -A $chain -m nfacct --nfacct-name $chain && NFACCT_MATCH=Yes
qt $g_tool -D $chain -m nfacct --nfacct-name $chain
qt $NFACCT del $chain
fi
if [ -n "$MANGLE_ENABLED" ]; then if [ -n "$MANGLE_ENABLED" ]; then
qt $g_tool -t mangle -N $chain qt $g_tool -t mangle -N $chain
@@ -2126,6 +2180,7 @@ determine_capabilities() {
qt $g_tool -t mangle -A $chain -j IMQ --todev 0 && IMQ_TARGET=Yes qt $g_tool -t mangle -A $chain -j IMQ --todev 0 && IMQ_TARGET=Yes
qt $g_tool -t mangle -A $chain -m dscp --dscp 0 && DSCP_MATCH=Yes qt $g_tool -t mangle -A $chain -m dscp --dscp 0 && DSCP_MATCH=Yes
qt $g_tool -t mangle -A $chain -j DSCP --set-dscp 0 && DSCP_TARGET=Yes qt $g_tool -t mangle -A $chain -j DSCP --set-dscp 0 && DSCP_TARGET=Yes
qt $g_tool -t mangle -A $chain -m rpfilter && RPFILTER_MATCH=Yes
qt $g_tool -t mangle -F $chain qt $g_tool -t mangle -F $chain
qt $g_tool -t mangle -X $chain qt $g_tool -t mangle -X $chain
@@ -2137,9 +2192,30 @@ determine_capabilities() {
qt $g_tool -t rawpost -L -n && RAWPOST_TABLE=Yes qt $g_tool -t rawpost -L -n && RAWPOST_TABLE=Yes
if [ -n "$RAW_TABLE" ]; then if [ -n "$RAW_TABLE" ]; then
qt $g_tool -t raw -F $chain
qt $g_tool -t raw -X $chain
qt $g_tool -t raw -N $chain qt $g_tool -t raw -N $chain
qt $g_tool -t raw -A $chain -j CT --notrack && CT_TARGET=Yes
qt $g_tool -t raw -N $chain if qt $g_tool -t raw -A $chain -j CT --notrack; then
CT_TARGET=Yes;
qt $g_tool -t raw -A $chain -p udp --dport 10080 -j CT --helper amanda && AMANDA_HELPER=Yes
qt $g_tool -t raw -A $chain -p tcp --dport 21 -j CT --helper ftp && FTP_HELPER=Yes
qt $g_tool -t raw -A $chain -p tcp --dport 21 -j CT --helper ftp-0 && FTP0_HELPER=Yes
qt $g_tool -t raw -A $chain -p udp --dport 1719 -j CT --helper RAS && H323_HELPER=Yes
qt $g_tool -t raw -A $chain -p tcp --dport 6667 -j CT --helper irc && IRC_HELPER=Yes
qt $g_tool -t raw -A $chain -p tcp --dport 6667 -j CT --helper irc-0 && IRC0_HELPER=Yes
qt $g_tool -t raw -A $chain -p udp --dport 137 -j CT --helper netbios-ns && NETBIOS_NS_HELPER=Yes
qt $g_tool -t raw -A $chain -p tcp --dport 1729 -j CT --helper pptp && PPTP_HELPER=Yes
qt $g_tool -t raw -A $chain -p tcp --dport 6566 -j CT --helper sane && SANE_HELPER=Yes
qt $g_tool -t raw -A $chain -p tcp --dport 6566 -j CT --helper sane-0 && SANE0_HELPER=Yes
qt $g_tool -t raw -A $chain -p udp --dport 5060 -j CT --helper sip && SIP_HELPER=Yes
qt $g_tool -t raw -A $chain -p udp --dport 5060 -j CT --helper sip-0 && SIP0_HELPER=Yes
qt $g_tool -t raw -A $chain -p udp --dport 161 -j CT --helper snmp && SNMP_HELPER=Yes
qt $g_tool -t raw -A $chain -p udp --dport 69 -j CT --helper tftp && TFTP_HELPER=Yes
qt $g_tool -t raw -A $chain -p udp --dport 69 -j CT --helper tftp-0 && TFTP0_HELPER=Yes
fi
qt $g_tool -t raw -F $chain qt $g_tool -t raw -F $chain
qt $g_tool -t raw -X $chain qt $g_tool -t raw -X $chain
fi fi
@@ -2159,10 +2235,10 @@ determine_capabilities() {
if [ -n "$have_ipset" ]; then if [ -n "$have_ipset" ]; then
if qt $g_tool -A $chain -m set --match-set $chain src -j ACCEPT; then if qt $g_tool -A $chain -m set --match-set $chain src -j ACCEPT; then
qt $g_tool -D $chain -m set --match-set $chain src -j ACCEPT qt $g_tool -F $chain
IPSET_MATCH=Yes IPSET_MATCH=Yes
elif qt $g_tool -A $chain -m set --set $chain src -j ACCEPT; then elif qt $g_tool -A $chain -m set --set $chain src -j ACCEPT; then
qt $g_tool -D $chain -m set --set $chain src -j ACCEPT qt $g_tool -F $chain
IPSET_MATCH=Yes IPSET_MATCH=Yes
OLD_IPSET_MATCH=Yes OLD_IPSET_MATCH=Yes
fi fi
@@ -2171,10 +2247,10 @@ determine_capabilities() {
elif qt ipset -N $chain hash:ip family inet6; then elif qt ipset -N $chain hash:ip family inet6; then
IPSET_V5=Yes IPSET_V5=Yes
if qt $g_tool -A $chain -m set --match-set $chain src -j ACCEPT; then if qt $g_tool -A $chain -m set --match-set $chain src -j ACCEPT; then
qt $g_tool -D $chain -m set --match-set $chain src -j ACCEPT qt $g_tool -F $chain
IPSET_MATCH=Yes IPSET_MATCH=Yes
elif qt $g_tool -A $chain -m set --set $chain src -j ACCEPT; then elif qt $g_tool -A $chain -m set --set $chain src -j ACCEPT; then
qt $g_tool -D $chain -m set --set $chain src -j ACCEPT qt $g_tool -F $chain
IPSET_MATCH=Yes IPSET_MATCH=Yes
OLD_IPSET_MATCH=Yes OLD_IPSET_MATCH=Yes
fi fi
@@ -2192,7 +2268,28 @@ determine_capabilities() {
fi fi
qt $g_tool -A $chain -j NFQUEUE --queue-num 4 && NFQUEUE_TARGET=Yes qt $g_tool -A $chain -j NFQUEUE --queue-num 4 && NFQUEUE_TARGET=Yes
qt $g_tool -A $chain -m realm --realm 4 && REALM_MATCH=Yes qt $g_tool -A $chain -m realm --realm 4 && REALM_MATCH=Yes
qt $g_tool -A $chain -m helper --helper "ftp" && HELPER_MATCH=Yes
#
# -m helper doesn't verify the existence of the specified helper :-(
#
if qt $g_tool -A $chain -p tcp --dport 21 -m helper --helper ftp; then
HELPER_MATCH=Yes
if [ -z "$CT_TARGET" ]; then
AMANDA_HELPER=Yes
FTP_HELPER=Yes
FTP_HELPER=Yes
H323_HELPER=Yes
IRC_HELPER=Yes
NS_HELPER=Yes
PPTP_HELPER=Yes
SANE_HELPER=Yes
SIP_HELPER=Yes
SNMP_HELPER=Yes
TFTP_HELPER=Yes
fi
fi
qt $g_tool -A $chain -m connlimit --connlimit-above 8 -j DROP && CONNLIMIT_MATCH=Yes qt $g_tool -A $chain -m connlimit --connlimit-above 8 -j DROP && CONNLIMIT_MATCH=Yes
qt $g_tool -A $chain -m time --timestart 23:00 -j DROP && TIME_MATCH=Yes qt $g_tool -A $chain -m time --timestart 23:00 -j DROP && TIME_MATCH=Yes
qt $g_tool -A $chain -g $chain1 && GOTO_TARGET=Yes qt $g_tool -A $chain -g $chain1 && GOTO_TARGET=Yes
@@ -2202,6 +2299,7 @@ determine_capabilities() {
qt $g_tool -A $chain -j NFLOG && NFLOG_TARGET=Yes qt $g_tool -A $chain -j NFLOG && NFLOG_TARGET=Yes
qt $g_tool -A $chain -j MARK --set-mark 5 && MARK_ANYWHERE=Yes qt $g_tool -A $chain -j MARK --set-mark 5 && MARK_ANYWHERE=Yes
qt $g_tool -A $chain -m statistic --mode nth --every 2 --packet 1 && STATISTIC_MATCH=Yes qt $g_tool -A $chain -m statistic --mode nth --every 2 --packet 1 && STATISTIC_MATCH=Yes
qt $g_tool -A $chain -m geoip --src-cc US && GEOIP_MATCH=Yes
if [ $g_family -eq 4 ]; then if [ $g_family -eq 4 ]; then
qt $g_tool -A $chain -j ACCOUNT --addr 192.168.1.0/29 --tname $chain && ACCOUNT_TARGET=Yes qt $g_tool -A $chain -j ACCOUNT --addr 192.168.1.0/29 --tname $chain && ACCOUNT_TARGET=Yes
@@ -2316,6 +2414,24 @@ report_capabilities() {
report_capability "IMQ Target (IMQ_TARGET)" $IMQ_TARGET report_capability "IMQ Target (IMQ_TARGET)" $IMQ_TARGET
report_capability "DSCP Match (DSCP_MATCH)" $DSCP_MATCH report_capability "DSCP Match (DSCP_MATCH)" $DSCP_MATCH
report_capability "DSCP Target (DSCP_TARGET)" $DSCP_TARGET report_capability "DSCP Target (DSCP_TARGET)" $DSCP_TARGET
report_capability "Geo IP match" $GEOIP_MATCH
report_capability "RPFilter match" $RPFILTER_MATCH
report_capability "NFAcct match" $NFACCT_MATCH
report_capability "Amanda Helper" $AMANDA_HELPER
report_capability "FTP Helper" $FTP_HELPER
report_capability "FTP-0 Helper" $FTP0_HELPER
report_capability "IRC Helper" $IRC_HELPER
report_capability "IRC-0 Helper" $IRC0_HELPER
report_capability "Netbios_ns Helper" $NETBIOS_NS_HELPER
report_capability "H323 Helper" $H323_HELPER
report_capability "PPTP Helper" $PPTP_HELPER
report_capability "SANE Helper" $SANE_HELPER
report_capability "SANE-0 Helper" $SANE0_HELPER
report_capability "SIP Helper" $SIP_HELPER
report_capability "SIP-0 Helper" $SIP0_HELPER
report_capability "SNMP Helper" $SNMP_HELPER
report_capability "TFTP Helper" $TFTP_HELPER
report_capability "TFTP-0 Helper" $TFTP0_HELPER
if [ $g_family -eq 4 ]; then if [ $g_family -eq 4 ]; then
report_capability "iptables -S (IPTABLES_S)" $IPTABLES_S report_capability "iptables -S (IPTABLES_S)" $IPTABLES_S
@@ -2325,6 +2441,9 @@ report_capabilities() {
report_capability "Basic Filter (BASIC_FILTER)" $BASIC_FILTER report_capability "Basic Filter (BASIC_FILTER)" $BASIC_FILTER
report_capability "CT Target (CT_TARGET)" $CT_TARGET report_capability "CT Target (CT_TARGET)" $CT_TARGET
echo " Kernel Version (KERNELVERSION): $KERNELVERSION"
echo " Capabilities Version (CAPVERSION): $CAPVERSION"
fi fi
[ -n "$PKTTYPE" ] || USEPKTTYPE= [ -n "$PKTTYPE" ] || USEPKTTYPE=
@@ -2406,6 +2525,24 @@ report_capabilities1() {
report_capability1 IMQ_TARGET report_capability1 IMQ_TARGET
report_capability1 DSCP_MATCH report_capability1 DSCP_MATCH
report_capability1 DSCP_TARGET report_capability1 DSCP_TARGET
report_capability1 GEOIP_MATCH
report_capability1 RPFILTER_MATCH
report_capability1 NFACCT_MATCH
report_capability1 AMANDA_HELPER
report_capability1 FTP_HELPER
report_capability1 FTP0_HELPER
report_capability1 IRC_HELPER
report_capability1 IRC0_HELPER
report_capability1 NETBIOS_NS_HELPER
report_capability1 H323_HELPER
report_capability1 PPTP_HELPER
report_capability1 SANE_HELPER
report_capability1 SANE0_HELPER
report_capability1 SIP_HELPER
report_capability1 SIP0_HELPER
report_capability1 SNMP_HELPER
report_capability1 TFTP_HELPER
report_capability1 TFTP0_HELPER
echo CAPVERSION=$SHOREWALL_CAPVERSION echo CAPVERSION=$SHOREWALL_CAPVERSION
echo KERNELVERSION=$KERNELVERSION echo KERNELVERSION=$KERNELVERSION
@@ -2942,9 +3079,16 @@ usage() # $1 = exit status
echo " show connections" echo " show connections"
echo " show filters" echo " show filters"
echo " show ip" echo " show ip"
if [ $g_family -eq 4 ]; then
echo " show ipa"
fi
echo " show [ -m ] log [<regex>]" echo " show [ -m ] log [<regex>]"
echo " show [ -x ] mangle|nat|raw|rawpost|routing" echo " show [ -x ] mangle|nat|raw|rawpost"
echo " show nfacct"
echo " show policies" echo " show policies"
echo " show routing"
echo " show tc [ device ]" echo " show tc [ device ]"
echo " show vardir" echo " show vardir"
echo " show zones" echo " show zones"

View File

@@ -717,3 +717,69 @@ truncate() # $1 = length
{ {
cut -b -${1} cut -b -${1}
} }
#
# Call this function to assert mutual exclusion with Shorewall. If you invoke the
# /sbin/shorewall program while holding mutual exclusion, you should pass "nolock" as
# the first argument. Example "shorewall nolock refresh"
#
# This function uses the lockfile utility from procmail if it exists.
# Otherwise, it uses a somewhat race-prone algorithm to attempt to simulate the
# behavior of lockfile.
#
mutex_on()
{
local try
try=0
local lockf
lockf=${LOCKFILE:=${VARDIR}/lock}
local lockpid
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
if [ $MUTEX_TIMEOUT -gt 0 ]; then
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
if [ -f $lockf ]; then
lockpid=`cat ${lockf} 2> /dev/null`
if [ -z "$lockpid" -o $lockpid = 0 ]; then
rm -f ${lockf}
error_message "WARNING: Stale lockfile ${lockf} removed"
elif [ $lockpid -eq $$ ]; then
return 0
elif ! qt ps p ${lockpid}; then
rm -f ${lockf}
error_message "WARNING: Stale lockfile ${lockf} from pid ${lockpid} removed"
fi
fi
if qt mywhich lockfile; then
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
chmod u+w ${lockf}
echo $$ > ${lockf}
chmod u-w ${lockf}
else
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
sleep 1
try=$((${try} + 1))
done
if [ ${try} -lt ${MUTEX_TIMEOUT} ] ; then
# Create the lockfile
echo $$ > ${lockf}
else
echo "Giving up on lock file ${lockf}" >&2
fi
fi
fi
}
#
# Call this function to release mutual exclusion
#
mutex_off()
{
rm -f ${LOCKFILE:=${VARDIR}/lock}
}

View File

@@ -11,10 +11,10 @@ CONFDIR=/etc #Directory where subsystem configurat
SBINDIR=/sbin #Directory where system administration programs are installed SBINDIR=/sbin #Directory where system administration programs are installed
MANDIR=${PREFIX}/man #Directory where manpages are installed. MANDIR=${PREFIX}/man #Directory where manpages are installed.
INITDIR=/etc/rc.d #Directory where SysV init scripts are installed. INITDIR=/etc/rc.d #Directory where SysV init scripts are installed.
INITSOURCE=init.slackware.firewall.sh #Name of the distributed file to be installed as the SysV init script AUXINITSOURCE=init.slackware.firewall.sh #Name of the distributed file to be installed as the SysV init script
INITFILE=rc.firewall #Name of the product's installed SysV init script AUXINITFILE=rc.firewall #Name of the product's installed SysV init script
AUXINITSOURCE=init.slackware.$PRODUCT.sh #Name of the distributed file to be installed as a second SysV init script INITSOURCE=init.slackware.$PRODUCT.sh #Name of the distributed file to be installed as a second SysV init script
AUXINITFILE=rc.$PRODUCT #Name of the product's installed second init script INITFILE=rc.$PRODUCT #Name of the product's installed second init script
SYSTEMD= #Name of the directory where .service files are installed (systems running systemd only) SYSTEMD= #Name of the directory where .service files are installed (systems running systemd only)
SYSCONFFILE= #Name of the distributed file to be installed in $SYSCONFDIR SYSCONFFILE= #Name of the distributed file to be installed in $SYSCONFDIR
SYSCONFDIR= #Name of the directory where SysV init parameter files are installed. SYSCONFDIR= #Name of the directory where SysV init parameter files are installed.

View File

@@ -106,15 +106,11 @@ if [ -f /etc/debian_version ]; then
else else
exit 0 exit 0
fi fi
case "$PHASE" in
pre-*)
exit 0
;;
esac
;; ;;
esac esac
elif [ -f /etc/SuSE-release ]; then elif [ -f /etc/SuSE-release ]; then
PHASE=''
case $0 in case $0 in
/etc/ppp*) /etc/ppp*)
# #
@@ -146,6 +142,8 @@ else
# #
# Assume RedHat/Fedora/CentOS/Foobar/... # Assume RedHat/Fedora/CentOS/Foobar/...
# #
PHASE=''
case $0 in case $0 in
/etc/ppp*) /etc/ppp*)
INTERFACE="$1" INTERFACE="$1"
@@ -186,20 +184,12 @@ else
esac esac
fi fi
[ -n "$LOGFILE" ] || LOGFILE=/dev/null
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
#
# For backward compatibility, lib.base appends the product name to VARDIR
# Save it here and restore it below
#
save_vardir=${VARDIR}
if [ -x $VARDIR/$PRODUCT/firewall ]; then if [ -x $VARDIR/$PRODUCT/firewall ]; then
( . ${SHAREDIR}/shorewall/lib.base ( ${VARDIR}/$PRODUCT/firewall -V0 $COMMAND $INTERFACE >> $LOGFILE 2>&1 ) || true
mutex_on
${VARDIR}/firewall -V0 $COMMAND $INTERFACE || echo_notdone
mutex_off
)
fi fi
VARDIR=${save_vardir}
done done
exit 0 exit 0

View File

@@ -260,6 +260,11 @@ else
first_install="Yes" first_install="Yes"
fi fi
if [ -n "$DESTDIR" ]; then
mkdir -p ${DESTDIR}${CONFDIR}/logrotate.d
chmod 755 ${DESTDIR}${CONFDIR}/logrotate.d
fi
# #
# Install the Firewall Script # Install the Firewall Script
# #
@@ -292,27 +297,35 @@ fi
# #
# Create /usr/share/shorewall-init if needed # Create /usr/share/shorewall-init if needed
# #
mkdir -p ${DESTDIR}/usr/share/shorewall-init mkdir -p ${DESTDIR}${SHAREDIR}/shorewall-init
chmod 755 ${DESTDIR}/usr/share/shorewall-init chmod 755 ${DESTDIR}${SHAREDIR}/shorewall-init
#
# Install logrotate file
#
if [ -d ${DESTDIR}${CONFDIR}/logrotate.d ]; then
run_install $OWNERSHIP -m 0644 logrotate ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT
echo "Logrotate file installed as ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT"
fi
# #
# Create the version file # Create the version file
# #
echo "$VERSION" > ${DESTDIR}/usr/share/shorewall-init/version echo "$VERSION" > ${DESTDIR}/${SHAREDIR}/shorewall-init/version
chmod 644 ${DESTDIR}/usr/share/shorewall-init/version chmod 644 ${DESTDIR}${SHAREDIR}/shorewall-init/version
# #
# Remove and create the symbolic link to the init script # Remove and create the symbolic link to the init script
# #
if [ -z "$DESTDIR" ]; then if [ -z "$DESTDIR" ]; then
rm -f /usr/share/shorewall-init/init rm -f ${SHAREDIR}/shorewall-init/init
ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/shorewall-init/init ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/shorewall-init/init
fi fi
if [ $HOST = debian ]; then if [ $HOST = debian ]; then
if [ -n "${DESTDIR}" ]; then if [ -n "${DESTDIR}" ]; then
mkdir -p ${DESTDIR}/etc/network/if-up.d/ mkdir -p ${DESTDIR}/etc/network/if-up.d/
mkdir -p ${DESTDIR}/etc/network/if-post-down.d/ mkdir -p ${DESTDIR}/etc/network/if-down.d/
fi fi
if [ ! -f ${DESTDIR}/etc/default/shorewall-init ]; then if [ ! -f ${DESTDIR}/etc/default/shorewall-init ]; then
@@ -347,7 +360,7 @@ fi
cp ifupdown.sh ifupdown cp ifupdown.sh ifupdown
d[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ifupdown [ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ifupdown
mkdir -p ${DESTDIR}${LIBEXECDIR}/shorewall-init mkdir -p ${DESTDIR}${LIBEXECDIR}/shorewall-init
@@ -360,6 +373,7 @@ fi
case $HOST in case $HOST in
debian) debian)
install_file ifupdown ${DESTDIR}/etc/network/if-up.d/shorewall 0544 install_file ifupdown ${DESTDIR}/etc/network/if-up.d/shorewall 0544
install_file ifupdown ${DESTDIR}/etc/network/if-down.d/shorewall 0544
install_file ifupdown ${DESTDIR}/etc/network/if-post-down.d/shorewall 0544 install_file ifupdown ${DESTDIR}/etc/network/if-post-down.d/shorewall 0544
;; ;;
suse) suse)
@@ -382,12 +396,12 @@ if [ -z "$DESTDIR" ]; then
if [ -n "$first_install" ]; then if [ -n "$first_install" ]; then
if [ $HOST = debian ]; then if [ $HOST = debian ]; then
update-rc.d shorewall-init defaults update-rc.d shorewall-init enable
echo "Shorewall Init will start automatically at boot" echo "Shorewall Init will start automatically at boot"
else else
if [ -n "$SYSTEMD" ]; then if [ -n "$SYSTEMD" ]; then
if systemctl enable shorewall-init; then if systemctl enable shorewall-init.service; then
echo "Shorewall Init will start automatically at boot" echo "Shorewall Init will start automatically at boot"
fi fi
elif [ -x ${SBINDIR}/insserv -o -x /usr${SBINDIR}/insserv ]; then elif [ -x ${SBINDIR}/insserv -o -x /usr${SBINDIR}/insserv ]; then

5
Shorewall-init/logrotate Normal file
View File

@@ -0,0 +1,5 @@
/var/log/shorewall-ifupdown.log {
missingok
notifempty
create 0600 root root
}

View File

@@ -16,3 +16,8 @@ IFUPDOWN=0
# during 'start' and will save them there during 'stop'. # during 'start' and will save them there during 'stop'.
# #
SAVE_IPSETS="" SAVE_IPSETS=""
#
# Where Up/Down events get logged
#
LOGFILE=/var/log/shorewall-ifupdown.log

View File

@@ -303,8 +303,8 @@ if [ -z "$DESTDIR" -a -d ${CONFDIR}/$PRODUCT ]; then
mv -f ${CONFDIR}/$PRODUCT/shorewall.conf ${CONFDIR}/$PRODUCT/$PRODUCT.conf mv -f ${CONFDIR}/$PRODUCT/shorewall.conf ${CONFDIR}/$PRODUCT/$PRODUCT.conf
else else
rm -rf ${DESTDIR}${CONFDIR}/$PRODUCT rm -rf ${DESTDIR}${CONFDIR}/$PRODUCT
rm -rf ${DESTDIR}/usr/share/$PRODUCT rm -rf ${DESTDIR}${SHAREDIR}/$PRODUCT
rm -rf ${DESTDIR}/var/lib/$PRODUCT rm -rf ${DESTDIR}${VARDIR}/$PRODUCT
[ "$LIBEXECDIR" = /usr/share ] || rm -rf ${DESTDIR}/usr/share/$PRODUCT/wait4ifup ${DESTDIR}/usr/share/$PRODUCT/shorecap [ "$LIBEXECDIR" = /usr/share ] || rm -rf ${DESTDIR}/usr/share/$PRODUCT/wait4ifup ${DESTDIR}/usr/share/$PRODUCT/shorecap
fi fi
@@ -327,9 +327,9 @@ echo "$Product control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
# Create ${CONFDIR}/$PRODUCT, /usr/share/$PRODUCT and /var/lib/$PRODUCT if needed # Create ${CONFDIR}/$PRODUCT, /usr/share/$PRODUCT and /var/lib/$PRODUCT if needed
# #
mkdir -p ${DESTDIR}${CONFDIR}/$PRODUCT mkdir -p ${DESTDIR}${CONFDIR}/$PRODUCT
mkdir -p ${DESTDIR}/usr/share/$PRODUCT mkdir -p ${DESTDIR}${SHAREDIR}/$PRODUCT
mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT
mkdir -p ${DESTDIR}/var/lib/$PRODUCT mkdir -p ${DESTDIR}${VARDIR}/$PRODUCT
chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT
chmod 755 ${DESTDIR}/usr/share/$PRODUCT chmod 755 ${DESTDIR}/usr/share/$PRODUCT
@@ -403,6 +403,7 @@ echo "Common functions linked through ${DESTDIR}${SHAREDIR}/$PRODUCT/functions"
# #
install_file shorecap ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap 0755 install_file shorecap ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap 0755
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${LIBEXECDIR}/$PRODUCT/shorecap
echo echo
echo "Capability file builder installed in ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap" echo "Capability file builder installed in ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap"
@@ -498,7 +499,7 @@ if [ -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
perl -p -w -i -e 's/^STARTUP_ENABLED=No/STARTUP_ENABLED=Yes/;s/^IP_FORWARDING=On/IP_FORWARDING=Keep/;s/^SUBSYSLOCK=.*/SUBSYSLOCK=/;' ${CONFDIR}/${PRODUCT}/${PRODUCT}.conf perl -p -w -i -e 's/^STARTUP_ENABLED=No/STARTUP_ENABLED=Yes/;s/^IP_FORWARDING=On/IP_FORWARDING=Keep/;s/^SUBSYSLOCK=.*/SUBSYSLOCK=/;' ${CONFDIR}/${PRODUCT}/${PRODUCT}.conf
update-rc.d $PRODUCT enable defaults update-rc.d $PRODUCT enable defaults
elif [ -n "$SYSTEMD" ]; then elif [ -n "$SYSTEMD" ]; then
if systemctl enable $PRODUCT; then if systemctl enable ${PRODUCT}.service; then
echo "$Product will start automatically at boot" echo "$Product will start automatically at boot"
fi fi
elif mywhich insserv; then elif mywhich insserv; then

View File

@@ -45,17 +45,22 @@
# used during firewall compilation, then the generated firewall program will likewise not # used during firewall compilation, then the generated firewall program will likewise not
# require Shorewall to be installed. # require Shorewall to be installed.
SHAREDIR=/usr/share/shorewall-lite
VARDIR=/var/lib/shorewall-lite
CONFDIR=/etc/shorewall-lite
g_program=shorewall-lite
g_product="Shorewall Lite"
g_family=4
g_base=shorewall
g_basedir=/usr/share/shorewall-lite
. /usr/share/shorewall-lite/lib.base g_program=shorewall-lite
. /usr/share/shorewall/lib.cli
#
# This is modified by the installer when ${SHAREDIR} != /usr/share
#
. /usr/share/shorewall/shorewallrc
g_libexec="$LIBEXECDIR"
g_sharedir="$SHAREDIR"/shorewall-lite
g_sbindir="$SBINDIR"
g_vardir="$VARDIR"
g_confdir="$CONFDIR"/shorewall-lite
g_readrc=1
. ${SHAREDIR}/shorewall/lib.cli
. /usr/share/shorewall-lite/configpath . /usr/share/shorewall-lite/configpath
[ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin [ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin

View File

@@ -8,9 +8,16 @@
# files from those nodes. # files from those nodes.
# #
############################################################################### ###############################################################################
FORMAT 2
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP # PORT(S) PORT(S) LIMIT GROUP
PARAM - - udp 10080
?if ( __CT_TARGET && ! $AUTOHELPERS && __AMANDA_HELPER )
PARAM - - udp 10080 ; helper=amanda
?else
PARAM - - udp 10080
?endif
PARAM - - tcp 10080 PARAM - - tcp 10080
# #
# You may also need this rule. With AMANDA 2.4.4 on Linux kernel 2.6, # You may also need this rule. With AMANDA 2.4.4 on Linux kernel 2.6,

View File

@@ -8,4 +8,8 @@
############################################################################### ###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP # PORT(S) PORT(S) LIMIT GROUP
$BLACKLIST_DISPOSITION:$BLACKLIST_LOGLEVEL ?if $BLACKLIST_LOGLEVEL
blacklog
?else
$BLACKLIST_DISPOSITION
?endif

View File

@@ -6,6 +6,11 @@
# This macro handles FTP traffic. # This macro handles FTP traffic.
# #
############################################################################### ###############################################################################
FORMAT 2
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP # PORT(S) PORT(S) LIMIT GROUP
PARAM - - tcp 21 ?if ( __CT_TARGET && ! $AUTOHELPERS && __FTP_HELPER )
PARAM - - tcp 21 ; helper=ftp
?else
PARAM - - tcp 21
?endif

View File

@@ -6,6 +6,12 @@
# This macro handles IRC traffic (Internet Relay Chat). # This macro handles IRC traffic (Internet Relay Chat).
# #
############################################################################### ###############################################################################
FORMAT 2
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP # PORT(S) PORT(S) LIMIT GROUP
PARAM - - tcp 6667
?if ( __CT_TARGET && ! $AUTOHELPERS && __IRC_HELPER )
PARAM - - tcp 6667 ; helper=irc
?else
PARAM - - tcp 6667
?endif

View File

@@ -0,0 +1,11 @@
#
# Shorewall version 4 - MSSQL Macro
#
# /usr/share/shorewall/macro.MSSQL
#
# This macro handles MSSQL (Microsoft SQL Server)
#
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP
PARAM - - tcp 1433

View File

@@ -6,8 +6,14 @@
# This macro handles PPTP traffic. # This macro handles PPTP traffic.
# #
############################################################################### ###############################################################################
?FORMAT 2
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP # PORT(S) PORT(S) LIMIT GROUP
PARAM - - 47 PARAM - - 47
PARAM DEST SOURCE 47 PARAM DEST SOURCE 47
PARAM - - tcp 1723
?if ( __CT_TARGET && ! $AUTOHELPERS && __PPTP_HELPER )
PARAM - - tcp 1723 ; helper=pptp
?else
PARAM - - tcp 1723
?endif

View File

@@ -6,9 +6,16 @@
# This macro handles SANE network scanning. # This macro handles SANE network scanning.
# #
############################################################################### ###############################################################################
FORMAT 2
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP # PORT(S) PORT(S) LIMIT GROUP
PARAM - - tcp 6566
?if ( __CT_TARGET && ! $AUTOHELPERS && __SANE_HELPER )
PARAM - - tcp 6566 ; helper=sane
?else
PARAM - - tcp 6566
?endif
# #
# Kernels 2.6.23+ has nf_conntrack_sane module which will handle # Kernels 2.6.23+ has nf_conntrack_sane module which will handle
# sane data connection. # sane data connection.

View File

@@ -0,0 +1,17 @@
#
# Shorewall version 4 - SIP Macro
#
# /usr/share/shorewall/macro.SIP
#
# This macro handles SIP traffic.
#
###############################################################################
FORMAT 2
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP
?if ( __CT_TARGET && ! $AUTOHELPERS && __SIP_HELPER )
PARAM - - udp 5060 ; helper=sip
?else
PARAM - - udp 5060
?endif

View File

@@ -10,9 +10,17 @@
# between hosts you fully trust. # between hosts you fully trust.
# #
############################################################################### ###############################################################################
FORMAT 2
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP # PORT(S) PORT(S) LIMIT GROUP
PARAM - - udp 135,445 PARAM - - udp 135,445
PARAM - - udp 137:139
?if ( __CT_TARGET && ! $AUTOHELPERS && __NETBIOS_NS_HELPER )
PARAM - - udp 137 ; helper=netbios-ns
PARAM - - udp 138:139
?else
PARAM - - udp 137:139
?endif
PARAM - - udp 1024: 137 PARAM - - udp 1024: 137
PARAM - - tcp 135,139,445 PARAM - - tcp 135,139,445

View File

@@ -10,13 +10,28 @@
# allow SMB traffic between hosts you fully trust. # allow SMB traffic between hosts you fully trust.
# #
############################################################################### ###############################################################################
FORMAT 2
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP # PORT(S) PORT(S) LIMIT GROUP
PARAM - - udp 135,445 PARAM - - udp 135,445
PARAM - - udp 137:139
?if ( __CT_TARGET && ! $AUTOHELPERS && __NETBIOS_NS_HELPER )
PARAM - - udp 137 ; helper=netbios-ns
PARAM - - udp 138:139
?else
PARAM - - udp 137:139
?endif
PARAM - - udp 1024: 137 PARAM - - udp 1024: 137
PARAM - - tcp 135,139,445 PARAM - - tcp 135,139,445
PARAM DEST SOURCE udp 135,445 PARAM DEST SOURCE udp 135,445
PARAM DEST SOURCE udp 137:139
?if ( __CT_TARGET && ! $AUTOHELPERS && __NETBIOS_NS_HELPER )
PARAM DEST SOURCE udp 137 ; helper=netbios-ns
PARAM DEST SOURCE udp 138:139
?else
PARAM DEST SOURCE udp 137:139
?endif
PARAM DEST SOURCE udp 1024: 137 PARAM DEST SOURCE udp 1024: 137
PARAM DEST SOURCE tcp 135,139,445 PARAM DEST SOURCE tcp 135,139,445

View File

@@ -6,7 +6,15 @@
# This macro handles SNMP traffic (including traps). # This macro handles SNMP traffic (including traps).
# #
############################################################################### ###############################################################################
FORMAT 2
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP # PORT(S) PORT(S) LIMIT GROUP
PARAM - - udp 161:162
?if ( __CT_TARGET && ! $AUTOHELPERS && __SNMP_HELPER )
PARAM - - udp 161 ; helper=snmp
PARAM - - udp 162
?else
PARAM - - udp 161:162
?endif
PARAM - - tcp 161 PARAM - - tcp 161

View File

@@ -8,6 +8,12 @@
# Internet. # Internet.
# #
############################################################################### ###############################################################################
FORMAT 2
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP # PORT(S) PORT(S) LIMIT GROUP
PARAM - - udp 69
?if ( __CT_TARGET && ! $AUTOHELPERS && __TFTP_HELPER )
PARAM - - udp 69 ; helper=tftp
?else
PARAM - - udp 69
?endif

View File

@@ -1,9 +1,11 @@
# #
# Shorewall version 4 - Multicast DNS Macro # Shorewall version 4 - Multicast DNS Macro -- this macro assumes that only
# the DEST zone sends mDNS queries. If both zones send
# queries, use the mDNSbi macro.
# #
# /usr/share/shorewall/macro.mDNS # /usr/share/shorewall/macro.mDNS
# #
# This macro handles multicast DNS traffic. # This macro handles multicast DNS traffic
# #
############################################################################### ###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/

View File

@@ -0,0 +1,16 @@
#
# Shorewall version 4 - Bi-directional Multicast DNS Macro.
#
# /usr/share/shorewall/macro.mDNSbi
#
# This macro handles multicast DNS traffic
#
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP
PARAM - 224.0.0.251 udp 5353
PARAM - - udp 32768: 5353
PARAM - 224.0.0.251 2
PARAM DEST SOURCE:224.0.0.251 udp 5353
PARAM DEST SOURCE udp 32768: 5353
PARAM DEST SOURCE:224.0.0.251 2

View File

@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<includepath />

View File

@@ -46,6 +46,7 @@ my $jumpchainref;
my %accountingjumps; my %accountingjumps;
my $asection; my $asection;
my $defaultchain; my $defaultchain;
my $ipsecdir;
my $defaultrestriction; my $defaultrestriction;
my $restriction; my $restriction;
my $accounting_commands = { COMMENT => 0, SECTION => 2 }; my $accounting_commands = { COMMENT => 0, SECTION => 2 };
@@ -92,6 +93,7 @@ sub initialize() {
# These are the legacy values # These are the legacy values
# #
$defaultchain = 'accounting'; $defaultchain = 'accounting';
$ipsecdir = '';
$defaultrestriction = NO_RESTRICT; $defaultrestriction = NO_RESTRICT;
$sectionname = ''; $sectionname = '';
} }
@@ -111,20 +113,25 @@ sub process_section ($) {
if ( $sectionname eq 'INPUT' ) { if ( $sectionname eq 'INPUT' ) {
$defaultchain = 'accountin'; $defaultchain = 'accountin';
$ipsecdir = 'in';
$defaultrestriction = INPUT_RESTRICT; $defaultrestriction = INPUT_RESTRICT;
} elsif ( $sectionname eq 'OUTPUT' ) { } elsif ( $sectionname eq 'OUTPUT' ) {
$defaultchain = 'accountout'; $defaultchain = 'accountout';
$ipsecdir = 'out';
$defaultrestriction = OUTPUT_RESTRICT; $defaultrestriction = OUTPUT_RESTRICT;
} elsif ( $sectionname eq 'FORWARD' ) { } elsif ( $sectionname eq 'FORWARD' ) {
$defaultchain = 'accountfwd'; $defaultchain = 'accountfwd';
$ipsecdir = '';
$defaultrestriction = NO_RESTRICT; $defaultrestriction = NO_RESTRICT;
} else { } else {
fatal_error "The $sectionname SECTION is not allowed when ACCOUNTING_TABLE=filter" unless $acctable eq 'mangle'; fatal_error "The $sectionname SECTION is not allowed when ACCOUNTING_TABLE=filter" unless $acctable eq 'mangle';
if ( $sectionname eq 'PREROUTING' ) { if ( $sectionname eq 'PREROUTING' ) {
$defaultchain = 'accountpre'; $defaultchain = 'accountpre';
$ipsecdir = 'in';
$defaultrestriction = PREROUTE_RESTRICT; $defaultrestriction = PREROUTE_RESTRICT;
} else { } else {
$defaultchain = 'accountpost'; $defaultchain = 'accountpost';
$ipsecdir = 'out';
$defaultrestriction = POSTROUTE_RESTRICT; $defaultrestriction = POSTROUTE_RESTRICT;
} }
} }
@@ -229,6 +236,11 @@ sub process_accounting_rule( ) {
} }
} elsif ( $action =~ /^NFLOG/ ) { } elsif ( $action =~ /^NFLOG/ ) {
$target = validate_level $action; $target = validate_level $action;
} elsif ( $action =~ /^NFACCT\((\w+)\)$/ ) {
require_capability 'NFACCT_MATCH', 'The NFACCT action', 's';
$nfobjects{$1} = 1;
$target = '';
$rule .= "-m nfacct --nfacct-name $1 ";
} else { } else {
( $action, my $cmd ) = split /:/, $action; ( $action, my $cmd ) = split /:/, $action;
@@ -285,7 +297,21 @@ sub process_accounting_rule( ) {
} }
my $chainref = $chain_table{$config{ACCOUNTING_TABLE}}{$chain}; my $chainref = $chain_table{$config{ACCOUNTING_TABLE}}{$chain};
my $dir; my $dir = $ipsecdir;
if ( $asection && $ipsec ne '-' ) {
if ( $ipsecdir ) {
fatal_error "Invalid IPSEC ($ipsec)" if $ipsec =~ /^(?:in|out)\b/;
} else {
if ( $ipsec =~ s/^(?:(in|out)\b)// ) {
$dir = $1;
} else {
fatal_error q(IPSEC rules in the $asection section require that the value begin with 'in' or 'out');
}
}
$rule .= do_ipsec( $dir, $ipsec );
}
if ( ! $chainref ) { if ( ! $chainref ) {
if ( reserved_chain_name( $chain ) ) { if ( reserved_chain_name( $chain ) ) {
@@ -297,6 +323,7 @@ sub process_accounting_rule( ) {
$chainref = ensure_accounting_chain $chain, 0 , $restriction; $chainref = ensure_accounting_chain $chain, 0 , $restriction;
} }
unless ( $asection ) {
$dir = ipsec_chain_name( $chain ); $dir = ipsec_chain_name( $chain );
if ( $ipsec ne '-' ) { if ( $ipsec ne '-' ) {
@@ -310,9 +337,11 @@ sub process_accounting_rule( ) {
warning_message "Adding rule to unreferenced accounting chain $chain" unless reserved_chain_name( $chain ); warning_message "Adding rule to unreferenced accounting chain $chain" unless reserved_chain_name( $chain );
$chainref->{ipsec} = $dir; $chainref->{ipsec} = $dir;
} }
}
} else { } else {
fatal_error "$chain is not an accounting chain" unless $chainref->{accounting}; fatal_error "$chain is not an accounting chain" unless $chainref->{accounting};
unless ( $asection ) {
if ( $ipsec ne '-' ) { if ( $ipsec ne '-' ) {
$dir = $chainref->{ipsec}; $dir = $chainref->{ipsec};
fatal_error "Adding an IPSEC rule into a non-IPSEC chain is not allowed" unless $dir; fatal_error "Adding an IPSEC rule into a non-IPSEC chain is not allowed" unless $dir;
@@ -321,6 +350,7 @@ sub process_accounting_rule( ) {
$restriction |= $chainref->{restriction}; $restriction |= $chainref->{restriction};
} }
} }
}
set_optflags( $chainref, DONT_OPTIMIZE ) if $target eq 'RETURN'; set_optflags( $chainref, DONT_OPTIMIZE ) if $target eq 'RETURN';
@@ -366,7 +396,6 @@ sub process_accounting_rule( ) {
} else { } else {
$jumpchainref->{ipsec} = $chainref->{ipsec}; $jumpchainref->{ipsec} = $chainref->{ipsec};
} }
} }
if ( $rule2 ) { if ( $rule2 ) {
@@ -394,7 +423,7 @@ sub setup_accounting() {
my $nonEmpty = 0; my $nonEmpty = 0;
$nonEmpty |= process_accounting_rule while read_a_line; $nonEmpty |= process_accounting_rule while read_a_line( NORMAL_READ );
clear_comment; clear_comment;

File diff suppressed because it is too large Load Diff

View File

@@ -354,7 +354,7 @@ sub generate_script_3($) {
emit 'cat > ${VARDIR}/.modules << EOF'; emit 'cat > ${VARDIR}/.modules << EOF';
open_file $fn; open_file $fn;
emit_unindented $currentline while read_a_line; emit_unindented $currentline while read_a_line( NORMAL_READ );
emit_unindented 'EOF'; emit_unindented 'EOF';
emit '', 'reload_kernel_modules < ${VARDIR}/.modules'; emit '', 'reload_kernel_modules < ${VARDIR}/.modules';
@@ -368,6 +368,7 @@ sub generate_script_3($) {
emit ''; emit '';
load_ipsets; load_ipsets;
create_nfobjects;
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
emit ( 'if [ "$COMMAND" = refresh ]; then' , emit ( 'if [ "$COMMAND" = refresh ]; then' ,
@@ -665,11 +666,6 @@ sub compiler {
# (Produces no output to the compiled script) # (Produces no output to the compiled script)
# #
process_policies; process_policies;
#
# N O T R A C K
# (Produces no output to the compiled script)
#
setup_notrack;
enable_script; enable_script;
@@ -709,6 +705,14 @@ sub compiler {
# #
setup_proxy_arp; setup_proxy_arp;
emit( "#\n# Disable automatic helper association on kernel 3.5.0 and later\n#" ,
'if [ -f /proc/sys/net/netfilter/nf_conntrack_helper ]; then' ,
' progress_message "Disabling Kernel Automatic Helper Association"',
" echo 0 > /proc/sys/net/netfilter/nf_conntrack_helper",
'fi',
''
);
if ( $scriptfilename || $debug ) { if ( $scriptfilename || $debug ) {
emit 'return 0'; emit 'return 0';
pop_indent; pop_indent;
@@ -788,6 +792,10 @@ sub compiler {
# #
process_rules( $convert ); process_rules( $convert );
# #
# Process the conntrack file
#
setup_conntrack;
#
# Add Tunnel rules. # Add Tunnel rules.
# #
setup_tunnels; setup_tunnels;
@@ -812,16 +820,16 @@ sub compiler {
optimize_level0; optimize_level0;
if ( $config{OPTIMIZE} & 0x1E ) { if ( ( my $optimize = $config{OPTIMIZE} ) & 0x1E ) {
progress_message2 'Optimizing Ruleset...'; progress_message2 'Optimizing Ruleset...';
# #
# Optimize Policy Chains # Optimize Policy Chains
# #
optimize_policy_chains if $config{OPTIMIZE} & 2; optimize_policy_chains if ( $optimize & OPTIMIZE_POLICY_MASK2n4 ) == OPTIMIZE_POLICY_MASK; # Level 2 but not 4
# #
# More Optimization # More Optimization
# #
optimize_ruleset if $config{OPTIMIZE} & 0x1C; optimize_ruleset if $config{OPTIMIZE} & OPTIMIZE_RULESET_MASK;
} }
enable_script; enable_script;
@@ -877,16 +885,16 @@ sub compiler {
optimize_level0; optimize_level0;
if ( $config{OPTIMIZE} & OPTIMIZE_MASK ) { if ( ( my $optimize = $config{OPTIMIZE} & OPTIMIZE_MASK ) ) {
progress_message2 'Optimizing Ruleset...'; progress_message2 'Optimizing Ruleset...';
# #
# Optimize Policy Chains # Optimize Policy Chains
# #
optimize_policy_chains if $config{OPTIMIZE} & OPTIMIZE_POLICY_MASK; optimize_policy_chains if ( $optimize & OPTIMIZE_POLICY_MASK2n4 ) == OPTIMIZE_POLICY_MASK; # Level 2 but not 4
# #
# Ruleset Optimization # Ruleset Optimization
# #
optimize_ruleset if $config{OPTIMIZE} & OPTIMIZE_RULESET_MASK; optimize_ruleset if $optimize & OPTIMIZE_RULESET_MASK;
} }
enable_script if $debug; enable_script if $debug;

File diff suppressed because it is too large Load Diff

View File

@@ -26,7 +26,7 @@
# #
package Shorewall::IPAddrs; package Shorewall::IPAddrs;
require Exporter; require Exporter;
use Shorewall::Config qw( :DEFAULT split_list require_capability in_hex8 numeric_value F_IPV4 F_IPV6 ); use Shorewall::Config qw( :DEFAULT split_list require_capability in_hex8 numeric_value F_IPV4 F_IPV6 :protocols );
use Socket; use Socket;
use strict; use strict;
@@ -48,14 +48,6 @@ our @EXPORT = qw( ALLIPv4
ALLIP ALLIP
NILIP NILIP
ALL ALL
TCP
UDP
UDPLITE
ICMP
DCCP
IPv6_ICMP
SCTP
GRE
validate_address validate_address
validate_net validate_net
@@ -115,14 +107,7 @@ use constant { ALLIPv4 => '0.0.0.0/0' ,
IPv6_LINK_ALLRTRS => 'ff01::2' , IPv6_LINK_ALLRTRS => 'ff01::2' ,
IPv6_SITE_ALLNODES => 'ff02::1' , IPv6_SITE_ALLNODES => 'ff02::1' ,
IPv6_SITE_ALLRTRS => 'ff02::2' , IPv6_SITE_ALLRTRS => 'ff02::2' ,
ICMP => 1, };
TCP => 6,
UDP => 17,
DCCP => 33,
GRE => 47,
IPv6_ICMP => 58,
SCTP => 132,
UDPLITE => 136 };
my @rfc1918_networks = ( "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16" ); my @rfc1918_networks = ( "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16" );

View File

@@ -79,7 +79,7 @@ sub process_tos() {
} }
); );
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) = split_line 'tos file entry', { source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 } ; my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) = split_line 'tos file entry', { source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 } ;
@@ -149,9 +149,9 @@ sub setup_ecn()
warning_message 'ECN will not be applied to forwarded packets' unless have_capability 'MANGLE_FORWARD'; warning_message 'ECN will not be applied to forwarded packets' unless have_capability 'MANGLE_FORWARD';
} ); } );
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
my ($interface, $hosts ) = split_line 'ecn file entry', { interface => 0, hosts => 1 }; my ($interface, $hosts ) = split_line1 'ecn file entry', { interface => 0, host => 1, hosts => 1 }, {}, 2;
fatal_error 'INTERFACE must be specified' if $interface eq '-'; fatal_error 'INTERFACE must be specified' if $interface eq '-';
fatal_error "Unknown interface ($interface)" unless known_interface $interface; fatal_error "Unknown interface ($interface)" unless known_interface $interface;
@@ -227,7 +227,7 @@ sub setup_blacklist() {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
while ( read_a_line ) { while ( read_a_line ( NORMAL_READ ) ) {
if ( $first_entry ) { if ( $first_entry ) {
unless ( @$zones || @$zones1 ) { unless ( @$zones || @$zones1 ) {
@@ -346,7 +346,7 @@ sub remove_blacklist( $ ) {
open $newfile, '>', "$fn.new" or fatal_error "Unable to open $fn.new for output: $!"; open $newfile, '>', "$fn.new" or fatal_error "Unable to open $fn.new for output: $!";
while ( read_a_line(1,1,0) ) { while ( read_a_line( EMBEDDED_ENABLED | EXPAND_VARIABLES ) ) {
my ( $rule, $comment ) = split '#', $currentline, 2; my ( $rule, $comment ) = split '#', $currentline, 2;
if ( $rule =~ /blacklist/ ) { if ( $rule =~ /blacklist/ ) {
@@ -396,7 +396,7 @@ sub convert_blacklist() {
first_entry "Converting $fn..."; first_entry "Converting $fn...";
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $networks, $protocol, $ports, $options ) = split_line 'blacklist file', { networks => 0, proto => 1, port => 2, options => 3 }; my ( $networks, $protocol, $ports, $options ) = split_line 'blacklist file', { networks => 0, proto => 1, port => 2, options => 3 };
if ( $options eq '-' ) { if ( $options eq '-' ) {
@@ -468,7 +468,7 @@ sub convert_blacklist() {
open $blrules, '>', $fn1 or fatal_error "Unable to open $fn1: $!"; open $blrules, '>', $fn1 or fatal_error "Unable to open $fn1: $!";
print $blrules <<'EOF'; print $blrules <<'EOF';
# #
# Shorewall version 5 - Blacklist Rules File # Shorewall version 4.5 - Blacklist Rules File
# #
# For information about entries in this file, type "man shorewall-blrules" # For information about entries in this file, type "man shorewall-blrules"
# #
@@ -554,7 +554,7 @@ sub process_routestopped() {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
while ( read_a_line ) { while ( read_a_line ( NORMAL_READ ) ) {
my ($interface, $hosts, $options , $proto, $ports, $sports ) = my ($interface, $hosts, $options , $proto, $ports, $sports ) =
split_line 'routestopped file', { interface => 0, hosts => 1, options => 2, proto => 3, dport => 4, sport => 5 }; split_line 'routestopped file', { interface => 0, hosts => 1, options => 2, proto => 3, dport => 4, sport => 5 };
@@ -681,7 +681,7 @@ sub add_common_rules ( $ ) {
my $chain; my $chain;
my $dynamicref; my $dynamicref;
my @state = $config{BLACKLISTNEWONLY} ? $globals{UNTRACKED} ? state_imatch 'NEW,INVALID,UNTRACKED' : state_imatch 'NEW,INVALID' : (); my @state = $config{BLACKLISTNEWONLY} ? have_capability( 'RAW_TABLE' ) ? state_imatch 'NEW,INVALID,UNTRACKED' : state_imatch 'NEW,INVALID' : ();
my $faststate = $config{RELATED_DISPOSITION} eq 'ACCEPT' && $config{RELATED_LOG_LEVEL} eq '' ? 'ESTABLISHED,RELATED' : 'ESTABLISHED'; my $faststate = $config{RELATED_DISPOSITION} eq 'ACCEPT' && $config{RELATED_LOG_LEVEL} eq '' ? 'ESTABLISHED,RELATED' : 'ESTABLISHED';
my $level = $config{BLACKLIST_LOGLEVEL}; my $level = $config{BLACKLIST_LOGLEVEL};
my $rejectref = $filter_table->{reject}; my $rejectref = $filter_table->{reject};
@@ -749,7 +749,7 @@ sub add_common_rules ( $ ) {
my $interfaceref = find_interface $interface; my $interfaceref = find_interface $interface;
unless ( $interfaceref->{options}{ignore} ) { unless ( $interfaceref->{options}{ignore} & NO_SFILTER || $interfaceref->{options}{rpfilter} ) {
my @filters = @{$interfaceref->{filter}}; my @filters = @{$interfaceref->{filter}};
@@ -787,6 +787,38 @@ sub add_common_rules ( $ ) {
} }
} }
$list = find_interfaces_by_option('rpfilter');
if ( @$list ) {
$policy = $config{RPFILTER_DISPOSITION};
$level = $config{RPFILTER_LOG_LEVEL};
$audit = $policy =~ s/^A_//;
if ( $level || $audit ) {
#
# Create a chain to log and/or audit and apply the policy
#
$chainref = ensure_mangle_chain 'rplog';
log_rule $level , $chainref , $policy , '' if $level ne '';
add_ijump( $chainref, j => 'AUDIT', targetopts => '--type ' . lc $policy ) if $audit;
add_ijump $chainref, g => $policy eq 'REJECT' ? 'reject' : $policy;
$target = 'rplog';
} else {
$target = $policy eq 'REJECT' ? 'reject' : $policy;
}
add_ijump( ensure_mangle_chain( 'rpfilter' ),
j => $target,
rpfilter => '--validmark --invert',
state_imatch 'NEW,RELATED,INVALID',
@ipsec
);
}
run_user_exit1 'initdone'; run_user_exit1 'initdone';
if ( $upgrade ) { if ( $upgrade ) {
@@ -850,7 +882,7 @@ sub add_common_rules ( $ ) {
add_ijump( $chainref, g => $smurfdest, s => IPv6_MULTICAST ); add_ijump( $chainref, g => $smurfdest, s => IPv6_MULTICAST );
} }
my @state = $globals{UNTRACKED} ? state_imatch 'NEW,INVALID,UNTRACKED' : state_imatch 'NEW,INVALID'; my @state = have_capability( 'RAW_TABLE' ) ? state_imatch 'NEW,INVALID,UNTRACKED' : state_imatch 'NEW,INVALID';
for my $hostref ( @$list ) { for my $hostref ( @$list ) {
$interface = $hostref->[0]; $interface = $hostref->[0];
@@ -1097,7 +1129,7 @@ sub setup_mac_lists( $ ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $original_disposition, $interface, $mac, $addresses ) = split_line1 'maclist file', { disposition => 0, interface => 1, mac => 2, addresses => 3 }; my ( $original_disposition, $interface, $mac, $addresses ) = split_line1 'maclist file', { disposition => 0, interface => 1, mac => 2, addresses => 3 };
@@ -1155,7 +1187,7 @@ sub setup_mac_lists( $ ) {
my @policy = have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : (); my @policy = have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : ();
my @source = imatch_source_net $hostref->[2]; my @source = imatch_source_net $hostref->[2];
my @state = $globals{UNTRACKED} ? state_imatch 'NEW,UNTRACKED' : state_imatch 'NEW'; my @state = have_capability( 'RAW_TABLE' ) ? state_imatch 'NEW,UNTRACKED' : state_imatch 'NEW';
if ( $table eq 'filter' ) { if ( $table eq 'filter' ) {
my $chainref = source_exclusion( $hostref->[3], $filter_table->{mac_chain $interface} ); my $chainref = source_exclusion( $hostref->[3], $filter_table->{mac_chain $interface} );
@@ -1310,15 +1342,22 @@ sub generate_source_rules( $$$;@ ) {
sub handle_loopback_traffic() { sub handle_loopback_traffic() {
my @zones = ( vserver_zones, firewall_zone ); my @zones = ( vserver_zones, firewall_zone );
my $natout = $nat_table->{OUTPUT}; my $natout = $nat_table->{OUTPUT};
my $rawout = $raw_table->{OUTPUT};
my $rulenum = 0; my $rulenum = 0;
my $outchainref; my $outchainref;
my @rule; my @rule;
if ( @zones > 1 ) { if ( @zones > 1 ) {
#
# We have a vserver zone -- route output through a separate chain
#
$outchainref = new_standard_chain 'loopback'; $outchainref = new_standard_chain 'loopback';
add_ijump $filter_table->{OUTPUT}, j => $outchainref, o => 'lo'; add_ijump $filter_table->{OUTPUT}, j => $outchainref, o => 'lo';
} else { } else {
#
# Only the firewall -- just use the OUTPUT chain
#
$outchainref = $filter_table->{OUTPUT}; $outchainref = $filter_table->{OUTPUT};
@rule = ( o => 'lo'); @rule = ( o => 'lo');
} }
@@ -1327,20 +1366,48 @@ sub handle_loopback_traffic() {
my $z1ref = find_zone( $z1 ); my $z1ref = find_zone( $z1 );
my $type1 = $z1ref->{type}; my $type1 = $z1ref->{type};
my $natref = $nat_table->{dnat_chain $z1}; my $natref = $nat_table->{dnat_chain $z1};
my $notrackref = $raw_table->{notrack_chain( $z1 )};
#
# Add jumps in the 'output' chain to the rules chains
#
if ( $type1 == FIREWALL ) { if ( $type1 == FIREWALL ) {
for my $z2 ( @zones ) { for my $z2 ( @zones ) {
my $chain = rules_target( $z1, $z2 ); my $chain = rules_target( $z1, $z2 );
generate_dest_rules( $outchainref, $chain, $z2, @rule ) if $chain; generate_dest_rules( $outchainref, $chain, $z2, @rule ) if $chain;
} }
#
# Handle conntrack
#
if ( $notrackref ) {
add_ijump $rawout, j => $notrackref if $notrackref->{referenced};
}
} else { } else {
for my $z2 ( @zones ) { for my $z2 ( @zones ) {
generate_source_rules( $outchainref, $z1, $z2, @rule ); generate_source_rules( $outchainref, $z1, $z2, @rule );
} }
#
# Handle conntrack rules
#
if ( $notrackref->{referenced} ) {
for my $hostref ( @{defined_zone( $z1 )->{hosts}{ip}{'%vserver%'}} ) {
my $exclusion = source_exclusion( $hostref->{exclusions}, $notrackref);
my @ipsec_match = match_ipsec_in $z1 , $hostref;
for my $net ( @{$hostref->{hosts}} ) {
add_ijump( $rawout,
j => $exclusion ,
imatch_source_net $net,
@ipsec_match );
}
}
}
} }
if ( $natref && $natref->{referenced} ) { if ( $natref && $natref->{referenced} ) {
#
# There are DNAT rules with this zone as the source -- add jumps from the nat OUTPUT chain
#
my $source_hosts_ref = defined_zone( $z1 )->{hosts}; my $source_hosts_ref = defined_zone( $z1 )->{hosts};
for my $typeref ( values %{$source_hosts_ref} ) { for my $typeref ( values %{$source_hosts_ref} ) {
@@ -1368,6 +1435,7 @@ sub add_interface_jumps {
our %forward_jump_added; our %forward_jump_added;
my $lo_jump_added = 0; my $lo_jump_added = 0;
my @interfaces = grep $_ ne '%vserver%', @_; my @interfaces = grep $_ ne '%vserver%', @_;
my $dummy;
# #
# Add Nat jumps # Add Nat jumps
# #
@@ -1389,6 +1457,8 @@ sub add_interface_jumps {
insert_ijump ( $raw_table->{PREROUTING}, j => prerouting_chain( $interface ), 0, imatch_source_dev( $interface) ) if $raw_table->{prerouting_chain $interface}; insert_ijump ( $raw_table->{PREROUTING}, j => prerouting_chain( $interface ), 0, imatch_source_dev( $interface) ) if $raw_table->{prerouting_chain $interface};
insert_ijump ( $raw_table->{OUTPUT}, j => output_chain( $interface ), 0, imatch_dest_dev( $interface) ) if $raw_table->{output_chain $interface}; insert_ijump ( $raw_table->{OUTPUT}, j => output_chain( $interface ), 0, imatch_dest_dev( $interface) ) if $raw_table->{output_chain $interface};
} }
add_ijump( $mangle_table->{PREROUTING}, j => 'rpfilter' , imatch_source_dev( $interface ) ) if interface_has_option( $interface, 'rpfilter', $dummy );
} }
# #
# Add the jumps to the interface chains from filter FORWARD, INPUT, OUTPUT # Add the jumps to the interface chains from filter FORWARD, INPUT, OUTPUT
@@ -1403,11 +1473,12 @@ sub add_interface_jumps {
if ( $interfaceref->{options}{port} ) { if ( $interfaceref->{options}{port} ) {
my $bridge = $interfaceref->{bridge}; my $bridge = $interfaceref->{bridge};
add_ijump ( $filter_table->{forward_chain $bridge}, add_ijump ( $filter_table->{forward_chain $bridge},
j => 'ACCEPT', j => 'ACCEPT',
imatch_source_dev( $interface, 1), imatch_source_dev( $interface, 1),
imatch_dest_dev( $interface, 1) imatch_dest_dev( $interface, 1)
) unless $interfaceref->{nets} || ! $interfaceref->{options}{bridge}; ) unless $interfaceref->{nets};
add_ijump( $filter_table->{forward_chain $bridge} , add_ijump( $filter_table->{forward_chain $bridge} ,
j => $forwardref , j => $forwardref ,
@@ -1442,56 +1513,30 @@ sub add_interface_jumps {
handle_loopback_traffic; handle_loopback_traffic;
} }
# Generate the rules matrix.
# #
# Stealing a comment from the Burroughs B6700 MCP Operating System source, "generate_matrix makes a sow's ear out of a silk purse". # Do the initial matrix processing for a complex zone
# #
# The biggest disadvantage of the zone-policy-rule model used by Shorewall is that it doesn't scale well as the number of zones increases (Order N**2 where N = number of zones). sub handle_complex_zone( $$ ) {
# A major goal of the rewrite of the compiler in Perl was to restrict those scaling effects to this function and the rules that it generates. my ( $zone, $zoneref ) = @_;
#
# The function traverses the full "source-zone by destination-zone" matrix and generates the rules necessary to direct traffic through the right set of filter-table and our %input_jump_added;
# nat-table rules. our %output_jump_added;
# our %forward_jump_added;
sub generate_matrix() { our %ipsec_jump_added;
my @interfaces = ( all_interfaces );
# #
# Should this be the real PREROUTING chain? # Complex zone or we have more than two off-firewall zones -- Shorewall::Rules::classic_blacklist created a zone forwarding chain
#
my $preroutingref = ensure_chain 'nat', 'dnat';
my $fw = firewall_zone;
my @zones = off_firewall_zones;
my @vservers = vserver_zones;
my $notrackref = $raw_table->{notrack_chain $fw};
my @state = $config{BLACKLISTNEWONLY} ? $globals{UNTRACKED} ? state_imatch 'NEW,INVALID,UNTRACKED' : state_imatch 'NEW,INVALID' : ();
my $interface_jumps_added = 0;
our %input_jump_added = ();
our %output_jump_added = ();
our %forward_jump_added = ();
my %ipsec_jump_added = ();
progress_message2 'Generating Rule Matrix...';
progress_message ' Handling complex zones...';
#
# Special processing for complex configurations
#
for my $zone ( @zones ) {
my $zoneref = find_zone( $zone );
next if @zones <= 2 && ! $zoneref->{complex};
#
# Complex zone or we have more than one non-firewall zone -- process_rules created a zone forwarding chain
# #
my $frwd_ref = $filter_table->{zone_forward_chain( $zone )}; my $frwd_ref = $filter_table->{zone_forward_chain( $zone )};
assert( $frwd_ref, $zone );
#
# Add Zone mark if any
#
add_ijump( $frwd_ref , j => 'MARK --set-mark ' . in_hex( $zoneref->{mark} ) . '/' . in_hex( $globals{ZONE_MASK} ) ) if $zoneref->{mark}; add_ijump( $frwd_ref , j => 'MARK --set-mark ' . in_hex( $zoneref->{mark} ) . '/' . in_hex( $globals{ZONE_MASK} ) ) if $zoneref->{mark};
if ( have_ipsec ) { if ( have_ipsec ) {
# #
# Because policy match only matches an 'in' or an 'out' policy (but not both), we have to place the # In general, policy match can only match an 'in' or an 'out' policy (but not both), so we place the
# '--pol ipsec --dir in' rules at the front of the (interface) forwarding chains. Otherwise, decrypted packets # '--pol ipsec --dir in' rules at the front of the (interface) forwarding chains. Otherwise, decrypted packets
# can match '--pol none --dir out' rules and send the packets down the wrong rules chain. # can match '--pol none --dir out' rules and send the packets down the wrong rules chain.
# #
@@ -1504,32 +1549,57 @@ sub generate_matrix() {
my $interfaceref = find_interface $interface; my $interfaceref = find_interface $interface;
if ( use_forward_chain( $interface, $sourcechainref ) ) { if ( use_forward_chain( $interface, $sourcechainref ) ) {
#
# Use the interface forward chain
#
if ( $interfaceref->{ports} && $interfaceref->{options}{bridge} ) { if ( $interfaceref->{ports} && $interfaceref->{options}{bridge} ) {
#
# This is a bridge with ports
#
@interfacematch = imatch_source_dev $interface; @interfacematch = imatch_source_dev $interface;
#
# Copy the rules from the interface forward chain to the zone forward chain unless they have already been copied
#
copy_rules( $sourcechainref, $frwd_ref, 1 ) unless $ipsec_jump_added{$zone}++; copy_rules( $sourcechainref, $frwd_ref, 1 ) unless $ipsec_jump_added{$zone}++;
#
# Jump directly from FORWARD to the zone forward chain
#
$sourcechainref = $filter_table->{FORWARD}; $sourcechainref = $filter_table->{FORWARD};
} elsif ( $interfaceref->{options}{port} ) { } elsif ( $interfaceref->{options}{port} ) {
#
# The forwarding chain for a bridge with ports is always used -- use physdev match for this interface
#
add_ijump( $filter_table->{ forward_chain $interfaceref->{bridge} } , add_ijump( $filter_table->{ forward_chain $interfaceref->{bridge} } ,
j => $sourcechainref , j => $sourcechainref ,
imatch_source_dev( $interface , 1 ) ) imatch_source_dev( $interface , 1 ) )
unless $forward_jump_added{$interface}++; unless $forward_jump_added{$interface}++;
} else { } else {
#
# Add jump from FORWARD to the intrface forward chain
#
add_ijump $filter_table->{FORWARD} , j => $sourcechainref, imatch_source_dev( $interface ) unless $forward_jump_added{$interface}++; add_ijump $filter_table->{FORWARD} , j => $sourcechainref, imatch_source_dev( $interface ) unless $forward_jump_added{$interface}++;
} }
} else { } else {
if ( $interfaceref->{options}{port} ) { if ( $interfaceref->{options}{port} ) {
#
# The forwarding chain for a bridge with ports is always used -- use physdev match
#
$sourcechainref = $filter_table->{ forward_chain $interfaceref->{bridge} }; $sourcechainref = $filter_table->{ forward_chain $interfaceref->{bridge} };
@interfacematch = imatch_source_dev $interface, 1; @interfacematch = imatch_source_dev $interface, 1;
} else { } else {
$sourcechainref = $filter_table->{FORWARD}; $sourcechainref = $filter_table->{FORWARD};
@interfacematch = imatch_source_dev $interface; @interfacematch = imatch_source_dev $interface;
} }
#
# copy any rules from the interface forward chain to the zone forward chain
#
move_rules( $filter_table->{forward_chain $interface} , $frwd_ref ); move_rules( $filter_table->{forward_chain $interface} , $frwd_ref );
} }
my $arrayref = $source_ref->{$interface}; my $arrayref = $source_ref->{$interface};
#
# Now add the jumps from the source chain (interface forward or FORWARD) to the zone forward chain
#
for my $hostref ( @{$arrayref} ) { for my $hostref ( @{$arrayref} ) {
my @ipsec_match = match_ipsec_in $zone , $hostref; my @ipsec_match = match_ipsec_in $zone , $hostref;
for my $net ( @{$hostref->{hosts}} ) { for my $net ( @{$hostref->{hosts}} ) {
@@ -1544,41 +1614,24 @@ sub generate_matrix() {
} }
} }
} }
} }
#
# The passed zone is a sub-zone. We need to determine if
#
# a) A parent zone defines DNAT/REDIRECT or notrack rules; and
# b) The current zone has a CONTINUE policy to some other zone.
#
# If a) but not b), then we must avoid sending packets from this
# zone through the DNAT/REDIRECT or notrack chain for the parent.
#
sub handle_nested_zone( $$ ) {
my ( $zone, $zoneref ) = @_;
# #
# NOTRACK from firewall # Function returns this 3-tuple
# #
add_ijump $raw_table->{OUTPUT}, j => $notrackref if $notrackref->{referenced}; my ( $nested, $parenthasnat, $parenthasnotrack ) = ( 1, 0, 0 );
#
# Main source-zone matrix-generation loop
#
progress_message ' Entering main matrix-generation loop...';
for my $zone ( @zones ) {
my $zoneref = find_zone( $zone );
my $source_hosts_ref = $zoneref->{hosts};
my $chain1 = rules_target firewall_zone , $zone;
my $chain2 = rules_target $zone, firewall_zone;
my $type = $zoneref->{type};
my $frwd_ref = $filter_table->{zone_forward_chain $zone};
my $chain = 0;
my $dnatref = ensure_chain 'nat' , dnat_chain( $zone );
my $notrackref = ensure_chain 'raw' , notrack_chain( $zone );
my $nested = @{$zoneref->{parents}};
my $parenthasnat = 0;
my $parenthasnotrack = 0;
if ( $nested ) {
#
# This is a sub-zone. We need to determine if
#
# a) A parent zone defines DNAT/REDIRECT or notrack rules; and
# b) The current zone has a CONTINUE policy to some other zone.
#
# If a) but not b), then we must avoid sending packets from this
# zone through the DNAT/REDIRECT or notrack chain for the parent.
#
for my $parent ( @{$zoneref->{parents}} ) { for my $parent ( @{$zoneref->{parents}} ) {
my $ref1 = $nat_table->{dnat_chain $parent} || {}; my $ref1 = $nat_table->{dnat_chain $parent} || {};
my $ref2 = $raw_table->{notrack_chain $parent} || {}; my $ref2 = $raw_table->{notrack_chain $parent} || {};
@@ -1604,78 +1657,102 @@ sub generate_matrix() {
# #
$nested = 0; $nested = 0;
} }
}
#
# Take care of PREROUTING, INPUT and OUTPUT jumps
#
for my $typeref ( values %$source_hosts_ref ) {
for my $interface ( sort { interface_number( $a ) <=> interface_number( $b ) } keys %$typeref ) {
my $arrayref = $typeref->{$interface};
my $interfaceref = find_interface $interface;
my $isport = $interfaceref->{options}{port};
my $bridge = $interfaceref->{bridge};
if ( get_physical( $interface ) eq '+' ) { ( $nested, $parenthasnat, $parenthasnotrack );
# }
# Insert the interface-specific jumps before this one which is not interface-specific
#
add_interface_jumps(@interfaces) unless $interface_jumps_added++;
}
for my $hostref ( @$arrayref ) { #
my @ipsec_in_match = match_ipsec_in $zone , $hostref; # Add output jump to the passed zone:interface:hostref:net
my @ipsec_out_match = match_ipsec_out $zone , $hostref; #
my $exclusions = $hostref->{exclusions}; sub add_output_jumps( $$$$$$$ ) {
my ( $zone, $interface, $hostref, $net, $exclusions, $isport, $bridge, ) = @_;
for my $net ( @{$hostref->{hosts}} ) { our @vservers;
my @dest = imatch_dest_net $net; our %output_jump_added;
if ( $chain1 && ! ( zone_type( $zone) & BPORT ) ) { my $chain1 = rules_target firewall_zone , $zone;
my $chain1ref = $filter_table->{$chain1}; my $chain1ref = $filter_table->{$chain1};
my $nextchain = dest_exclusion( $exclusions, $chain1 ); my $nextchain = dest_exclusion( $exclusions, $chain1 );
my $outputref; my $outputref;
my $interfacechainref = $filter_table->{output_chain $interface}; my $interfacechainref = $filter_table->{output_chain $interface};
my @interfacematch; my @interfacematch;
my $use_output = 0; my $use_output = 0;
my @dest = imatch_dest_net $net;
my @ipsec_out_match = match_ipsec_out $zone , $hostref;
if ( @vservers || use_output_chain( $interface, $interfacechainref ) || ( @{$interfacechainref->{rules}} && ! $chain1ref ) ) { if ( @vservers || use_output_chain( $interface, $interfacechainref ) || ( @{$interfacechainref->{rules}} && ! $chain1ref ) ) {
#
# - There are vserver zones (so OUTPUT will have multiple source; or
# - We must use the interface output chain; or
# - There are rules in the interface chain and none in the rules chain
#
# In any of these cases use the inteface output chain
#
$outputref = $interfacechainref; $outputref = $interfacechainref;
if ( $isport ) { if ( $isport ) {
#
# It is a bridge port zone -- use the bridges output chain and match the physdev
#
add_ijump( $filter_table->{ output_chain $bridge }, add_ijump( $filter_table->{ output_chain $bridge },
j => $outputref , j => $outputref ,
imatch_dest_dev( $interface, 1 ) ) imatch_dest_dev( $interface, 1 ) )
unless $output_jump_added{$interface}++; unless $output_jump_added{$interface}++;
} else { } else {
#
# Not a bridge -- match the input interface
#
add_ijump $filter_table->{OUTPUT}, j => $outputref, imatch_dest_dev( $interface ) unless $output_jump_added{$interface}++; add_ijump $filter_table->{OUTPUT}, j => $outputref, imatch_dest_dev( $interface ) unless $output_jump_added{$interface}++;
} }
$use_output = 1; $use_output = 1;
unless ( lc $net eq IPv6_LINKLOCAL ) { unless ( lc $net eq IPv6_LINKLOCAL ) {
for my $vzone ( vserver_zones ) { #
# Generate output rules for the vservers
#
for my $vzone ( @vservers ) {
generate_source_rules ( $outputref, $vzone, $zone, @dest ); generate_source_rules ( $outputref, $vzone, $zone, @dest );
} }
} }
} elsif ( $isport ) { } elsif ( $isport ) {
#
# It is a bridge port zone -- use the bridges output chain and match the physdev
#
$outputref = $filter_table->{ output_chain $bridge }; $outputref = $filter_table->{ output_chain $bridge };
@interfacematch = imatch_dest_dev $interface, 1; @interfacematch = imatch_dest_dev $interface, 1;
} else { } else {
#
# Just put the jump in the OUTPUT chain
#
$outputref = $filter_table->{OUTPUT}; $outputref = $filter_table->{OUTPUT};
@interfacematch = imatch_dest_dev $interface; @interfacematch = imatch_dest_dev $interface;
} }
#
# Add the jump
#
add_ijump $outputref , j => $nextchain, @interfacematch, @dest, @ipsec_out_match; add_ijump $outputref , j => $nextchain, @interfacematch, @dest, @ipsec_out_match;
#
# Add jump for broadcast
#
add_ijump( $outputref , j => $nextchain, @interfacematch, d => '255.255.255.255' , @ipsec_out_match ) add_ijump( $outputref , j => $nextchain, @interfacematch, d => '255.255.255.255' , @ipsec_out_match )
if $family == F_IPV4 && $hostref->{options}{broadcast}; if $family == F_IPV4 && $hostref->{options}{broadcast};
#
# Move the rules from the interface output chain if we didn't use it
#
move_rules( $interfacechainref , $chain1ref ) unless $use_output; move_rules( $interfacechainref , $chain1ref ) unless $use_output;
} }
clearrule; #
# Add prerouting jumps from the passed zone:interface:hostref:net
#
sub add_prerouting_jumps( $$$$$$$$ ) {
my ( $zone, $interface, $hostref, $net, $exclusions, $nested, $parenthasnat, $parenthasnotrack ) = @_;
next if $hostref->{options}{destonly}; my $dnatref = $nat_table->{dnat_chain( $zone )};
my $preroutingref = $nat_table->{PREROUTING};
my $notrackref = ensure_chain 'raw' , notrack_chain( $zone );
my @ipsec_in_match = match_ipsec_in $zone , $hostref;
my @source = imatch_source_net $net; my @source = imatch_source_net $net;
@@ -1690,13 +1767,6 @@ sub generate_matrix() {
@source, @source,
@ipsec_in_match ); @ipsec_in_match );
if ( get_physical( $interface ) eq '+' ) {
#
# The jump from the PREROUTING chain to dnat may not have been added above
#
addnatjump 'PREROUTING', 'dnat' unless $preroutingref->{references}{PREROUTING};
}
check_optimization( $dnatref ) if @source; check_optimization( $dnatref ) if @source;
} }
@@ -1707,7 +1777,6 @@ sub generate_matrix() {
# #
add_ijump $raw_table->{PREROUTING}, j => source_exclusion( $exclusions, $notrackref), imatch_source_dev( $interface), @source, @ipsec_in_match; add_ijump $raw_table->{PREROUTING}, j => source_exclusion( $exclusions, $notrackref), imatch_source_dev( $interface), @source, @ipsec_in_match;
} }
# #
# If this zone has parents with DNAT/REDIRECT or notrack rules and there are no CONTINUE polcies with this zone as the source # If this zone has parents with DNAT/REDIRECT or notrack rules and there are no CONTINUE polcies with this zone as the source
# then add a RETURN jump for this source network. # then add a RETURN jump for this source network.
@@ -1716,90 +1785,157 @@ sub generate_matrix() {
add_ijump $preroutingref, j => 'RETURN', imatch_source_dev( $interface), @source, @ipsec_in_match if $parenthasnat; add_ijump $preroutingref, j => 'RETURN', imatch_source_dev( $interface), @source, @ipsec_in_match if $parenthasnat;
add_ijump $raw_table->{PREROUTING}, j => 'RETURN', imatch_source_dev( $interface), @source, @ipsec_in_match if $parenthasnotrack; add_ijump $raw_table->{PREROUTING}, j => 'RETURN', imatch_source_dev( $interface), @source, @ipsec_in_match if $parenthasnotrack;
} }
}
#
# Add input jump from the passed zone:interface:hostref:net
#
sub add_input_jumps( $$$$$$$$ ) {
my ( $zone, $interface, $hostref, $net, $exclusions, $frwd_ref, $isport, $bridge ) = @_;
our @vservers;
our %input_jump_added;
my $chain2 = rules_target $zone, firewall_zone;
my $chain2ref = $filter_table->{$chain2}; my $chain2ref = $filter_table->{$chain2};
my $inputchainref; my $inputchainref;
my $interfacechainref = $filter_table->{input_chain $interface}; my $interfacechainref = $filter_table->{input_chain $interface};
my @interfacematch; my @interfacematch;
my $use_input; my $use_input;
my @source = imatch_source_net $net;
my @ipsec_in_match = match_ipsec_in $zone , $hostref;
if ( @vservers || use_input_chain( $interface, $interfacechainref ) || ! $chain2 || ( @{$interfacechainref->{rules}} && ! $chain2ref ) ) { if ( @vservers || use_input_chain( $interface, $interfacechainref ) || ! $chain2 || ( @{$interfacechainref->{rules}} && ! $chain2ref ) ) {
#
# - There are vserver zones (so INPUT will have multiple destinations; or
# - We must use the interface input chain; or
# - The zone->firewall policy is CONTINUE; or
# - There are rules in the interface chain and none in the rules chain
#
# In any of these cases use the inteface input chain
#
$inputchainref = $interfacechainref; $inputchainref = $interfacechainref;
if ( $isport ) { if ( $isport ) {
#
# It is a bridge port zone -- use the bridges input chain and match the physdev
#
add_ijump( $filter_table->{ input_chain $bridge }, add_ijump( $filter_table->{ input_chain $bridge },
j => $inputchainref , j => $inputchainref ,
imatch_source_dev($interface, 1) ) imatch_source_dev($interface, 1) )
unless $input_jump_added{$interface}++; unless $input_jump_added{$interface}++;
} else { } else {
#
# Not a bridge -- match the input interface
#
add_ijump $filter_table->{INPUT}, j => $inputchainref, imatch_source_dev($interface) unless $input_jump_added{$interface}++; add_ijump $filter_table->{INPUT}, j => $inputchainref, imatch_source_dev($interface) unless $input_jump_added{$interface}++;
} }
$use_input = 1; $use_input = 1;
unless ( lc $net eq IPv6_LINKLOCAL ) { unless ( lc $net eq IPv6_LINKLOCAL ) {
#
# Generate input rules for the vservers
#
for my $vzone ( @vservers ) { for my $vzone ( @vservers ) {
my $target = rules_target( $zone, $vzone ); my $target = rules_target( $zone, $vzone );
generate_dest_rules( $inputchainref, $target, $vzone, @source, @ipsec_in_match ) if $target; generate_dest_rules( $inputchainref, $target, $vzone, @source, @ipsec_in_match ) if $target;
} }
} }
} elsif ( $isport ) { } elsif ( $isport ) {
#
# It is a bridge port zone -- use the bridges input chain and match the physdev
#
$inputchainref = $filter_table->{ input_chain $bridge }; $inputchainref = $filter_table->{ input_chain $bridge };
@interfacematch = imatch_source_dev $interface, 1; @interfacematch = imatch_source_dev $interface, 1;
} else { } else {
#
# Just put the jump in the INPUT chain
#
$inputchainref = $filter_table->{INPUT}; $inputchainref = $filter_table->{INPUT};
@interfacematch = imatch_source_dev $interface; @interfacematch = imatch_source_dev $interface;
} }
if ( $chain2 ) { if ( $chain2 ) {
#
# Add the jump from the input chain to the rules chain
#
add_ijump $inputchainref, j => source_exclusion( $exclusions, $chain2 ), @interfacematch, @source, @ipsec_in_match; add_ijump $inputchainref, j => source_exclusion( $exclusions, $chain2 ), @interfacematch, @source, @ipsec_in_match;
move_rules( $interfacechainref , $chain2ref ) unless $use_input; move_rules( $interfacechainref , $chain2ref ) unless $use_input;
} }
}
#
# This function is called when there is forwarding and this net isn't IPSEC protected. It adds the jump for this net to the zone forwarding chain.
#
sub add_forward_jump( $$$$$$$$ ) {
my ( $zone, $interface, $hostref, $net, $exclusions, $frwd_ref, $isport, $bridge ) = @_;
our %forward_jump_added;
my @source = imatch_source_net $net;
my @ipsec_in_match = match_ipsec_in $zone , $hostref;
if ( $frwd_ref && $hostref->{ipsec} ne 'ipsec' ) {
my $ref = source_exclusion( $exclusions, $frwd_ref ); my $ref = source_exclusion( $exclusions, $frwd_ref );
my $forwardref = $filter_table->{forward_chain $interface}; my $forwardref = $filter_table->{forward_chain $interface};
if ( use_forward_chain $interface, $forwardref ) { if ( use_forward_chain $interface, $forwardref ) {
#
# We must use the interface forwarding chain -- add the jump from the interface forward chain to the zone forward chain.
#
add_ijump $forwardref , j => $ref, @source, @ipsec_in_match; add_ijump $forwardref , j => $ref, @source, @ipsec_in_match;
if ( $isport ) { if ( $isport ) {
#
# It is a bridge port zone -- use the bridges input chain and match the physdev
#
add_ijump( $filter_table->{ forward_chain $bridge } , add_ijump( $filter_table->{ forward_chain $bridge } ,
j => $forwardref , j => $forwardref ,
imatch_source_dev( $interface , 1 ) ) imatch_source_dev( $interface , 1 ) )
unless $forward_jump_added{$interface}++; unless $forward_jump_added{$interface}++;
} else { } else {
#
# Not a bridge -- match the input interface
#
add_ijump $filter_table->{FORWARD} , j => $forwardref, imatch_source_dev( $interface ) unless $forward_jump_added{$interface}++; add_ijump $filter_table->{FORWARD} , j => $forwardref, imatch_source_dev( $interface ) unless $forward_jump_added{$interface}++;
} }
} else { } else {
if ( $isport ) { if ( $isport ) {
#
# It is a bridge port zone -- use the bridges input chain and match the physdev
#
add_ijump( $filter_table->{ forward_chain $bridge } , add_ijump( $filter_table->{ forward_chain $bridge } ,
j => $ref , j => $ref ,
imatch_source_dev( $interface, 1 ) , imatch_source_dev( $interface, 1 ) ,
@source, @source,
@ipsec_in_match ); @ipsec_in_match );
} else { } else {
#
# Not a bridge -- match the input interface
#
add_ijump $filter_table->{FORWARD} , j => $ref, imatch_source_dev( $interface ) , @source, @ipsec_in_match; add_ijump $filter_table->{FORWARD} , j => $ref, imatch_source_dev( $interface ) , @source, @ipsec_in_match;
} }
move_rules ( $forwardref , $frwd_ref ); move_rules ( $forwardref , $frwd_ref );
} }
} }
}
}
}
}
# #
# F O R W A R D I N G # Generate the list of destination zones from the passed source zone when optimization level 1 is selected
# #
my @dest_zones; # - Drop zones where the policy to that zone is 'NONE'
# - Drop this zone if it has only one interface without 'routeback'
# - Drop BPORT zones that are not on the same bridge
# - Eliminate duplicate zones that have the same '2all' (-all) rules chain.
#
sub optimize1_zones( $$@ ) {
my $zone = shift;
my $zoneref = shift;
my $last_chain = ''; my $last_chain = '';
my @dest_zones;
if ( $config{OPTIMIZE} & 1 ) {
my @temp_zones; my @temp_zones;
for my $zone1 ( @zones ) { for my $zone1 ( @_ ) {
my $zone1ref = find_zone( $zone1 ); my $zone1ref = find_zone( $zone1 );
my $policy = $filter_table->{rules_chain( ${zone}, ${zone1} )}->{policy}; my $policy = $filter_table->{rules_chain( ${zone}, ${zone1} )}->{policy};
@@ -1839,12 +1975,131 @@ sub generate_matrix() {
push @dest_zones, @temp_zones; push @dest_zones, @temp_zones;
$last_chain = ''; $last_chain = '';
} }
( $last_chain, @dest_zones );
}
# Generate the rules matrix.
#
# Stealing a comment from the Burroughs B6700 MCP Operating System source, "generate_matrix makes a sow's ear out of a silk purse".
#
# The biggest disadvantage of the zone-policy-rule model used by Shorewall is that it doesn't scale well as the number of zones increases (Order N**2 where N = number of zones).
# A major goal of the rewrite of the compiler in Perl was to restrict those scaling effects to this function and the rules that it generates.
#
# The function traverses the full "source-zone by destination-zone" matrix and generates the rules necessary to direct traffic through the right set of filter-table and
# nat-table rules.
#
sub generate_matrix() {
my @interfaces = ( all_interfaces );
#
# Should this be the real PREROUTING chain?
#
my @zones = off_firewall_zones;
our @vservers = vserver_zones;
my $interface_jumps_added = 0;
our %input_jump_added = ();
our %output_jump_added = ();
our %forward_jump_added = ();
our %ipsec_jump_added = ();
progress_message2 'Generating Rule Matrix...';
progress_message ' Handling complex zones...';
#
# Special processing for configurations with more than 2 off-firewall zones or with other special considerations like IPSEC.
# Don't be tempted to move this logic into the zone loop below -- it won't work.
#
for my $zone ( @zones ) {
my $zoneref = find_zone( $zone );
if ( @zones > 2 || $zoneref->{complex} ) {
handle_complex_zone( $zone, $zoneref );
} else {
new_standard_chain zone_forward_chain( $zone ) if @zones > 1;
}
}
#
# Main source-zone matrix-generation loop
#
progress_message ' Entering main matrix-generation loop...';
for my $zone ( @zones ) {
my $zoneref = find_zone( $zone );
my $source_hosts_ref = $zoneref->{hosts};
my $frwd_ref = $filter_table->{zone_forward_chain $zone};
my $nested = @{$zoneref->{parents}};
my $parenthasnat = 0;
my $parenthasnotrack = 0;
#
# Create the zone's dnat chain
#
ensure_chain 'nat', dnat_chain( $zone );
( $nested, $parenthasnat, $parenthasnotrack) = handle_nested_zone( $zone, $zoneref ) if $nested;
#
# Take care of PREROUTING, INPUT and OUTPUT jumps
#
for my $typeref ( values %$source_hosts_ref ) {
for my $interface ( sort { interface_number( $a ) <=> interface_number( $b ) } keys %$typeref ) {
if ( get_physical( $interface ) eq '+' ) {
#
# Insert the interface-specific jumps before this one which is not interface-specific
#
add_interface_jumps(@interfaces) unless $interface_jumps_added++;
}
my $interfaceref = find_interface $interface;
my $isport = $interfaceref->{options}{port};
my $bridge = $interfaceref->{bridge};
for my $hostref ( @{$typeref->{$interface}} ) {
my $exclusions = $hostref->{exclusions};
for my $net ( @{$hostref->{hosts}} ) {
#
# OUTPUT
#
if ( rules_target( firewall_zone, $zone ) && ! ( zone_type( $zone) & BPORT ) ) {
#
# Policy from the firewall to this zone is not 'CONTINUE' and this isn't a bport zone
#
add_output_jumps( $zone, $interface, $hostref, $net, $exclusions, $isport, $bridge );
}
clearrule;
unless( $hostref->{options}{destonly} ) {
#
# PREROUTING
#
add_prerouting_jumps( $zone, $interface, $hostref, $net, $exclusions, $nested, $parenthasnat, $parenthasnotrack );
#
# INPUT
#
add_input_jumps( $zone, $interface, $hostref, $net, $exclusions, $frwd_ref, $isport, $bridge );
#
# FORWARDING Jump for non-IPSEC host group
#
add_forward_jump( $zone, $interface, $hostref, $net, $exclusions, $frwd_ref, $isport, $bridge ) if $frwd_ref && $hostref->{ipsec} ne 'ipsec';
}
} # Subnet Loop
} # Hostref Loop
} # Interface Loop
} #Type Loop
if ( $frwd_ref ) {
#
# F O R W A R D I N G
#
my @dest_zones;
my $last_chain = '';
if ( $config{OPTIMIZE} & 1 ) {
( $last_chain , @dest_zones ) = optimize1_zones($zone, $zoneref, @zones );
} else { } else {
@dest_zones = @zones ; @dest_zones = @zones ;
} }
# #
# Here it is -- THE BIG UGLY!!!!!!!!!!!!
#
# We now loop through the destination zones creating jumps to the rules chain for each source/dest combination. # We now loop through the destination zones creating jumps to the rules chain for each source/dest combination.
# @dest_zones is the list of destination zones that we need to handle from this source zone # @dest_zones is the list of destination zones that we need to handle from this source zone
# #
@@ -1869,10 +2124,6 @@ sub generate_matrix() {
my $chainref = $filter_table->{$chain}; #Will be null if $chain is a Netfilter Built-in target like ACCEPT my $chainref = $filter_table->{$chain}; #Will be null if $chain is a Netfilter Built-in target like ACCEPT
if ( $frwd_ref ) {
#
# Simple case -- the source zone has it's own forwarding chain
#
for my $typeref ( values %{$zone1ref->{hosts}} ) { for my $typeref ( values %{$zone1ref->{hosts}} ) {
for my $interface ( sort { interface_number( $a ) <=> interface_number( $b ) } keys %$typeref ) { for my $interface ( sort { interface_number( $a ) <=> interface_number( $b ) } keys %$typeref ) {
for my $hostref ( @{$typeref->{$interface}} ) { for my $hostref ( @{$typeref->{$interface}} ) {
@@ -1887,81 +2138,6 @@ sub generate_matrix() {
} }
} }
} }
} else {
#
# More compilcated case. If the interface is associated with a single simple zone, we try to combine the interface's forwarding chain with the rules chain
#
for my $typeref ( values %$source_hosts_ref ) {
for my $interface ( keys %$typeref ) {
my $interfaceref = find_interface $interface;
my $chain3ref;
my @match_source_dev;
my $forwardchainref = $filter_table->{forward_chain $interface};
if ( use_forward_chain( $interface , $forwardchainref ) || ( @{$forwardchainref->{rules} } && ! $chainref ) ) {
#
# Either we must use the interface's forwarding chain or that chain has rules and we have nowhere to move them
#
$chain3ref = $forwardchainref;
if ( $interfaceref->{options}{port} ) {
add_ijump( $filter_table->{ forward_chain $interfaceref->{bridge} } ,
j => $chain3ref,
imatch_source_dev( $interface , 1 ) )
unless $forward_jump_added{$interface}++;
} else {
add_ijump $filter_table->{FORWARD} , j => $chain3ref, imatch_source_dev( $interface ) unless $forward_jump_added{$interface}++;
}
} else {
#
# Don't use the interface's forward chain -- move any rules in that chain to this rules chain
#
if ( $interfaceref->{options}{port} ) {
$chain3ref = $filter_table->{ forward_chain $interfaceref->{bridge} };
@match_source_dev = imatch_source_dev $interface, 1;
} else {
$chain3ref = $filter_table->{FORWARD};
@match_source_dev = imatch_source_dev $interface;
}
move_rules $forwardchainref, $chainref;
}
for my $hostref ( @{$typeref->{$interface}} ) {
next if $hostref->{options}{destonly};
my $excl3ref = source_exclusion( $hostref->{exclusions}, $chain3ref );
for my $net ( @{$hostref->{hosts}} ) {
for my $type1ref ( values %{$zone1ref->{hosts}} ) {
for my $interface1 ( keys %$type1ref ) {
my $array1ref = $type1ref->{$interface1};
for my $host1ref ( @$array1ref ) {
next if $host1ref->{options}{sourceonly};
my @ipsec_out_match = match_ipsec_out $zone1 , $host1ref;
my $dest_exclusion = dest_exclusion( $host1ref->{exclusions}, $chain );
for my $net1 ( @{$host1ref->{hosts}} ) {
unless ( $interface eq $interface1 && $net eq $net1 && ! $host1ref->{options}{routeback} ) {
#
# We defer evaluation of the source net match to accomodate systems without $capabilities{KLUDEFREE};
#
add_ijump(
$excl3ref ,
j => $dest_exclusion,
@match_source_dev,
imatch_dest_dev($interface1),
imatch_source_net($net),
imatch_dest_net($net1),
@ipsec_out_match
);
}
}
}
}
}
}
}
}
}
}
} }
# #
# E N D F O R W A R D I N G # E N D F O R W A R D I N G
@@ -1969,7 +2145,8 @@ sub generate_matrix() {
# Now add an unconditional jump to the last unique policy-only chain determined above, if any # Now add an unconditional jump to the last unique policy-only chain determined above, if any
# #
add_ijump $frwd_ref , g => $last_chain if $frwd_ref && $last_chain; add_ijump $frwd_ref , g => $last_chain if $frwd_ref && $last_chain;
} } # Forwarding required
} # Source Zone Loop
progress_message ' Finishing matrix...'; progress_message ' Finishing matrix...';
@@ -2163,6 +2340,14 @@ EOF
deletechain shorewall deletechain shorewall
run_stop_exit run_stop_exit
#
# Enable automatic helper association on kernel 3.5.0 and later
#
if [ -f /proc/sys/net/netfilter/nf_conntrack_helper ]; then
echo 1 > /proc/sys/net/netfilter/nf_conntrack_helper
fi
EOF EOF
if ( have_capability( 'NAT_ENABLED' ) ) { if ( have_capability( 'NAT_ENABLED' ) ) {

View File

@@ -35,7 +35,11 @@ use strict;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw( setup_masq setup_nat setup_netmap add_addresses ); our @EXPORT = qw( setup_masq setup_nat setup_netmap add_addresses );
our %EXPORT_TAGS = ( rules => [ qw ( handle_nat_rule handle_nonat_rule ) ] );
our @EXPORT_OK = (); our @EXPORT_OK = ();
Exporter::export_ok_tags('rules');
our $VERSION = 'MODULEVERSION'; our $VERSION = 'MODULEVERSION';
my @addresses_to_add; my @addresses_to_add;
@@ -54,8 +58,8 @@ sub initialize() {
# #
sub process_one_masq( ) sub process_one_masq( )
{ {
my ($interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition ) = my ($interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest ) =
split_line1 'masq file', { interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8 }; split_line1 'masq file', { interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9 };
if ( $interfacelist eq 'COMMENT' ) { if ( $interfacelist eq 'COMMENT' ) {
process_comment; process_comment;
@@ -233,7 +237,7 @@ sub process_one_masq( )
$baserule . $rule , $baserule . $rule ,
$networks , $networks ,
$destnets , $destnets ,
'' , $origdest ,
$target , $target ,
'' , '' ,
'' , '' ,
@@ -276,7 +280,7 @@ sub setup_masq()
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , 'a non-empty masq file' , 's'; } ); first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , 'a non-empty masq file' , 's'; } );
process_one_masq while read_a_line; process_one_masq while read_a_line( NORMAL_READ );
clear_comment; clear_comment;
} }
@@ -373,7 +377,7 @@ sub setup_nat() {
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , 'a non-empty nat file' , 's'; } ); first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , 'a non-empty nat file' , 's'; } );
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $external, $interfacelist, $internal, $allints, $localnat ) = split_line1 'nat file', { external => 0, interface => 1, internal => 2, allints => 3, local => 4 }; my ( $external, $interfacelist, $internal, $allints, $localnat ) = split_line1 'nat file', { external => 0, interface => 1, internal => 2, allints => 3, local => 4 };
@@ -409,7 +413,7 @@ sub setup_netmap() {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $type, $net1, $interfacelist, $net2, $net3, $proto, $dport, $sport ) = split_line 'netmap file', { type => 0, net1 => 1, interface => 2, net2 => 3, net3 => 4, proto => 5, dport => 6, sport => 7 }; my ( $type, $net1, $interfacelist, $net2, $net3, $proto, $dport, $sport ) = split_line 'netmap file', { type => 0, net1 => 1, interface => 2, net2 => 3, net3 => 4, proto => 5, dport => 6, sport => 7 };
@@ -514,6 +518,227 @@ sub setup_netmap() {
} }
#
# Called from process_rule1 to add a rule to the NAT table
#
sub handle_nat_rule( $$$$$$$$$$$$ ) {
my ( $dest, # <server>[:port]
$proto, # Protocol
$ports, # Destination port list
$origdest, # Original Destination
$action_target, # If the target is an action, the name of the log action chain to jump to
$action, # The Action
$sourceref, # Reference to the Source Zone's table entry in the Zones module
$action_chain, # Name of the action chain if the rule is in an action
$rule, # Matches
$source, # Source Address
$loglevel, # [<level>[:<tag>]]
$log_action, # Action name to include in the log message
) = @_;
my ( $server, $serverport , $origdstports ) = ( '', '', '' );
my $randomize = $dest =~ s/:random$// ? ' --random' : '';
#
# Isolate server port
#
if ( $dest =~ /^(.*)(?::(.+))$/ ) {
#
# Server IP and Port
#
$server = $1; # May be empty
$serverport = $2; # Not Empty due to RE
$origdstports = validate_port( $proto, $ports ) if $ports && $ports ne '-' && port_count( $ports ) == 1;
if ( $serverport =~ /^(\d+)-(\d+)$/ ) {
#
# Server Port Range
#
fatal_error "Invalid port range ($serverport)" unless $1 < $2;
my @ports = ( $1, $2 );
$_ = validate_port( proto_name( $proto ), $_) for ( @ports );
( $ports = $serverport ) =~ tr/-/:/;
} else {
$serverport = $ports = validate_port( proto_name( $proto ), $serverport );
}
} elsif ( $dest ne ':' ) {
#
# Simple server IP address (may be empty or "-")
#
$server = $dest;
}
#
# Generate the target
#
my $target = '';
if ( $action eq 'REDIRECT' ) {
fatal_error "A server IP address ($server) may not be specified in a REDIRECT rule" if $server;
$target = 'REDIRECT';
$target .= " --to-port $serverport" if $serverport;
if ( $origdest eq '' || $origdest eq '-' ) {
$origdest = ALLIP;
} elsif ( $origdest eq 'detect' ) {
fatal_error 'ORIGINAL DEST "detect" is invalid in an action' if $action_chain;
if ( $config{DETECT_DNAT_IPADDRS} ) {
my $interfacesref = $sourceref->{interfaces};
my @interfaces = keys %$interfacesref;
$origdest = @interfaces ? "detect:@interfaces" : ALLIP;
} else {
$origdest = ALLIP;
}
}
} elsif ( $action_target ) {
fatal_error "A server port ($serverport) is not allowed in $action rule" if $serverport;
$target = $action_target;
} else {
if ( $server eq '' ) {
fatal_error "A server and/or port must be specified in the DEST column in $action rules" unless $serverport;
} elsif ( $server =~ /^(.+)-(.+)$/ ) {
validate_range( $1, $2 );
} else {
unless ( $server eq ALLIP ) {
my @servers = validate_address $server, 1;
$server = join ',', @servers;
}
}
if ( $action eq 'DNAT' ) {
$target = $action;
if ( $server ) {
$serverport = ":$serverport" if $serverport;
for my $serv ( split /,/, $server ) {
$target .= " --to-destination ${serv}${serverport}";
}
} else {
$target .= " --to-destination :$serverport";
}
}
unless ( $origdest && $origdest ne '-' && $origdest ne 'detect' ) {
if ( ! $action_chain && $config{DETECT_DNAT_IPADDRS} ) {
my $interfacesref = $sourceref->{interfaces};
my @interfaces = keys %$interfacesref;
$origdest = @interfaces ? "detect:@interfaces" : ALLIP;
} else {
$origdest = ALLIP;
}
}
}
$target .= $randomize;
#
# And generate the nat table rule(s)
#
my $firewallsource = $sourceref && ( $sourceref->{type} & ( FIREWALL | VSERVER ) );
expand_rule ( ensure_chain ('nat' ,
( $action_chain ? $action_chain :
$firewallsource ? 'OUTPUT' :
dnat_chain $sourceref->{name} ) ) ,
$firewallsource ? OUTPUT_RESTRICT : PREROUTE_RESTRICT ,
$rule ,
$source ,
$origdest ,
'' ,
$target ,
$loglevel ,
$log_action ,
$serverport ? do_proto( $proto, '', '' ) : '',
);
( $ports, $origdstports, $server );
}
#
# Called from process_rule1() to handle the nat table part of the NONAT and ACCEPT+ actions
#
sub handle_nonat_rule( $$$$$$$$$$ ) {
my ( $action, $source, $dest, $origdest, $sourceref, $inaction, $chain, $loglevel, $log_action, $rule ) = @_;
my $sourcezone = $sourceref->{name};
#
# NONAT or ACCEPT+ may not specify a destination interface
#
fatal_error "Invalid DEST ($dest) in $action rule" if $dest =~ /:/;
$origdest = '' unless $origdest and $origdest ne '-';
if ( $origdest eq 'detect' ) {
my $interfacesref = $sourceref->{interfaces};
my $interfaces = [ ( keys %$interfacesref ) ];
$origdest = $interfaces ? "detect:@$interfaces" : ALLIP;
}
my $tgt = 'RETURN';
my $nonat_chain;
my $chn;
if ( $inaction ) {
$nonat_chain = ensure_chain( 'nat', $chain );
} elsif ( $sourceref->{type} == FIREWALL ) {
$nonat_chain = $nat_table->{OUTPUT};
} else {
$nonat_chain = ensure_chain( 'nat', dnat_chain( $sourcezone ) );
my @interfaces = keys %{zone_interfaces $sourcezone};
for ( @interfaces ) {
my $ichain = input_chain $_;
if ( $nat_table->{$ichain} ) {
#
# Static NAT is defined on this interface
#
$chn = new_chain( 'nat', newnonatchain ) unless $chn;
add_ijump $chn, j => $nat_table->{$ichain}, @interfaces > 1 ? imatch_source_dev( $_ ) : ();
}
}
if ( $chn ) {
#
# Call expand_rule() to correctly handle logging. Because
# the 'logname' argument is passed, expand_rule() will
# not create a separate logging chain but will rather emit
# any logging rule in-line.
#
expand_rule( $chn,
PREROUTE_RESTRICT,
'', # Rule
'', # Source
'', # Dest
'', # Original dest
'ACCEPT',
$loglevel,
$log_action,
'',
dnat_chain( $sourcezone ) );
$loglevel = '';
$tgt = $chn->{name};
} else {
$tgt = 'ACCEPT';
}
}
set_optflags( $nonat_chain, DONT_MOVE | DONT_OPTIMIZE ) if $tgt eq 'RETURN';
expand_rule( $nonat_chain ,
PREROUTE_RESTRICT ,
$rule ,
$source ,
$dest ,
$origdest ,
$tgt,
$loglevel ,
$log_action ,
'',
);
}
sub add_addresses () { sub add_addresses () {
if ( @addresses_to_add ) { if ( @addresses_to_add ) {
my @addrs = @addresses_to_add; my @addrs = @addresses_to_add;

View File

@@ -39,7 +39,9 @@ our @EXPORT = qw( process_providers
@routemarked_interfaces @routemarked_interfaces
handle_stickiness handle_stickiness
handle_optional_interfaces handle_optional_interfaces
compile_updown
setup_load_distribution setup_load_distribution
have_providers
); );
our @EXPORT_OK = qw( initialize lookup_provider ); our @EXPORT_OK = qw( initialize lookup_provider );
our $VERSION = '4.4_24'; our $VERSION = '4.4_24';
@@ -60,9 +62,11 @@ my @load_interfaces;
my $balancing; my $balancing;
my $fallback; my $fallback;
my $metrics;
my $first_default_route; my $first_default_route;
my $first_fallback_route; my $first_fallback_route;
my $maxload; my $maxload;
my $tproxies;
my %providers; my %providers;
@@ -95,9 +99,11 @@ sub initialize( $ ) {
@load_interfaces = (); @load_interfaces = ();
$balancing = 0; $balancing = 0;
$fallback = 0; $fallback = 0;
$metrics = 0;
$first_default_route = 1; $first_default_route = 1;
$first_fallback_route = 1; $first_fallback_route = 1;
$maxload = 0; $maxload = 0;
$tproxies = 0;
%providers = ( local => { number => LOCAL_TABLE , mark => 0 , optional => 0 ,routes => [], rules => [] } , %providers = ( local => { number => LOCAL_TABLE , mark => 0 , optional => 0 ,routes => [], rules => [] } ,
main => { number => MAIN_TABLE , mark => 0 , optional => 0 ,routes => [], rules => [] } , main => { number => MAIN_TABLE , mark => 0 , optional => 0 ,routes => [], rules => [] } ,
@@ -396,8 +402,8 @@ sub process_a_provider() {
$gateway = ''; $gateway = '';
} }
my ( $loose, $track, $balance , $default, $default_balance, $optional, $mtu, $local , $load ) = my ( $loose, $track, $balance , $default, $default_balance, $optional, $mtu, $tproxy , $local, $load ) =
(0, $config{TRACK_PROVIDERS}, 0 , 0, $config{USE_DEFAULT_RT} ? 1 : 0, interface_is_optional( $interface ), '' , 0 , 0 ); (0, $config{TRACK_PROVIDERS}, 0 , 0, $config{USE_DEFAULT_RT} ? 1 : 0, interface_is_optional( $interface ), '' , 0 , 0, 0 );
unless ( $options eq '-' ) { unless ( $options eq '-' ) {
for my $option ( split_list $options, 'option' ) { for my $option ( split_list $options, 'option' ) {
@@ -435,7 +441,12 @@ sub process_a_provider() {
$default = -1; $default = -1;
$default_balance = 0; $default_balance = 0;
} elsif ( $option eq 'local' ) { } elsif ( $option eq 'local' ) {
$local = 1; warning_message q(The 'local' provider option is deprecated in favor of 'tproxy');
$local = $tproxy = 1;
$track = 0 if $config{TRACK_PROVIDERS};
$default_balance = 0 if $config{USE_DEFAULT_RT};
} elsif ( $option eq 'tproxy' ) {
$tproxy = 1;
$track = 0 if $config{TRACK_PROVIDERS}; $track = 0 if $config{TRACK_PROVIDERS};
$default_balance = 0 if $config{USE_DEFAULT_RT}; $default_balance = 0 if $config{USE_DEFAULT_RT};
} elsif ( $option =~ /^load=(0?\.\d{1,8})/ ) { } elsif ( $option =~ /^load=(0?\.\d{1,8})/ ) {
@@ -459,7 +470,13 @@ sub process_a_provider() {
fatal_error "GATEWAY not valid with 'local' provider" unless $gatewaycase eq 'none'; fatal_error "GATEWAY not valid with 'local' provider" unless $gatewaycase eq 'none';
fatal_error "'track' not valid with 'local'" if $track; fatal_error "'track' not valid with 'local'" if $track;
fatal_error "DUPLICATE not valid with 'local'" if $duplicate ne '-'; fatal_error "DUPLICATE not valid with 'local'" if $duplicate ne '-';
fatal_error "MARK required with 'local'" unless $mark; } elsif ( $tproxy ) {
fatal_error "Only one 'tproxy' provider is allowed" if $tproxies++;
fatal_error "GATEWAY not valid with 'tproxy' provider" unless $gatewaycase eq 'none';
fatal_error "'track' not valid with 'tproxy'" if $track;
fatal_error "DUPLICATE not valid with 'tproxy'" if $duplicate ne '-';
fatal_error "MARK not allowed with 'tproxy'" if $mark ne '-';
$mark = $globals{TPROXY_MARK};
} }
my $val = 0; my $val = 0;
@@ -471,6 +488,10 @@ sub process_a_provider() {
require_capability( 'MANGLE_ENABLED' , 'Provider marks' , '' ); require_capability( 'MANGLE_ENABLED' , 'Provider marks' , '' );
if ( $tproxy && ! $local ) {
$val = $globals{TPROXY_MARK};
$pref = 1;
} else {
$val = numeric_value $mark; $val = numeric_value $mark;
fatal_error "Invalid Mark Value ($mark)" unless defined $val && $val; fatal_error "Invalid Mark Value ($mark)" unless defined $val && $val;
@@ -485,10 +506,11 @@ sub process_a_provider() {
fatal_error "Duplicate mark value ($mark)" if numeric_value( $providerref->{mark} ) == $val; fatal_error "Duplicate mark value ($mark)" if numeric_value( $providerref->{mark} ) == $val;
} }
$pref = 10000 + $number - 1;
$lastmark = $val; $lastmark = $val;
$pref = 10000 + $number - 1;
}
} }
unless ( $loose ) { unless ( $loose ) {
@@ -527,6 +549,7 @@ sub process_a_provider() {
duplicate => $duplicate , duplicate => $duplicate ,
address => $address , address => $address ,
local => $local , local => $local ,
tproxy => $tproxy ,
load => $load , load => $load ,
rules => [] , rules => [] ,
routes => [] , routes => [] ,
@@ -579,6 +602,7 @@ sub add_a_provider( $$ ) {
my $duplicate = $providerref->{duplicate}; my $duplicate = $providerref->{duplicate};
my $address = $providerref->{address}; my $address = $providerref->{address};
my $local = $providerref->{local}; my $local = $providerref->{local};
my $tproxy = $providerref->{tproxy};
my $load = $providerref->{load}; my $load = $providerref->{load};
my $dev = chain_base $physical; my $dev = chain_base $physical;
@@ -600,7 +624,7 @@ sub add_a_provider( $$ ) {
$provider_interfaces{$interface} = $table; $provider_interfaces{$interface} = $table;
if ( $gatewaycase eq 'none' ) { if ( $gatewaycase eq 'none' ) {
if ( $local ) { if ( $tproxy ) {
emit 'run_ip route add local ' . ALLIP . " dev $physical table $number"; emit 'run_ip route add local ' . ALLIP . " dev $physical table $number";
} else { } else {
emit "run_ip route add default dev $physical table $number"; emit "run_ip route add default dev $physical table $number";
@@ -608,7 +632,8 @@ sub add_a_provider( $$ ) {
} }
} }
emit( qq(echo $load > \${VARDIR}/${physical}_load) ) if $load; emit( "echo $load > \${VARDIR}/${physical}_load",
'echo ' . in_hex( $mark ) . '/' . in_hex( $globals{PROVIDER_MASK} ) . " > \${VARDIR}/${physical}_mark" ) if $load;
emit( '', emit( '',
"cat <<EOF >> \${VARDIR}/undo_${table}_routing" ); "cat <<EOF >> \${VARDIR}/undo_${table}_routing" );
@@ -618,6 +643,7 @@ sub add_a_provider( $$ ) {
emit_unindented ' ;;'; emit_unindented ' ;;';
emit_unindented ' *)'; emit_unindented ' *)';
emit_unindented " rm -f \${VARDIR}/${physical}_load" if $load; emit_unindented " rm -f \${VARDIR}/${physical}_load" if $load;
emit_unindented " rm -f \${VARDIR}/${physical}_mark" if $load;
emit_unindented <<"CEOF", 1; emit_unindented <<"CEOF", 1;
rm -f \${VARDIR}/${physical}.status rm -f \${VARDIR}/${physical}.status
;; ;;
@@ -630,12 +656,13 @@ CEOF
setup_interface_proc( $interface ); setup_interface_proc( $interface );
if ( $mark ne '-' ) { if ( $mark ne '-' ) {
my $mask = have_capability 'FWMARK_RT_MASK' ? '/' . in_hex $globals{PROVIDER_MASK} : ''; my $hexmark = in_hex( $mark );
my $mask = have_capability 'FWMARK_RT_MASK' ? '/' . in_hex( $globals{ $tproxy && ! $local ? 'TPROXY_MARK' : 'PROVIDER_MASK' } ) : '';
emit ( "qt \$IP -$family rule del fwmark ${mark}${mask}" ) if $config{DELETE_THEN_ADD}; emit ( "qt \$IP -$family rule del fwmark ${hexmark}${mask}" ) if $config{DELETE_THEN_ADD};
emit ( "run_ip rule add fwmark ${mark}${mask} pref $pref table $number", emit ( "run_ip rule add fwmark ${hexmark}${mask} pref $pref table $number",
"echo \"qt \$IP -$family rule del fwmark ${mark}${mask}\" >> \${VARDIR}/undo_${table}_routing" "echo \"qt \$IP -$family rule del fwmark ${hexmark}${mask}\" >> \${VARDIR}/undo_${table}_routing"
); );
} }
@@ -675,19 +702,20 @@ CEOF
emit ''; emit '';
if ( $gateway ) { if ( $gateway ) {
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
emit qq(run_ip route replace $gateway dev $physical table ) . DEFAULT_TABLE; emit qq(run_ip route replace $gateway/32 dev $physical table ) . DEFAULT_TABLE;
emit qq(run_ip route replace default via $gateway src $address dev $physical table ) . DEFAULT_TABLE . qq( metric $number); emit qq(run_ip route replace default via $gateway src $address dev $physical table ) . DEFAULT_TABLE . qq( metric $number);
} else { } else {
emit qq(qt \$IP -6 route del default via $gateway src $address dev $physical table ) . DEFAULT_TABLE . qq( metric $number); emit qq(qt \$IP -6 route del default via $gateway src $address dev $physical table ) . DEFAULT_TABLE . qq( metric $number);
emit qq(run_ip route add default via $gateway src $address dev $physical table ) . DEFAULT_TABLE . qq( metric $number); emit qq(run_ip route add default via $gateway src $address dev $physical table ) . DEFAULT_TABLE . qq( metric $number);
} }
emit qq(echo "qt \$IP -$family route del default via $gateway table ) . DEFAULT_TABLE . qq(" >> \${VARDIR}/undo_${table}_routing); emit qq(echo "qt \$IP -$family route del default via $gateway table ) . DEFAULT_TABLE . qq(" >> \${VARDIR}/undo_${table}_routing);
emit qq(echo "qt \$IP -4 route del $gateway/32 dev $physical table ) . DEFAULT_TABLE . qq(" >> \${VARDIR}/undo_${table}_routing) if $family == F_IPV4;
} else { } else {
emit qq(run_ip route add default table ) . DEFAULT_TABLE . qq( dev $physical metric $number); emit qq(run_ip route add default table ) . DEFAULT_TABLE . qq( dev $physical metric $number);
emit qq(echo "qt \$IP -$family route del default dev $physical table ) . DEFAULT_TABLE . qq(" >> \${VARDIR}/undo_${table}_routing); emit qq(echo "qt \$IP -$family route del default dev $physical table ) . DEFAULT_TABLE . qq(" >> \${VARDIR}/undo_${table}_routing);
} }
$fallback = 1; $metrics = 1;
} }
emit( qq(\n) , emit( qq(\n) ,
@@ -695,7 +723,7 @@ CEOF
qq( qt \$IP -6 rule add from all table ) . DEFAULT_TABLE . qq( prio 32767\n) , qq( qt \$IP -6 rule add from all table ) . DEFAULT_TABLE . qq( prio 32767\n) ,
qq(fi) ) if $family == F_IPV6; qq(fi) ) if $family == F_IPV6;
unless ( $local ) { unless ( $tproxy ) {
emit ''; emit '';
if ( $loose ) { if ( $loose ) {
@@ -759,7 +787,7 @@ CEOF
if ( $gateway ) { if ( $gateway ) {
emit qq(add_gateway "via $gateway dev $physical $realm" ) . $tbl; emit qq(add_gateway "via $gateway dev $physical $realm" ) . $tbl;
} else { } else {
emit qq(add_gateway "nexthop dev $physical $realm" ) . $tbl; emit qq(add_gateway "dev $physical $realm" ) . $tbl;
} }
} }
} else { } else {
@@ -861,7 +889,8 @@ CEOF
"qt \$TC qdisc del dev $physical ingress\n" ) if $tcdevices->{$interface}; "qt \$TC qdisc del dev $physical ingress\n" ) if $tcdevices->{$interface};
} }
emit( "progress_message2 \" Provider $table ($number) stopped\"" ); emit( "echo 1 > \${VARDIR}/${physical}.status",
"progress_message2 \" Provider $table ($number) stopped\"" );
pop_indent; pop_indent;
@@ -928,7 +957,7 @@ sub add_an_rtrule( ) {
validate_net ( $source, 0 ); validate_net ( $source, 0 );
$source = "from $source"; $source = "from $source";
} else { } else {
$source = "iif $source"; $source = 'iif ' . physical_name $source;
} }
} elsif ( $source =~ /^(.+?):<(.+)>\s*$/ || $source =~ /^(.+?):\[(.+)\]\s*$/ ) { } elsif ( $source =~ /^(.+?):<(.+)>\s*$/ || $source =~ /^(.+?):\[(.+)\]\s*$/ ) {
my ($interface, $source ) = ($1, $2); my ($interface, $source ) = ($1, $2);
@@ -939,7 +968,7 @@ sub add_an_rtrule( ) {
validate_net ( $source, 0 ); validate_net ( $source, 0 );
$source = "from $source"; $source = "from $source";
} else { } else {
$source = "iif $source"; $source = 'iif ' . physical_name $source;
} }
my $mark = ''; my $mark = '';
@@ -1024,8 +1053,8 @@ sub setup_null_routing() {
emit "> \${VARDIR}/undo_rfc1918_routing\n"; emit "> \${VARDIR}/undo_rfc1918_routing\n";
for ( rfc1918_networks ) { for ( rfc1918_networks ) {
emit( qq(if ! \$IP -4 route ls | grep -q '^$_.* dev '; then), emit( qq(if ! \$IP -4 route ls | grep -q '^$_.* dev '; then),
qq( run_ip route replace unreachable $_), qq( run_ip route replace blackhole $_),
qq( echo "qt \$IP -4 route del unreachable $_" >> \${VARDIR}/undo_rfc1918_routing), qq( echo "qt \$IP -4 route del blackhole $_" >> \${VARDIR}/undo_rfc1918_routing),
qq(fi\n) ); qq(fi\n) );
} }
} }
@@ -1114,6 +1143,10 @@ sub finish_providers() {
'# We don\'t have any \'balance\' providers so we restore any default route that we\'ve saved', '# We don\'t have any \'balance\' providers so we restore any default route that we\'ve saved',
'#', '#',
"restore_default_route $config{USE_DEFAULT_RT}" , "restore_default_route $config{USE_DEFAULT_RT}" ,
'#',
'# And delete any routes in the \'balance\' table',
'#',
"qt \$IP -$family route del default table " . BALANCE_TABLE,
'' ); '' );
} }
@@ -1127,10 +1160,17 @@ sub finish_providers() {
} }
emit( " progress_message \"Fallback route '\$(echo \$FALLBACK_ROUTE | sed 's/\$\\s*//')' Added\"", emit( " progress_message \"Fallback route '\$(echo \$FALLBACK_ROUTE | sed 's/\$\\s*//')' Added\"",
'else',
' #',
' # We don\'t have any \'fallback\' providers so we delete any default routes in the default table',
' #',
' delete_default_routes ' . DEFAULT_TABLE,
'fi', 'fi',
'' ); '' );
} elsif ( $config{USE_DEFAULT_RT} ) { } elsif ( $config{USE_DEFAULT_RT} ) {
emit "qt \$IP -$family route del default table " . DEFAULT_TABLE; emit( 'delete_default_routes ' . DEFAULT_TABLE,
''
);
} }
unless ( $config{KEEP_RT_TABLES} ) { unless ( $config{KEEP_RT_TABLES} ) {
@@ -1164,15 +1204,17 @@ sub process_providers( $ ) {
if ( my $fn = open_file 'providers' ) { if ( my $fn = open_file 'providers' ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
process_a_provider, $providers++ while read_a_line; process_a_provider, $providers++ while read_a_line( NORMAL_READ );
} }
if ( $providers ) { if ( $providers ) {
fatal_error q(Either all 'fallback' providers must specify a weight or non of them can specify a weight) if $fallback && $metrics;
my $fn = open_file( 'route_rules' ); my $fn = open_file( 'route_rules' );
if ( $fn ){ if ( $fn ){
if ( -f ( my $fn1 = find_file 'rtrules' ) ) { if ( -f ( my $fn1 = find_file 'rtrules' ) ) {
warning_message "Both $fn and $fn1 exists: $fn1 will be ignored"; warning_message "Both $fn and $fn1 exist: $fn1 will be ignored";
} }
} else { } else {
$fn = open_file( 'rtrules' ); $fn = open_file( 'rtrules' );
@@ -1183,7 +1225,7 @@ sub process_providers( $ ) {
emit ''; emit '';
add_an_rtrule while read_a_line; add_an_rtrule while read_a_line( NORMAL_READ );
} }
$fn = open_file 'routes'; $fn = open_file 'routes';
@@ -1191,7 +1233,7 @@ sub process_providers( $ ) {
if ( $fn ) { if ( $fn ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
emit ''; emit '';
add_a_route while read_a_line; add_a_route while read_a_line( NORMAL_READ );
} }
} }
@@ -1239,6 +1281,7 @@ EOF
startup_error "$g_interface is not an optional provider or provider interface" startup_error "$g_interface is not an optional provider or provider interface"
;; ;;
esac esac
} }
# #
@@ -1279,6 +1322,10 @@ EOF
} }
sub have_providers() {
return our $providers;
}
sub setup_providers() { sub setup_providers() {
our $providers; our $providers;
@@ -1324,6 +1371,228 @@ sub setup_providers() {
} }
#
# Emit the updown() function
#
sub compile_updown() {
emit( '',
'#',
'# Handle the "up" and "down" commands',
'#',
'updown() # $1 = interface',
'{',
);
push_indent;
emit( 'local state',
'state=cleared',
''
);
emit 'progress_message3 "$g_product $COMMAND triggered by $1"';
emit '';
if ( $family == F_IPV4 ) {
emit 'if shorewall_is_started; then';
} else {
emit 'if shorewall6_is_started; then';
}
emit( ' state=started',
'elif [ -f ${VARDIR}/state ]; then',
' case "$(cat ${VARDIR}/state)" in',
' Stopped*)',
' state=stopped',
' ;;',
' Cleared*)',
' ;;',
' *)',
' state=unknown',
' ;;',
' esac',
'else',
' state=unknown',
'fi',
''
);
emit( 'case $1 in' );
push_indent;
my $ignore = find_interfaces_by_option 'ignore', 1;
my $required = find_interfaces_by_option 'required';
my $optional = find_interfaces_by_option 'optional';
if ( @$ignore ) {
my $interfaces = join '|', map get_physical( $_ ), @$ignore;
$interfaces =~ s/\+/*/g;
emit( "$interfaces)",
' progress_message3 "$COMMAND on interface $1 ignored"',
' exit 0',
' ;;'
);
}
my @nonshared = ( grep $providers{$_}->{optional},
sort( { $providers{$a}->{number} <=> $providers{$b}->{number} } values %provider_interfaces ) );
if ( @nonshared ) {
my $interfaces = join( '|', map $providers{$_}->{physical}, @nonshared );
emit "$interfaces)";
push_indent;
emit( q(if [ "$state" = started ]; then) ,
q( if [ "$COMMAND" = up ]; then) ,
q( progress_message3 "Attempting enable on interface $1") ,
q( COMMAND=enable) ,
q( detect_configuration),
q( enable_provider $1),
q( elif [ "$PHASE" != post-down ]; then # pre-down or not Debian) ,
q( progress_message3 "Attempting disable on interface $1") ,
q( COMMAND=disable) ,
q( detect_configuration),
q( disable_provider $1) ,
q( fi) ,
q(elif [ "$COMMAND" = up ]; then) ,
q( echo 0 > ${VARDIR}/${1}.status) ,
q( COMMAND=start),
q( progress_message3 "$g_product attempting start") ,
q( detect_configuration),
q( define_firewall),
q(else),
q( progress_message3 "$COMMAND on interface $1 ignored") ,
q(fi) ,
q(;;) );
pop_indent;
}
if ( @$required ) {
my $interfaces = join '|', map get_physical( $_ ), @$required;
my $wildcard = ( $interfaces =~ s/\+/*/g );
emit( "$interfaces)",
' if [ "$COMMAND" = up ]; then' );
if ( $wildcard ) {
emit( ' if [ "$state" = started ]; then',
' COMMAND=restart',
' else',
' COMMAND=start',
' fi' );
} else {
emit( ' COMMAND=start' );
}
emit( ' progress_message3 "$g_product attempting $COMMAND"',
' detect_configuration',
' define_firewall',
' elif [ "$PHASE" != pre-down ]; then # Not Debian pre-down phase'
);
push_indent;
if ( $wildcard ) {
emit( ' if [ "$state" = started ]; then',
' progress_message3 "$g_product attempting restart"',
' COMMAND=restart',
' detect_configuration',
' define_firewall',
' fi' );
} else {
emit( ' COMMAND=stop',
' progress_message3 "$g_product attempting stop"',
' detect_configuration',
' stop_firewall' );
}
pop_indent;
emit( ' fi',
' ;;'
);
}
if ( @$optional ) {
my @interfaces = map( get_physical( $_ ), grep( ! $provider_interfaces{$_} , @$optional ) );
my $interfaces = join '|', @interfaces;
if ( $interfaces ) {
if ( $interfaces =~ s/\+/*/g || @interfaces > 1 ) {
emit( "$interfaces)",
' if [ "$COMMAND" = up ]; then',
' echo 0 > ${VARDIR}/${1}.state',
' else',
' echo 1 > ${VARDIR}/${1}.state',
' fi' );
} else {
emit( "$interfaces)",
' if [ "$COMMAND" = up ]; then',
" echo 0 > \${VARDIR}/$interfaces.state",
' else',
" echo 1 > \${VARDIR}/$interfaces.state",
' fi' );
}
emit( '',
' if [ "$state" = started ]; then',
' COMMAND=restart',
' progress_message3 "$g_product attempting restart"',
' detect_configuration',
' define_firewall',
' elif [ "$state" = stopped ]; then',
' COMMAND=start',
' progress_message3 "$g_product attempting start"',
' detect_configuration',
' define_firewall',
' else',
' progress_message3 "$COMMAND on interface $1 ignored"',
' fi',
' ;;',
);
}
}
if ( my @plain_interfaces = all_plain_interfaces ) {
my $interfaces = join ( '|', @plain_interfaces );
$interfaces =~ s/\+/*/g;
emit( "$interfaces)",
' case $state in',
' started)',
' COMMAND=restart',
' progress_message3 "$g_product attempting restart"',
' detect_configuration',
' define_firewall',
' ;;',
' *)',
' progress_message3 "$COMMAND on interface $1 ignored"',
' ;;',
' esac',
);
}
pop_indent;
emit( 'esac' );
pop_indent;
emit( '}',
'',
);
}
sub lookup_provider( $ ) { sub lookup_provider( $ ) {
my $provider = $_[0]; my $provider = $_[0];
my $providerref = $providers{ $provider }; my $providerref = $providers{ $provider };

View File

@@ -120,7 +120,7 @@ sub setup_proxy_arp() {
my ( %set, %reset ); my ( %set, %reset );
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $address, $interface, $external, $haveroute, $persistent ) = my ( $address, $interface, $external, $haveroute, $persistent ) =
split_line $file_opt . 'file ', { address => 0, interface => 1, external => 2, haveroute => 3, persistent => 4 }; split_line $file_opt . 'file ', { address => 0, interface => 1, external => 2, haveroute => 3, persistent => 4 };

View File

@@ -20,7 +20,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# This module contains the code that handles the /etc/shorewall/notrack file. # This module contains the code that handles the /etc/shorewall/conntrack file.
# #
package Shorewall::Raw; package Shorewall::Raw;
require Exporter; require Exporter;
@@ -32,8 +32,8 @@ use Shorewall::Chains qw(:DEFAULT :internal);
use strict; use strict;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw( setup_notrack ); our @EXPORT = qw( setup_conntrack );
our @EXPORT_OK = qw( ); our @EXPORT_OK = qw( handle_helper_rule );
our $VERSION = 'MODULEVERSION'; our $VERSION = 'MODULEVERSION';
my %valid_ctevent = ( new => 1, related => 1, destroy => 1, reply => 1, assured => 1, protoinfo => 1, helper => 1, mark => 1, natseqinfo => 1, secmark => 1 ); my %valid_ctevent = ( new => 1, related => 1, destroy => 1, reply => 1, assured => 1, protoinfo => 1, helper => 1, mark => 1, natseqinfo => 1, secmark => 1 );
@@ -41,21 +41,34 @@ my %valid_ctevent = ( new => 1, related => 1, destroy => 1, reply => 1, assured
# #
# Notrack # Notrack
# #
sub process_notrack_rule( $$$$$$$ ) { sub process_conntrack_rule( $$$$$$$$$ ) {
my ($action, $source, $dest, $proto, $ports, $sports, $user ) = @_; my ($chainref, $zoneref, $action, $source, $dest, $proto, $ports, $sports, $user ) = @_;
require_capability 'RAW_TABLE', 'conntrack rules', '';
$proto = '' if $proto eq 'any'; $proto = '' if $proto eq 'any';
$ports = '' if $ports eq 'any' || $ports eq 'all'; $ports = '' if $ports eq 'any' || $ports eq 'all';
$sports = '' if $sports eq 'any' || $sports eq 'all'; $sports = '' if $sports eq 'any' || $sports eq 'all';
( my $zone, $source) = split /:/, $source, 2; my $zone;
my $zoneref = find_zone $zone; my $restriction = PREROUTE_RESTRICT;
my $chainref = ensure_raw_chain( notrack_chain $zone );
my $restriction = $zoneref->{type} == FIREWALL || $zoneref->{type} == VSERVER ? OUTPUT_RESTRICT : PREROUTE_RESTRICT;
unless ( $chainref ) {
#
# Entry in the conntrack file
#
if ( $zoneref ) {
$zone = $zoneref->{name};
} else {
($zone, $source) = split /:/, $source, 2;
$zoneref = find_zone ( $zone );
}
$chainref = ensure_raw_chain( notrack_chain $zone );
$restriction = OUTPUT_RESTRICT if $zoneref->{type} == FIREWALL || $zoneref->{type} == VSERVER;
fatal_error 'USER/GROUP is not allowed unless the SOURCE zone is $FW or a Vserver zone' if $user ne '-' && $restriction != OUTPUT_RESTRICT; fatal_error 'USER/GROUP is not allowed unless the SOURCE zone is $FW or a Vserver zone' if $user ne '-' && $restriction != OUTPUT_RESTRICT;
require_capability 'RAW_TABLE', 'Notrack rules', ''; }
my $target = $action; my $target = $action;
my $exception_rule = ''; my $exception_rule = '';
@@ -66,29 +79,45 @@ sub process_notrack_rule( $$$$$$$ ) {
fatal_error "Invalid notrack ACTION ( $action )" if $junk || $target ne 'CT'; fatal_error "Invalid notrack ACTION ( $action )" if $junk || $target ne 'CT';
require_capability 'CT_TARGET', 'CT entries in the notrack file', ''; require_capability 'CT_TARGET', 'CT entries in the conntrack file', '';
if ( $option eq 'notrack' ) { if ( $option eq 'notrack' ) {
fatal_error "Invalid notrack ACTION ( $action )" if supplied $args; fatal_error "Invalid conntrack ACTION ( $action )" if supplied $args;
$action = 'CT --notrack'; $action = 'CT --notrack';
} else { } else {
fatal_error "Invalid or missing CT option and arguments" unless supplied $option && supplied $args; fatal_error "Invalid or missing CT option and arguments" unless supplied $option && supplied $args;
if ( $option eq 'helper' ) { if ( $option eq 'helper' ) {
my $modifiers = '';
if ( $args =~ /^([-\w.]+)\((.+)\)$/ ) {
$args = $1;
$modifiers = $2;
}
fatal_error "Invalid helper' ($args)" if $args =~ /,/; fatal_error "Invalid helper' ($args)" if $args =~ /,/;
validate_helper( $args, $proto ); validate_helper( $args, $proto );
$action = "CT --helper $args"; $action = "CT --helper $helpers_aliases{$args}";
$exception_rule = do_proto( $proto, '-', '-' ); $exception_rule = do_proto( $proto, '-', '-' );
} elsif ( $option eq 'ctevents' ) {
for ( split ',', $args ) { for my $mod ( split_list1( $modifiers, 'ctevents' ) ) {
fatal_error "Invalid helper option ($mod)" unless $mod =~ /^(\w+)=(.+)$/;
$mod = $1;
my $val = $2;
if ( $mod eq 'ctevents' ) {
for ( split_list( $val, 'ctevents' ) ) {
fatal_error "Invalid 'ctevents' event ($_)" unless $valid_ctevent{$_}; fatal_error "Invalid 'ctevents' event ($_)" unless $valid_ctevent{$_};
} }
$action = "CT --ctevents $args"; $action .= " --ctevents $val";
} elsif ( $option eq 'expevent' ) { } elsif ( $mod eq 'expevents' ) {
fatal_error "Invalid expevent argument ($args)" unless $args eq 'new'; fatal_error "Invalid expevent argument ($val)" unless $val eq 'new';
} elsif ( $option eq 'zone' ) { $action .= ' --expevents new';
fatal_error "Invalid zone id ($args)" unless $args =~ /^\d+$/; } else {
fatal_error "Invalid helper option ($mod)";
}
}
} else { } else {
fatal_error "Invalid CT option ($option)"; fatal_error "Invalid CT option ($option)";
} }
@@ -106,9 +135,60 @@ sub process_notrack_rule( $$$$$$$ ) {
$target , $target ,
$exception_rule ); $exception_rule );
progress_message " Notrack rule \"$currentline\" $done"; progress_message " Conntrack rule \"$currentline\" $done";
}
$globals{UNTRACKED} = 1; sub handle_helper_rule( $$$$$$$$$$$ ) {
my ( $helper, $source, $dest, $proto, $ports, $sports, $sourceref, $action_target, $actionchain, $user, $rule ) = @_;
if ( $helper ne '-' ) {
fatal_error "A HELPER is not allowed with this ACTION" if $action_target;
#
# This means that an ACCEPT or NAT rule with a helper is being processed
#
process_conntrack_rule( $actionchain ? ensure_raw_chain( $actionchain ) : undef ,
$sourceref ,
"CT:helper:$helper",
$source ,
$dest ,
$proto ,
$ports ,
$sports ,
$user );
} else {
assert( $action_target );
#
# The target is an action
#
if ( $actionchain ) {
#
# And the source is another action chain
#
expand_rule( ensure_raw_chain( $actionchain ) ,
PREROUTE_RESTRICT ,
$rule ,
$source ,
$dest ,
'' ,
$action_target ,
'',
'CT' ,
'' );
} else {
expand_rule( ensure_raw_chain( notrack_chain( $sourceref->{name} ) ) ,
( $sourceref->{type} == FIREWALL || $sourceref->{type} == VSERVER ?
OUTPUT_RESTRICT :
PREROUTE_RESTRICT ) ,
$rule ,
$source ,
$dest ,
'' ,
$action_target ,
'' ,
'CT' ,
'' );
}
}
} }
sub process_format( $ ) { sub process_format( $ ) {
@@ -119,51 +199,72 @@ sub process_format( $ ) {
$format; $format;
} }
sub setup_notrack() { sub setup_conntrack() {
for my $name ( qw/notrack conntrack/ ) {
my $fn = open_file( $name );
if ( $fn ) {
my $format = 1; my $format = 1;
my $action = 'NOTRACK'; my $action = 'NOTRACK';
if ( my $fn = open_file 'notrack' ) { my $empty = 1;
first_entry "$doing $fn..."; first_entry( "$doing $fn..." );
my $nonEmpty = 0; while ( read_a_line( NORMAL_READ ) ) {
while ( read_a_line ) {
my ( $source, $dest, $proto, $ports, $sports, $user ); my ( $source, $dest, $proto, $ports, $sports, $user );
if ( $format == 1 ) { if ( $format == 1 ) {
( $source, $dest, $proto, $ports, $sports, $user ) = split_line1 'Notrack File', { source => 0, dest => 1, proto => 2, dport => 3, sport => 4, user => 5 }; ( $source, $dest, $proto, $ports, $sports, $user ) = split_line1 'Conntrack File', { source => 0, dest => 1, proto => 2, dport => 3, sport => 4, user => 5 };
if ( $source eq 'FORMAT' ) { if ( $source eq 'FORMAT' ) {
$format = process_format( $dest ); $format = process_format( $dest );
next; next;
} }
if ( $source eq 'COMMENT' ) {
process_comment;
next;
}
} else { } else {
( $action, $source, $dest, $proto, $ports, $sports, $user ) = split_line1 'Notrack File', { action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6 }, { COMMENT => 0, FORMAT => 2 }; ( $action, $source, $dest, $proto, $ports, $sports, $user ) = split_line1 'Conntrack File', { action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6 }, { COMMENT => 0, FORMAT => 2 };
if ( $action eq 'FORMAT' ) { if ( $action eq 'FORMAT' ) {
$format = process_format( $source ); $format = process_format( $source );
$action = 'NOTRACK'; $action = 'NOTRACK';
next; next;
} }
}
if ( $action eq 'COMMENT' ) { if ( $action eq 'COMMENT' ) {
process_comment; process_comment;
next; next;
} }
}
process_notrack_rule $action, $source, $dest, $proto, $ports, $sports, $user; $empty = 0;
if ( $source eq 'all' ) {
for my $zone (all_zones) {
process_conntrack_rule( undef, undef, $action, $zone, $dest, $proto, $ports, $sports, $user );
}
} else {
process_conntrack_rule( undef, undef, $action, $source, $dest, $proto, $ports, $sports, $user );
}
} }
clear_comment; clear_comment;
if ( $name eq 'notrack') {
if ( $empty ) {
if ( unlink( $fn ) ) {
warning_message "Empty notrack file ($fn) removed";
} else {
warning_message "Unable to remove empty notrack file ($fn): $!";
}
} else {
warning_message "Non-empty notrack file ($fn); please move its contents to the conntrack file";
}
}
}
} }
} }

View File

@@ -33,6 +33,8 @@ use Shorewall::Config qw(:DEFAULT :internal);
use Shorewall::Zones; use Shorewall::Zones;
use Shorewall::Chains qw(:DEFAULT :internal); use Shorewall::Chains qw(:DEFAULT :internal);
use Shorewall::IPAddrs; use Shorewall::IPAddrs;
use Shorewall::Nat qw(:rules);
use Shorewall::Raw qw( handle_helper_rule );
use Scalar::Util 'reftype'; use Scalar::Util 'reftype';
use strict; use strict;
@@ -90,7 +92,9 @@ my %rulecolumns = ( action => 0,
connlimit => 10, connlimit => 10,
time => 11, time => 11,
headers => 12, headers => 12,
switch => 13 ); switch => 13,
helper => 14,
);
use constant { MAX_MACRO_NEST_LEVEL => 5 }; use constant { MAX_MACRO_NEST_LEVEL => 5 };
@@ -529,7 +533,7 @@ sub process_policies()
if ( my $fn = open_file 'policy' ) { if ( my $fn = open_file 'policy' ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
process_a_policy while read_a_line; process_a_policy while read_a_line( NORMAL_READ );
} else { } else {
fatal_error q(The 'policy' file does not exist or has zero size); fatal_error q(The 'policy' file does not exist or has zero size);
} }
@@ -1394,7 +1398,7 @@ sub process_actions() {
for my $file ( qw/actions.std actions/ ) { for my $file ( qw/actions.std actions/ ) {
open_file $file; open_file $file;
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $action ) = split_line 'action file' , { action => 0 }; my ( $action ) = split_line 'action file' , { action => 0 };
if ( $action =~ /:/ ) { if ( $action =~ /:/ ) {
@@ -1423,7 +1427,7 @@ sub process_actions() {
} }
sub process_rule1 ( $$$$$$$$$$$$$$$$$ ); sub process_rule1 ( $$$$$$$$$$$$$$$$$$ );
# #
# Populate an action invocation chain. As new action tuples are encountered, # Populate an action invocation chain. As new action tuples are encountered,
@@ -1454,16 +1458,16 @@ sub process_action( $) {
push_comment( '' ); push_comment( '' );
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
my ($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition ); my ($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper );
if ( $format == 1 ) { if ( $format == 1 ) {
($target, $source, $dest, $proto, $ports, $sports, $rate, $user, $mark ) = ($target, $source, $dest, $proto, $ports, $sports, $rate, $user, $mark ) =
split_line1 'action file', { target => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, rate => 6, user => 7, mark => 8 }, $rule_commands; split_line1 'action file', { target => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, rate => 6, user => 7, mark => 8 }, $rule_commands;
$origdest = $connlimit = $time = $headers = $condition = '-'; $origdest = $connlimit = $time = $headers = $condition = $helper = '-';
} else { } else {
($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition ) ($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper )
= split_line1 'action file', \%rulecolumns, $action_commands; = split_line1 'action file', \%rulecolumns, $action_commands;
} }
@@ -1501,6 +1505,7 @@ sub process_action( $) {
$time, $time,
$headers, $headers,
$condition, $condition,
$helper,
0 ); 0 );
} }
@@ -1530,8 +1535,8 @@ sub use_policy_action( $ ) {
# #
# Expand a macro rule from the rules file # Expand a macro rule from the rules file
# #
sub process_macro ( $$$$$$$$$$$$$$$$$$ ) { sub process_macro ( $$$$$$$$$$$$$$$$$$$) {
my ($macro, $chainref, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $wildcard ) = @_; my ($macro, $chainref, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_;
my $nocomment = no_comment; my $nocomment = no_comment;
@@ -1547,15 +1552,15 @@ sub process_macro ( $$$$$$$$$$$$$$$$$$ ) {
push_open $macrofile; push_open $macrofile;
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $morigdest, $mrate, $muser, $mmark, $mconnlimit, $mtime, $mheaders, $mcondition ); my ( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $morigdest, $mrate, $muser, $mmark, $mconnlimit, $mtime, $mheaders, $mcondition, $mhelper);
if ( $format == 1 ) { if ( $format == 1 ) {
( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $mrate, $muser ) = split_line1 'macro file', \%rulecolumns, $rule_commands; ( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $mrate, $muser ) = split_line1 'macro file', \%rulecolumns, $rule_commands;
( $morigdest, $mmark, $mconnlimit, $mtime, $mheaders, $mcondition ) = qw/- - - - - -/; ( $morigdest, $mmark, $mconnlimit, $mtime, $mheaders, $mcondition, $mhelper ) = qw/- - - - - - -/;
} else { } else {
( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $morigdest, $mrate, $muser, $mmark, $mconnlimit, $mtime, $mheaders, $mcondition ) = split_line1 'macro file', \%rulecolumns, $rule_commands; ( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $morigdest, $mrate, $muser, $mmark, $mconnlimit, $mtime, $mheaders, $mcondition, $mhelper ) = split_line1 'macro file', \%rulecolumns, $rule_commands;
} }
fatal_error 'TARGET must be specified' if $mtarget eq '-'; fatal_error 'TARGET must be specified' if $mtarget eq '-';
@@ -1589,7 +1594,7 @@ sub process_macro ( $$$$$$$$$$$$$$$$$$ ) {
my $actiontype = $targets{$action} || find_macro( $action ); my $actiontype = $targets{$action} || find_macro( $action );
fatal_error "Invalid Action ($mtarget) in macro" unless $actiontype & ( ACTION + STANDARD + NATRULE + MACRO ); fatal_error( "Invalid Action ($mtarget) in macro", $actiontype ) unless $actiontype & ( ACTION + STANDARD + NATRULE + MACRO + CHAIN );
if ( $msource ) { if ( $msource ) {
if ( $msource eq '-' ) { if ( $msource eq '-' ) {
@@ -1634,6 +1639,7 @@ sub process_macro ( $$$$$$$$$$$$$$$$$$ ) {
merge_macro_column( $mtime, $time ), merge_macro_column( $mtime, $time ),
merge_macro_column( $mheaders, $headers ), merge_macro_column( $mheaders, $headers ),
merge_macro_column( $mcondition, $condition ), merge_macro_column( $mcondition, $condition ),
merge_macro_column( $mhelper, $helper ),
$wildcard $wildcard
); );
@@ -1666,7 +1672,7 @@ sub verify_audit($;$$) {
# Similarly, if a new action tuple is encountered, this function is called recursively for each rule in the action # Similarly, if a new action tuple is encountered, this function is called recursively for each rule in the action
# body. In this latter case, a reference to the tuple's chain is passed in the first ($chainref) argument. # body. In this latter case, a reference to the tuple's chain is passed in the first ($chainref) argument.
# #
sub process_rule1 ( $$$$$$$$$$$$$$$$ $) { sub process_rule1 ( $$$$$$$$$$$$$$$$$$ ) {
my ( $chainref, #reference to Action Chain if we are being called from process_action(); undef otherwise my ( $chainref, #reference to Action Chain if we are being called from process_action(); undef otherwise
$target, $target,
$current_param, $current_param,
@@ -1683,12 +1689,13 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
$time, $time,
$headers, $headers,
$condition, $condition,
$helper,
$wildcard ) = @_; $wildcard ) = @_;
my ( $action, $loglevel) = split_action $target; my ( $action, $loglevel) = split_action $target;
my ( $basictarget, $param ) = get_target_param $action; my ( $basictarget, $param ) = get_target_param $action;
my $rule = ''; my $rule = '';
my $optimize = $wildcard ? ( $basictarget =~ /!$/ ? 0 : $config{OPTIMIZE} & 1 ) : 0; my $optimize = $wildcard ? ( $basictarget =~ /!$/ ? 0 : $config{OPTIMIZE} & 5 ) : 0;
my $inaction = ''; my $inaction = '';
my $normalized_target; my $normalized_target;
my $normalized_action; my $normalized_action;
@@ -1734,6 +1741,7 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
$time, $time,
$headers, $headers,
$condition, $condition,
$helper,
$wildcard ); $wildcard );
$macro_nest_level--; $macro_nest_level--;
@@ -1757,7 +1765,7 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
# #
# We can now dispense with the postfix character # We can now dispense with the postfix character
# #
fatal_error "The +, - and ! modifiers are not allowed in the blrules file" if $action =~ s/[\+\-!]$// && $blacklist; fatal_error "The +, - and ! modifiers are not allowed in the blrules file" if $action =~ s/[-+!]$// && $blacklist;
# #
# Handle actions # Handle actions
# #
@@ -1775,12 +1783,13 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
# #
process_action( $ref ); process_action( $ref );
# #
# Processing the action may determine that the action or one of it's dependents does NAT, so: # Processing the action may determine that the action or one of it's dependents does NAT or HELPER, so:
# #
# - Refresh $actiontype # - Refresh $actiontype
# - Create the associate nat table chain if appropriate. # - Create the associated nat and/or table chain if appropriate.
# #
ensure_chain( 'nat', $ref->{name} ) if ( $actiontype = $targets{$basictarget} ) & NATRULE; ensure_chain( 'nat', $ref->{name} ) if ( $actiontype = $targets{$basictarget} ) & NATRULE;
ensure_chain( 'raw', $ref->{name} ) if ( $actiontype & HELPER );
} }
$action = $basictarget; # Remove params, if any, from $action. $action = $basictarget; # Remove params, if any, from $action.
@@ -1795,6 +1804,10 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
$targets{$inaction} |= NATRULE if $inaction; $targets{$inaction} |= NATRULE if $inaction;
fatal_error "NAT rules are only allowed in the NEW section" unless $section eq 'NEW'; fatal_error "NAT rules are only allowed in the NEW section" unless $section eq 'NEW';
} }
if ( $actiontype & HELPER ) {
fatal_error "HELPER rules are only allowed in the NEW section" unless $section eq 'NEW';
}
# #
# Take care of irregular syntax and targets # Take care of irregular syntax and targets
# #
@@ -1805,7 +1818,14 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
$bt =~ s/[-+!]$//; $bt =~ s/[-+!]$//;
my %functions = ( ACCEPT => sub() { $action = 'RETURN' if $blacklist; } , my %functions =
( ACCEPT => sub() {
if ( $blacklist ) {
$action = 'RETURN';
} elsif ( $helper ne '-' ) {
$actiontype |= HELPER if $section eq 'NEW';
}
} ,
REDIRECT => sub () { REDIRECT => sub () {
my $z = $actiontype & NATONLY ? '' : firewall_zone; my $z = $actiontype & NATONLY ? '' : firewall_zone;
@@ -1830,12 +1850,19 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
COUNT => sub { $action = ''; } , COUNT => sub { $action = ''; } ,
LOG => sub { fatal_error 'LOG requires a log level' unless supplied $loglevel; } , LOG => sub { fatal_error 'LOG requires a log level' unless supplied $loglevel; } ,
HELPER => sub {
fatal_error "HELPER requires require that the helper be specified in the HELPER column" if $helper eq '-';
fatal_error "HELPER rules may only appear in the NEW section" unless $section eq 'NEW';
$action = ''; } ,
); );
my $function = $functions{ $bt }; my $function = $functions{ $bt };
if ( $function ) { if ( $function ) {
$function->(); $function->();
} elsif ( $actiontype & NATRULE && $helper ne '-' ) {
$actiontype |= HELPER;
} elsif ( $actiontype & SET ) { } elsif ( $actiontype & SET ) {
my %xlate = ( ADD => 'add-set' , DEL => 'del-set' ); my %xlate = ( ADD => 'add-set' , DEL => 'del-set' );
@@ -1920,7 +1947,7 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
# #
# Take care of chain # Take care of chain
# #
my ( $chain, $policy ); my $chain;
if ( $inaction ) { if ( $inaction ) {
# #
@@ -1944,7 +1971,7 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
# Ensure that the chain exists but don't mark it as referenced until after optimization is checked # Ensure that the chain exists but don't mark it as referenced until after optimization is checked
# #
$chainref = ensure_chain 'filter', $chain; $chainref = ensure_chain 'filter', $chain;
$policy = $chainref->{policy}; my $policy = $chainref->{policy};
if ( $policy eq 'NONE' ) { if ( $policy eq 'NONE' ) {
return 0 if $wildcard; return 0 if $wildcard;
@@ -1953,10 +1980,10 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
# #
# Handle Optimization # Handle Optimization
# #
if ( $optimize > 0 && $section eq 'NEW' ) { if ( $optimize == 1 && $section eq 'NEW' ) {
my $loglevel = $filter_table->{$chainref->{policychain}}{loglevel}; my $loglevel = $filter_table->{$chainref->{policychain}}{loglevel};
if ( $loglevel ne '' ) { if ( $loglevel ne '' ) {
return 0 if $target eq "${policy}:$loglevel}"; return 0 if $target eq "${policy}:${loglevel}";
} else { } else {
return 0 if $basictarget eq $policy; return 0 if $basictarget eq $policy;
} }
@@ -2002,6 +2029,18 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
do_headers( $headers ) , do_headers( $headers ) ,
do_condition( $condition ) , do_condition( $condition ) ,
); );
} elsif ( $section eq 'RELATED' ) {
$rule = join( '',
do_proto($proto, $ports, $sports),
do_ratelimit( $ratelimit, $basictarget ) ,
do_user( $user ) ,
do_test( $mark , $globals{TC_MASK} ) ,
do_connlimit( $connlimit ),
do_time( $time ) ,
do_headers( $headers ) ,
do_condition( $condition ) ,
do_helper( $helper ) ,
);
} else { } else {
$rule = join( '', $rule = join( '',
do_proto($proto, $ports, $sports), do_proto($proto, $ports, $sports),
@@ -2025,137 +2064,53 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
fatal_error "$basictarget rules are not allowed in the $section SECTION" if $actiontype & ( NATRULE | NONAT ); fatal_error "$basictarget rules are not allowed in the $section SECTION" if $actiontype & ( NATRULE | NONAT );
$rule .= "$globals{STATEMATCH} $section " unless $section eq 'ALL' || $blacklist; $rule .= "$globals{STATEMATCH} $section " unless $section eq 'ALL' || $blacklist;
} }
# #
# Generate CT rules(s), if any
#
if ( $actiontype & HELPER ) {
handle_helper_rule( $helper,
$source,
$origdest ? $origdest : $dest,
$proto,
$ports,
$sports,
$sourceref,
( $actiontype & ACTION ) ? $usedactions{$normalized_target}->{name} : '',
$inaction ? $chain : '' ,
$user ,
$rule ,
);
$targets{$inaction} |= HELPER if $inaction;
}
# Generate NAT rule(s), if any # Generate NAT rule(s), if any
# #
if ( $actiontype & NATRULE ) { if ( $actiontype & NATRULE ) {
my ( $server, $serverport );
my $randomize = $dest =~ s/:random$// ? ' --random' : '';
require_capability( 'NAT_ENABLED' , "$basictarget rules", '' ); require_capability( 'NAT_ENABLED' , "$basictarget rules", '' );
# #
# Isolate server port # Add the appropriate rule to the nat table
# #
if ( $dest =~ /^(.*)(:(.+))$/ ) { ( $ports,
# $origdstports,
# Server IP and Port $dest ) = handle_nat_rule( $dest,
# $proto,
$server = $1; # May be empty $ports,
$serverport = $3; # Not Empty due to RE $origdest,
$origdstports = $ports; ( $actiontype & ACTION ) ? $usedactions{$normalized_target}->{name} : '',
$action,
if ( $origdstports && $origdstports ne '-' && port_count( $origdstports ) == 1 ) { $sourceref,
$origdstports = validate_port( $proto, $origdstports ); $inaction ? $chain : '',
} else { $rule,
$origdstports = ''; $source,
} ( $actiontype & ACTION ) ? '' : $loglevel,
$log_action,
if ( $serverport =~ /^(\d+)-(\d+)$/ ) {
#
# Server Port Range
#
fatal_error "Invalid port range ($serverport)" unless $1 < $2;
my @ports = ( $1, $2 );
$_ = validate_port( proto_name( $proto ), $_) for ( @ports );
( $ports = $serverport ) =~ tr/-/:/;
} else {
$serverport = $ports = validate_port( proto_name( $proto ), $serverport );
}
} elsif ( $dest eq ':' ) {
#
# Rule with no server IP or port ( zone:: )
#
$server = $serverport = '';
} else {
#
# Simple server IP address (may be empty or "-")
#
$server = $dest;
$serverport = '';
}
#
# Generate the target
#
my $target = '';
if ( $actiontype & REDIRECT ) {
fatal_error "A server IP address ($server) may not be specified in a REDIRECT rule" if $server;
$target = 'REDIRECT';
$target .= " --to-port $serverport" if $serverport;
if ( $origdest eq '' || $origdest eq '-' ) {
$origdest = ALLIP;
} elsif ( $origdest eq 'detect' ) {
fatal_error 'ORIGINAL DEST "detect" is invalid in an action' if $inaction;
if ( $config{DETECT_DNAT_IPADDRS} && $sourcezone ne firewall_zone ) {
my $interfacesref = $sourceref->{interfaces};
my @interfaces = keys %$interfacesref;
$origdest = @interfaces ? "detect:@interfaces" : ALLIP;
} else {
$origdest = ALLIP;
}
}
} elsif ( $actiontype & ACTION ) {
fatal_error "A server port ($serverport) is not allowed in $action rule" if $serverport;
$target = $usedactions{$normalized_target}->{name};
$loglevel = '';
} else {
if ( $server eq '' ) {
fatal_error "A server and/or port must be specified in the DEST column in $action rules" unless $serverport;
} elsif ( $server =~ /^(.+)-(.+)$/ ) {
validate_range( $1, $2 );
} else {
unless ( ( $actiontype & ACTION ) && $server eq ALLIP ) {
my @servers = validate_address $server, 1;
$server = join ',', @servers;
}
}
if ( $action eq 'DNAT' ) {
$target = 'DNAT';
if ( $server ) {
$serverport = ":$serverport" if $serverport;
for my $serv ( split /,/, $server ) {
$target .= " --to-destination ${serv}${serverport}";
}
} else {
$target .= " --to-destination :$serverport";
}
}
unless ( $origdest && $origdest ne '-' && $origdest ne 'detect' ) {
if ( ! $inaction && $config{DETECT_DNAT_IPADDRS} && $sourcezone ne firewall_zone ) {
my $interfacesref = $sourceref->{interfaces};
my @interfaces = keys %$interfacesref;
$origdest = @interfaces ? "detect:@interfaces" : ALLIP;
} else {
$origdest = ALLIP;
}
}
}
$target .= $randomize;
#
# And generate the nat table rule(s)
#
expand_rule ( ensure_chain ('nat' , $inaction ? $chain : $sourceref->{type} == FIREWALL ? 'OUTPUT' : dnat_chain $sourcezone ),
PREROUTE_RESTRICT ,
$rule ,
$source ,
$origdest ,
'' ,
$target ,
$loglevel ,
$log_action ,
$serverport ? do_proto( $proto, '', '' ) : '',
); );
# #
# After NAT: # After NAT:
# - the destination port will be the server port ($ports) -- we did that above # - the destination port will be the server port ($ports) -- we did that above
# - the destination IP will be the server IP ($dest) # - the destination IP will be the server IP ($dest) -- also done above
# - there will be no log level (we log NAT rules in the nat table rather than in the filter table). # - there will be no log level (we log NAT rules in the nat table rather than in the filter table).
# - the target will be ACCEPT. # - the target will be ACCEPT.
# #
@@ -2168,88 +2123,24 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) {
do_condition( $condition ) do_condition( $condition )
); );
$loglevel = ''; $loglevel = '';
$dest = $server;
$action = 'ACCEPT'; $action = 'ACCEPT';
$origdest = ALLIP if $origdest =~ /[+]/; $origdest = ALLIP if $origdest =~ /[+]/;
$helper = '-';
} }
} elsif ( $actiontype & NONAT ) { } elsif ( $actiontype & NONAT ) {
# #
# NONAT or ACCEPT+ -- May not specify a destination interface # NONAT or ACCEPT+
# #
fatal_error "Invalid DEST ($dest) in $action rule" if $dest =~ /:/; handle_nonat_rule( $action,
$source,
$origdest = '' unless $origdest and $origdest ne '-'; $dest,
$origdest,
if ( $origdest eq 'detect' ) { $sourceref,
my $interfacesref = $sourceref->{interfaces}; $inaction,
my $interfaces = [ ( keys %$interfacesref ) ]; $chain,
$origdest = $interfaces ? "detect:@$interfaces" : ALLIP;
}
my $tgt = 'RETURN';
my $nonat_chain;
my $chn;
if ( $inaction ) {
$nonat_chain = ensure_chain( 'nat', $chain );
} elsif ( $sourceref->{type} == FIREWALL ) {
$nonat_chain = $nat_table->{OUTPUT};
} else {
$nonat_chain = ensure_chain( 'nat', dnat_chain( $sourcezone ) );
my @interfaces = keys %{zone_interfaces $sourcezone};
for ( @interfaces ) {
my $ichain = input_chain $_;
if ( $nat_table->{$ichain} ) {
#
# Static NAT is defined on this interface
#
$chn = new_chain( 'nat', newnonatchain ) unless $chn;
add_ijump $chn, j => $nat_table->{$ichain}, @interfaces > 1 ? imatch_source_dev( $_ ) : ();
}
}
if ( $chn ) {
#
# Call expand_rule() to correctly handle logging. Because
# the 'logname' argument is passed, expand_rule() will
# not create a separate logging chain but will rather emit
# any logging rule in-line.
#
expand_rule( $chn,
PREROUTE_RESTRICT,
'', # Rule
'', # Source
'', # Dest
'', # Original dest
'ACCEPT',
$loglevel, $loglevel,
$log_action, $log_action,
'', $rule
dnat_chain( $sourcezone ) );
$loglevel = '';
$tgt = $chn->{name};
} else {
$tgt = 'ACCEPT';
}
}
set_optflags( $nonat_chain, DONT_MOVE | DONT_OPTIMIZE ) if $tgt eq 'RETURN';
expand_rule( $nonat_chain ,
PREROUTE_RESTRICT ,
$rule ,
$source ,
$dest ,
$origdest ,
$tgt,
$loglevel ,
$log_action ,
'',
); );
} }
@@ -2390,7 +2281,7 @@ sub build_zone_list( $$$\$\$ ) {
# Process a Record in the rules file # Process a Record in the rules file
# #
sub process_rule ( ) { sub process_rule ( ) {
my ( $target, $source, $dest, $protos, $ports, $sports, $origdest, $ratelimit, $user, $mark, $connlimit, $time, $headers, $condition ) my ( $target, $source, $dest, $protos, $ports, $sports, $origdest, $ratelimit, $user, $mark, $connlimit, $time, $headers, $condition, $helper )
= split_line1 'rules file', \%rulecolumns, $rule_commands; = split_line1 'rules file', \%rulecolumns, $rule_commands;
fatal_error 'ACTION must be specified' if $target eq '-'; fatal_error 'ACTION must be specified' if $target eq '-';
@@ -2447,6 +2338,7 @@ sub process_rule ( ) {
$time, $time,
$headers, $headers,
$condition, $condition,
$helper,
$wild ); $wild );
} }
} }
@@ -2471,7 +2363,7 @@ sub classic_blacklist() {
my $fw = firewall_zone; my $fw = firewall_zone;
my @zones = off_firewall_zones; my @zones = off_firewall_zones;
my @vservers = vserver_zones; my @vservers = vserver_zones;
my @state = $config{BLACKLISTNEWONLY} ? $globals{UNTRACKED} ? state_imatch 'NEW,INVALID,UNTRACKED' : state_imatch 'NEW,INVALID' : (); my @state = $config{BLACKLISTNEWONLY} ? have_capability( 'RAW_TABLE' ) ? state_imatch 'NEW,INVALID,UNTRACKED' : state_imatch 'NEW,INVALID' : ();
my $result; my $result;
for my $zone ( @zones ) { for my $zone ( @zones ) {
@@ -2567,7 +2459,7 @@ sub process_rules( $ ) {
} }
); );
process_rule while read_a_line; process_rule while read_a_line( NORMAL_READ );
} }
$section = ''; $section = '';
@@ -2585,7 +2477,7 @@ sub process_rules( $ ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
process_rule while read_a_line; process_rule while read_a_line( NORMAL_READ );
clear_comment; clear_comment;
} }

View File

@@ -163,13 +163,17 @@ my @tcclasses;
my %tcclasses; my %tcclasses;
my %restrictions = ( tcpre => PREROUTE_RESTRICT , my %restrictions = ( tcpre => PREROUTE_RESTRICT ,
PREROUTING => PREROUTE_RESTRICT ,
tcpost => POSTROUTE_RESTRICT , tcpost => POSTROUTE_RESTRICT ,
tcfor => NO_RESTRICT , tcfor => NO_RESTRICT ,
tcin => INPUT_RESTRICT , tcin => INPUT_RESTRICT ,
tcout => OUTPUT_RESTRICT ); tcout => OUTPUT_RESTRICT ,
);
my $family; my $family;
my $divertref; # DIVERT chain
# #
# Rather than initializing globals in an INIT block or during declaration, # Rather than initializing globals in an INIT block or during declaration,
# we initialize them in a function. This is done for two reasons: # we initialize them in a function. This is done for two reasons:
@@ -191,21 +195,24 @@ sub initialize( $ ) {
$devnum = 0; $devnum = 0;
$sticky = 0; $sticky = 0;
$ipp2p = 0; $ipp2p = 0;
$divertref = 0;
} }
sub process_tc_rule( ) { sub process_tc_rule( ) {
my ( $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp ); my ( $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp );
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
( $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp ) = ( $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp ) =
split_line1 'tcrules file', { mark => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, test => 7, length => 8, tos => 9, connbytes => 10, helper => 11, probability => 12 , dscp => 13 }; split_line1 'tcrules file', { mark => 0, action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, test => 7, length => 8, tos => 9, connbytes => 10, helper => 11, probability => 12 , dscp => 13 }, { COMMENT => 0, FORMAT => 2 } , 14;
$headers = '-'; $headers = '-';
} else { } else {
( $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp ) = ( $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp ) =
split_line1 'tcrules file', { mark => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, test => 7, length => 8, tos => 9, connbytes => 10, helper => 11, headers => 12, probability => 13 , dscp => 14 }; split_line1 'tcrules file', { mark => 0, action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, test => 7, length => 8, tos => 9, connbytes => 10, helper => 11, headers => 12, probability => 13 , dscp => 14 }, { COMMENT => 0, FORMAT => 2 }, 15;
} }
our @tccmd; our @tccmd;
our $format;
fatal_error 'MARK must be specified' if $originalmark eq '-'; fatal_error 'MARK must be specified' if $originalmark eq '-';
if ( $originalmark eq 'COMMENT' ) { if ( $originalmark eq 'COMMENT' ) {
@@ -213,6 +220,15 @@ sub process_tc_rule( ) {
return; return;
} }
if ( $originalmark eq 'FORMAT' ) {
if ( $source =~ /^([12])$/ ) {
$format = $1;
return;
}
fatal_error "Invalid FORMAT ($source)";
}
my ( $mark, $designator, $remainder ) = split( /:/, $originalmark, 3 ); my ( $mark, $designator, $remainder ) = split( /:/, $originalmark, 3 );
fatal_error "Invalid MARK ($originalmark)" unless supplied $mark; fatal_error "Invalid MARK ($originalmark)" unless supplied $mark;
@@ -242,6 +258,7 @@ sub process_tc_rule( ) {
my $restriction = 0; my $restriction = 0;
my $cmd; my $cmd;
my $rest; my $rest;
my $matches = '';
my %processtcc = ( sticky => sub() { my %processtcc = ( sticky => sub() {
if ( $chain eq 'tcout' ) { if ( $chain eq 'tcout' ) {
@@ -294,23 +311,57 @@ sub process_tc_rule( ) {
$target = "IPMARK --addr $srcdst --and-mask $mask1 --or-mask $mask2 --shift $shift"; $target = "IPMARK --addr $srcdst --and-mask $mask1 --or-mask $mask2 --shift $shift";
}, },
DIVERT => sub() {
fatal_error "Invalid MARK ($originalmark)" unless $format == 2;
fatal_error "Invalid DIVERT specification( $cmd/$rest )" if $rest;
$chain = 'PREROUTING';
$mark = in_hex( $globals{TPROXY_MARK} ) . '/' . in_hex( $globals{TPROXY_MARK} );
unless ( $divertref ) {
$divertref = new_chain( 'mangle', 'divert' );
add_ijump( $divertref , j => 'MARK', targetopts => "--set-mark $mark" );
add_ijump( $divertref , j => 'ACCEPT' );
}
$target = 'divert';
$matches = '! --tcp-flags FIN,SYN,RST,ACK SYN -m socket --transparent ';
},
TPROXY => sub() { TPROXY => sub() {
require_capability( 'TPROXY_TARGET', 'Use of TPROXY', 's'); require_capability( 'TPROXY_TARGET', 'Use of TPROXY', 's');
fatal_error "Invalid TPROXY specification( $cmd/$rest )" if $rest; fatal_error "Invalid TPROXY specification( $cmd/$rest )" if $rest;
$chain = 'tcpre'; $chain = 'PREROUTING';
$cmd =~ /TPROXY\((.+?)\)$/; $cmd =~ /TPROXY\((.+?)\)$/;
my $params = $1; my $params = $1;
my ( $port, $ip, $bad );
if ( $format == 1 ) {
fatal_error "Invalid TPROXY specification( $cmd )" unless defined $params; fatal_error "Invalid TPROXY specification( $cmd )" unless defined $params;
( $mark, my $port, my $ip, my $bad ) = split ',', $params; ( $mark, $port, $ip, $bad ) = split_list $params, 'Parameter';
fatal_error "Invalid TPROXY specification( $cmd )" if defined $bad; fatal_error "Invalid TPROXY specification( $cmd )" if defined $bad;
warning_message "TPROXY is deprecated in a format-1 tcrules file";
} else {
if ( $params ) {
( $port, $ip, $bad ) = split_list $params, 'Parameter';
fatal_error "Invalid TPROXY specification( $cmd )" if defined $bad;
} else {
fatal_error "Invalid TPROXY specification ($cmd)" unless $cmd eq 'TPROXY' || $cmd eq 'TPROXY()';
}
$mark = in_hex( $globals{TPROXY_MARK} ) . '/' . in_hex( $globals{TPROXY_MARK} );
}
if ( $port ) { if ( $port ) {
$port = validate_port( 'tcp', $port ); $port = validate_port( 'tcp', $port );
} else { } else {
@@ -530,7 +581,7 @@ sub process_tc_rule( ) {
if ( ( my $result = expand_rule( ensure_chain( 'mangle' , $chain ) , if ( ( my $result = expand_rule( ensure_chain( 'mangle' , $chain ) ,
$restrictions{$chain} | $restriction, $restrictions{$chain} | $restriction,
do_proto( $proto, $ports, $sports) . do_proto( $proto, $ports, $sports) . $matches .
do_user( $user ) . do_user( $user ) .
do_test( $testval, $globals{TC_MASK} ) . do_test( $testval, $globals{TC_MASK} ) .
do_length( $length ) . do_length( $length ) .
@@ -539,7 +590,7 @@ sub process_tc_rule( ) {
do_helper( $helper ) . do_helper( $helper ) .
do_headers( $headers ) . do_headers( $headers ) .
do_probability( $probability ) . do_probability( $probability ) .
do_dscp( $dscp ), do_dscp( $dscp ) ,
$source , $source ,
$dest , $dest ,
'' , '' ,
@@ -802,6 +853,8 @@ sub process_simple_device() {
progress_message " Simple tcdevice \"$currentline\" $done."; progress_message " Simple tcdevice \"$currentline\" $done.";
} }
my %validlinklayer = ( ethernet => 1, atm => 1, adsl => 1 );
sub validate_tc_device( ) { sub validate_tc_device( ) {
my ( $device, $inband, $outband , $options , $redirected ) = split_line 'tcdevices', { interface => 0, in_bandwidth => 1, out_bandwidth => 2, options => 3, redirect => 4 }; my ( $device, $inband, $outband , $options , $redirected ) = split_line 'tcdevices', { interface => 0, in_bandwidth => 1, out_bandwidth => 2, options => 3, redirect => 4 };
@@ -836,7 +889,8 @@ sub validate_tc_device( ) {
fatal_error "Duplicate INTERFACE ($device)" if $tcdevices{$device}; fatal_error "Duplicate INTERFACE ($device)" if $tcdevices{$device};
fatal_error "Invalid INTERFACE name ($device)" if $device =~ /[:+]/; fatal_error "Invalid INTERFACE name ($device)" if $device =~ /[:+]/;
my ( $classify, $pfifo, $flow, $qdisc ) = (0, 0, '', 'htb' ); my ( $classify, $pfifo, $flow, $qdisc, $linklayer, $overhead, $mtu, $mpu, $tsize ) =
(0, 0, '', 'htb', '', 0, 0, 0, 0);
if ( $options ne '-' ) { if ( $options ne '-' ) {
for my $option ( split_list1 $options, 'option' ) { for my $option ( split_list1 $options, 'option' ) {
@@ -852,6 +906,25 @@ sub validate_tc_device( ) {
$qdisc = 'hfsc'; $qdisc = 'hfsc';
} elsif ( $option eq 'htb' ) { } elsif ( $option eq 'htb' ) {
$qdisc = 'htb'; $qdisc = 'htb';
} elsif ( $option =~ /^linklayer=([a-z]+)$/ ) {
$linklayer = $1;
fatal_error "Invalid linklayer ($linklayer)" unless $validlinklayer{ $linklayer };
} elsif ( $option =~ /^overhead=(.+)$/ ) {
$overhead = numeric_value( $1 );
fatal_error "Invalid overhead ($1)" unless defined $overhead;
fatal_error q('overhead' requires 'linklayer') unless $linklayer;
} elsif ( $option =~ /^mtu=(.+)$/ ) {
$mtu = numeric_value( $1 );
fatal_error "Invalid mtu ($1)" unless defined $mtu;
fatal_error q('mtu' requires 'linklayer') unless $linklayer;
} elsif ( $option =~ /^mpu=(.+)$/ ) {
$mpu = numeric_value( $1 );
fatal_error "Invalid mpu ($1)" unless defined $mpu;
fatal_error q('mpu' requires 'linklayer') unless $linklayer;
} elsif ( $option =~ /^tsize=(.+)$/ ) {
$tsize = numeric_value( $1 );
fatal_error "Invalid tsize ($1)" unless defined $tsize;
fatal_error q('tsize' requires 'linklayer') unless $linklayer;
} else { } else {
fatal_error "Unknown device option ($option)"; fatal_error "Unknown device option ($option)";
} }
@@ -890,7 +963,12 @@ sub validate_tc_device( ) {
guarantee => 0, guarantee => 0,
name => $device, name => $device,
physical => physical_name $device, physical => physical_name $device,
filters => [] filters => [],
linklayer => $linklayer,
overhead => $overhead,
mtu => $mtu,
mpu => $mpu,
tsize => $tsize,
} , } ,
push @tcdevices, $device; push @tcdevices, $device;
@@ -924,7 +1002,7 @@ sub convert_delay( $ ) {
my $delay = shift; my $delay = shift;
return 0 unless $delay; return 0 unless $delay;
return $1 if $delay =~ /^(\d+)(ms)?$/; return $1 if $delay =~ /^(\d+(\.\d+)?)(ms)?$/;
fatal_error "Invalid Delay ($delay)"; fatal_error "Invalid Delay ($delay)";
} }
@@ -953,6 +1031,18 @@ sub dev_by_number( $ ) {
( $dev , $devref ); ( $dev , $devref );
} }
use constant { RED_INTEGER => 1, RED_FLOAT => 2, RED_NONE => 3 };
my %validredoptions = ( min => RED_INTEGER,
max => RED_INTEGER,
limit => RED_INTEGER,
burst => RED_INTEGER,
avpkt => RED_INTEGER,
bandwidth => RED_INTEGER,
probability => RED_FLOAT,
ecn => RED_NONE,
);
sub validate_tc_class( ) { sub validate_tc_class( ) {
my ( $devclass, $mark, $rate, $ceil, $prio, $options ) = my ( $devclass, $mark, $rate, $ceil, $prio, $options ) =
split_line 'tcclasses file', { interface => 0, mark => 1, rate => 2, ceil => 3, prio => 4, options => 5 }; split_line 'tcclasses file', { interface => 0, mark => 1, rate => 2, ceil => 3, prio => 4, options => 5 };
@@ -962,6 +1052,7 @@ sub validate_tc_class( ) {
my $occurs = 1; my $occurs = 1;
my $parentclass = 1; my $parentclass = 1;
my $parentref; my $parentref;
my $lsceil = 0;
fatal_error 'INTERFACE must be specified' if $devclass eq '-'; fatal_error 'INTERFACE must be specified' if $devclass eq '-';
fatal_error 'CEIL must be specified' if $ceil eq '-'; fatal_error 'CEIL must be specified' if $ceil eq '-';
@@ -1008,9 +1099,6 @@ sub validate_tc_class( ) {
my $markval = 0; my $markval = 0;
if ( $mark ne '-' ) { if ( $mark ne '-' ) {
if ( $devref->{classify} ) {
warning_message "INTERFACE $device has the 'classify' option - MARK value ($mark) ignored";
} else {
fatal_error "MARK may not be specified when TC_BITS=0" unless $config{TC_BITS}; fatal_error "MARK may not be specified when TC_BITS=0" unless $config{TC_BITS};
$markval = numeric_value( $mark ); $markval = numeric_value( $mark );
@@ -1024,7 +1112,6 @@ sub validate_tc_class( ) {
$classnumber = $config{TC_BITS} >= 14 ? $devref->{nextclass}++ : hex_value( $devnum . $markval ); $classnumber = $config{TC_BITS} >= 14 ? $devref->{nextclass}++ : hex_value( $devnum . $markval );
fatal_error "Duplicate MARK ($mark)" if $tcref->{$classnumber}; fatal_error "Duplicate MARK ($mark)" if $tcref->{$classnumber};
} }
}
} else { } else {
fatal_error "Duplicate Class NUMBER ($classnumber)" if $tcref->{$classnumber}; fatal_error "Duplicate Class NUMBER ($classnumber)" if $tcref->{$classnumber};
$markval = '-'; $markval = '-';
@@ -1038,7 +1125,9 @@ sub validate_tc_class( ) {
my $parentnum = in_hexp $parentclass; my $parentnum = in_hexp $parentclass;
fatal_error "Unknown Parent class ($parentnum)" unless $parentref && $parentref->{occurs} == 1; fatal_error "Unknown Parent class ($parentnum)" unless $parentref && $parentref->{occurs} == 1;
fatal_error "The class ($parentnum) specifies UMAX and/or DMAX; it cannot serve as a parent" if $parentref->{dmax}; fatal_error "The class ($parentnum) specifies UMAX and/or DMAX; it cannot serve as a parent" if $parentref->{dmax};
fatal_error "The class ($parentnum) specifies flow; it cannot serve as a parent" if $parentref->{flow}; fatal_error "The class ($parentnum) specifies 'flow'; it cannot serve as a parent" if $parentref->{flow};
fatal_error "The class ($parentnum) specifies 'red'; it cannot serve as a parent " if $parentref->{red};
fatal_error "The class ($parentnum) has an 'ls' curve; it cannot serve as a parent " if $parentref->{lsceil};
fatal_error "The default class ($parentnum) may not have sub-classes" if ( $devref->{default} || 0 ) == $parentclass; fatal_error "The default class ($parentnum) may not have sub-classes" if ( $devref->{default} || 0 ) == $parentclass;
$parentref->{leaf} = 0; $parentref->{leaf} = 0;
$ratemax = $parentref->{rate}; $ratemax = $parentref->{rate};
@@ -1049,7 +1138,17 @@ sub validate_tc_class( ) {
my ( $umax, $dmax ) = ( '', '' ); my ( $umax, $dmax ) = ( '', '' );
if ( $ceil =~ /^(.+):(.+)/ ) {
fatal_error "An LS rate may only be specified for HFSC classes" unless $devref->{qdisc} eq 'hfsc';
$lsceil = $1;
$ceil = $2;
}
if ( $devref->{qdisc} eq 'hfsc' ) { if ( $devref->{qdisc} eq 'hfsc' ) {
if ( $rate eq '-' ) {
fatal_error 'A RATE must be supplied' unless $lsceil;
$rate = 0;
} else {
( my $trate , $dmax, $umax , my $rest ) = split ':', $rate , 4; ( my $trate , $dmax, $umax , my $rest ) = split ':', $rate , 4;
fatal_error "Invalid RATE ($rate)" if defined $rest; fatal_error "Invalid RATE ($rate)" if defined $rest;
@@ -1059,6 +1158,7 @@ sub validate_tc_class( ) {
$umax = convert_size( $umax ); $umax = convert_size( $umax );
fatal_error "DMAX must be specified when UMAX is specified" if $umax && ! $dmax; fatal_error "DMAX must be specified when UMAX is specified" if $umax && ! $dmax;
$parentclass ||= 1; $parentclass ||= 1;
}
} else { } else {
$rate = convert_rate ( $ratemax, $rate, 'RATE' , $ratename ); $rate = convert_rate ( $ratemax, $rate, 'RATE' , $ratename );
} }
@@ -1075,7 +1175,8 @@ sub validate_tc_class( ) {
rate => $rate , rate => $rate ,
umax => $umax , umax => $umax ,
dmax => $dmax , dmax => $dmax ,
ceiling => convert_rate( $ceilmax, $ceil, 'CEIL' , $ceilname ) , ceiling => $ceil = ( supplied $ceil ? convert_rate( $ceilmax, $ceil, 'CEIL' , $ceilname ) : 0 ),
lsceil => $lsceil = ( $lsceil ? convert_rate( $ceilmax, $lsceil, 'LSCEIL', $ceilname ) : 0 ),
priority => $prio eq '-' ? 1 : $prio , priority => $prio eq '-' ? 1 : $prio ,
mark => $markval , mark => $markval ,
flow => '' , flow => '' ,
@@ -1089,7 +1190,9 @@ sub validate_tc_class( ) {
$tcref = $tcref->{$classnumber}; $tcref = $tcref->{$classnumber};
fatal_error "RATE ($tcref->{rate}) exceeds CEIL ($tcref->{ceiling})" if $tcref->{rate} > $tcref->{ceiling}; fatal_error "RATE ($rate) exceeds CEIL ($ceil)" if $rate && $ceil && $rate > $ceil;
my ( $red, %redopts ) = ( 0, ( avpkt => 1000 ) );
unless ( $options eq '-' ) { unless ( $options eq '-' ) {
for my $option ( split_list1 "\L$options", 'option' ) { for my $option ( split_list1 "\L$options", 'option' ) {
@@ -1114,9 +1217,11 @@ sub validate_tc_class( ) {
push @{$tcref->{tos}}, $option; push @{$tcref->{tos}}, $option;
} elsif ( $option =~ /^flow=(.*)$/ ) { } elsif ( $option =~ /^flow=(.*)$/ ) {
fatal_error "The 'flow' option is not allowed with 'pfifo'" if $tcref->{pfifo}; fatal_error "The 'flow' option is not allowed with 'pfifo'" if $tcref->{pfifo};
fatal_error "The 'flow' option is not allowed with 'red'" if $tcref->{red};
$tcref->{flow} = process_flow $1; $tcref->{flow} = process_flow $1;
} elsif ( $option eq 'pfifo' ) { } elsif ( $option eq 'pfifo' ) {
fatal_error "The 'pfifo'' option is not allowed with 'flow='" if $tcref->{flow}; fatal_error "The 'pfifo' option is not allowed with 'flow='" if $tcref->{flow};
fatal_error "The 'pfifo' option is not allowed with 'red='" if $tcref->{red};
$tcref->{pfifo} = 1; $tcref->{pfifo} = 1;
} elsif ( $option =~ /^occurs=(\d+)$/ ) { } elsif ( $option =~ /^occurs=(\d+)$/ ) {
my $val = $1; my $val = $1;
@@ -1137,6 +1242,57 @@ sub validate_tc_class( ) {
warning_message "limit ignored with pfifo queuing" if $tcref->{pfifo}; warning_message "limit ignored with pfifo queuing" if $tcref->{pfifo};
fatal_error "Invalid limit ($1)" if $1 < 3 || $1 > 128; fatal_error "Invalid limit ($1)" if $1 < 3 || $1 > 128;
$tcref->{limit} = $1; $tcref->{limit} = $1;
} elsif ( $option =~ s/^red=// ) {
fatal_error "The 'red=' option is not allowed with 'flow='" if $tcref->{flow};
fatal_error "The 'red=' option is not allowed with 'pfifo'" if $tcref->{pfifo};
$tcref->{red} = 1;
my $opttype;
for my $redopt ( split_list( $option , q('red' option list) ) ) {
#
# $2 ----------------------
# $1 ------ | $3 ------- |
# | | | | | |
if ( $redopt =~ /^([a-z]+) (?:= ( ([01]?\.)?(\d{1,8})) )?$/x ) {
fatal_error "Invalid RED option ($1)" unless $opttype = $validredoptions{$1};
if ( $2 ) {
#
# '=<value>' supplied
#
fatal_error "The $1 option does not take a value" if $opttype == RED_NONE;
if ( $3 ) {
#
# fractional value
#
fatal_error "The $1 option requires an integer value" if $opttype == RED_INTEGER;
fatal_error "The value of $1 must be <= 1" if $2 > 1;
} else {
#
# Integer value
#
fatal_error "The $1 option requires a value 0 <= value <= 1" if $opttype == RED_FLOAT;
}
} else {
#
# No value supplied
#
fatal_error "The $1 option requires a value" unless $opttype == RED_NONE;
}
$redopts{$1} = $2;
} else {
fatal_error "Invalid RED option specification ($redopt)";
}
}
for ( qw/ limit min max avpkt burst probability / ) {
fatal_error "The $_ 'red' option is required" unless $redopts{$_};
}
fatal_error "The 'max' red option must be at least 2 * 'min'" unless $redopts{max} >= 2 * $redopts{min};
fatal_error "The 'limit' red option must be at least 2 * 'max'" unless $redopts{limit} >= 2 * $redopts{min};
$redopts{ecn} = 1 if exists $redopts{ecn};
$tcref->{redopts} = \%redopts;
} else { } else {
fatal_error "Unknown option ($option)"; fatal_error "Unknown option ($option)";
} }
@@ -1168,6 +1324,8 @@ sub validate_tc_class( ) {
occurs => 0, occurs => 0,
parent => $parentclass, parent => $parentclass,
limit => $tcref->{limit}, limit => $tcref->{limit},
red => $tcref->{red},
redopts => $tcref->{redopts},
}; };
push @tcclasses, "$device:$classnumber"; push @tcclasses, "$device:$classnumber";
}; };
@@ -1455,7 +1613,7 @@ sub process_tcfilters() {
first_entry( "$doing $fn..." ); first_entry( "$doing $fn..." );
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
if ( $currentline =~ /^\s*IPV4\s*$/ ) { if ( $currentline =~ /^\s*IPV4\s*$/ ) {
Shorewall::IPAddrs::initialize( $family = F_IPV4 ) unless $family == F_IPV4; Shorewall::IPAddrs::initialize( $family = F_IPV4 ) unless $family == F_IPV4;
} elsif ( $currentline =~ /^\s*IPV6\s*$/ ) { } elsif ( $currentline =~ /^\s*IPV6\s*$/ ) {
@@ -1499,7 +1657,6 @@ sub process_tc_priority() {
$interface eq '-' && $interface eq '-' &&
$helper eq '-' ); $helper eq '-' );
my $val = numeric_value $band; my $val = numeric_value $band;
fatal_error "Invalid PRIORITY ($band)" unless $val && $val <= 3; fatal_error "Invalid PRIORITY ($band)" unless $val && $val <= 3;
@@ -1555,7 +1712,7 @@ sub process_tcinterfaces() {
if ( $fn ) { if ( $fn ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
process_simple_device while read_a_line; process_simple_device while read_a_line( NORMAL_READ );
} }
} }
@@ -1573,7 +1730,7 @@ sub process_tcpri() {
warning_message "There are entries in $fn1 but $fn was empty" unless @tcdevices || $family == F_IPV6; warning_message "There are entries in $fn1 but $fn was empty" unless @tcdevices || $family == F_IPV6;
}; };
process_tc_priority while read_a_line; process_tc_priority while read_a_line( NORMAL_READ );
clear_comment; clear_comment;
@@ -1584,8 +1741,14 @@ sub process_tcpri() {
mark => '--mark 0/' . in_hex( $globals{TC_MASK} ) mark => '--mark 0/' . in_hex( $globals{TC_MASK} )
); );
insert_irule( $mangle_table->{tcpost} ,
j => 'RETURN',
1 ,
mark => '! --mark 0/' . in_hex( $globals{TC_MASK} ) ,
);
add_ijump( $mangle_table->{tcpost} , add_ijump( $mangle_table->{tcpost} ,
j => 'CONNMARK --save-mark --ctmask ' . in_hex( $globals{TC_MASK} ), j => 'CONNMARK --save-mark --mask ' . in_hex( $globals{TC_MASK} ),
mark => '! --mark 0/' . in_hex( $globals{TC_MASK} ) mark => '! --mark 0/' . in_hex( $globals{TC_MASK} )
); );
} }
@@ -1604,7 +1767,7 @@ sub process_traffic_shaping() {
if ( $fn ) { if ( $fn ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
validate_tc_device while read_a_line; validate_tc_device while read_a_line( NORMAL_READ );
} }
$devnum = $devnum > 10 ? 10 : 1; $devnum = $devnum > 10 ? 10 : 1;
@@ -1614,7 +1777,7 @@ sub process_traffic_shaping() {
if ( $fn ) { if ( $fn ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
validate_tc_class while read_a_line; validate_tc_class while read_a_line( NORMAL_READ );
} }
process_tcfilters; process_tcfilters;
@@ -1654,11 +1817,22 @@ sub process_traffic_shaping() {
"${dev}_mtu1=\$(get_device_mtu1 $device)" "${dev}_mtu1=\$(get_device_mtu1 $device)"
); );
my $stab;
if ( $devref->{linklayer} ) {
$stab = "stab linklayer $devref->{linklayer} overhead $devref->{overhead} ";
$stab .= "mtu $devref->{mtu} " if $devref->{mtu};
$stab .= "mpu $devref->{mpu} " if $devref->{mpu};
$stab .= "tsize $devref->{tsize} " if $devref->{tsize};
} else {
$stab = '';
}
if ( $devref->{qdisc} eq 'htb' ) { if ( $devref->{qdisc} eq 'htb' ) {
emit ( "run_tc qdisc add dev $device root handle $devnum: htb default $defmark r2q $r2q" , emit ( "run_tc qdisc add dev $device ${stab}root handle $devnum: htb default $defmark r2q $r2q" ,
"run_tc class add dev $device parent $devnum: classid $devnum:1 htb rate $devref->{out_bandwidth} \$${dev}_mtu1" ); "run_tc class add dev $device parent $devnum: classid $devnum:1 htb rate $devref->{out_bandwidth} \$${dev}_mtu1" );
} else { } else {
emit ( "run_tc qdisc add dev $device root handle $devnum: hfsc default $defmark" , emit ( "run_tc qdisc add dev $device ${stab}root handle $devnum: hfsc default $defmark" ,
"run_tc class add dev $device parent $devnum: classid $devnum:1 hfsc sc rate $devref->{out_bandwidth} ul rate $devref->{out_bandwidth}" ); "run_tc class add dev $device parent $devnum: classid $devnum:1 hfsc sc rate $devref->{out_bandwidth} ul rate $devref->{out_bandwidth}" );
} }
@@ -1682,8 +1856,9 @@ sub process_traffic_shaping() {
handle_in_bandwidth( $device, $devref->{in_bandwidth} ); handle_in_bandwidth( $device, $devref->{in_bandwidth} );
for my $rdev ( @{$devref->{redirected}} ) { for my $rdev ( @{$devref->{redirected}} ) {
emit ( "run_tc qdisc add dev $rdev handle ffff: ingress" ); my $phyrdev = get_physical( $rdev );
emit( "run_tc filter add dev $rdev parent ffff: protocol all u32 match u32 0 0 action mirred egress redirect dev $device > /dev/null" ); emit ( "run_tc qdisc add dev $phyrdev handle ffff: ingress" );
emit( "run_tc filter add dev $phyrdev parent ffff: protocol all u32 match u32 0 0 action mirred egress redirect dev $device > /dev/null" );
} }
for my $class ( @tcclasses ) { for my $class ( @tcclasses ) {
@@ -1704,10 +1879,12 @@ sub process_traffic_shaping() {
my $mark = $tcref->{mark}; my $mark = $tcref->{mark};
my $devicenumber = in_hexp $devref->{number}; my $devicenumber = in_hexp $devref->{number};
my $classid = join( ':', $devicenumber, $classnum); my $classid = join( ':', $devicenumber, $classnum);
my $rate = "$tcref->{rate}kbit"; my $rawrate = $tcref->{rate};
my $rate = "${rawrate}kbit";
my $lsceil = $tcref->{lsceil};
my $quantum = calculate_quantum $rate, calculate_r2q( $devref->{out_bandwidth} ); my $quantum = calculate_quantum $rate, calculate_r2q( $devref->{out_bandwidth} );
$classids{$classid}=$device; $classids{$classid}=$devname;
my $priority = $tcref->{priority} << 8; my $priority = $tcref->{priority} << 8;
my $parent = in_hexp $tcref->{parent}; my $parent = in_hexp $tcref->{parent};
@@ -1718,16 +1895,42 @@ sub process_traffic_shaping() {
emit ( "run_tc class add dev $device parent $devicenumber:$parent classid $classid htb rate $rate ceil $tcref->{ceiling}kbit prio $tcref->{priority} \$${dev}_mtu1 quantum \$quantum" ); emit ( "run_tc class add dev $device parent $devicenumber:$parent classid $classid htb rate $rate ceil $tcref->{ceiling}kbit prio $tcref->{priority} \$${dev}_mtu1 quantum \$quantum" );
} else { } else {
my $dmax = $tcref->{dmax}; my $dmax = $tcref->{dmax};
my $rule = "run_tc class add dev $device parent $devicenumber:$parent classid $classid hfsc";
if ( $dmax ) { if ( $dmax ) {
my $umax = $tcref->{umax} ? "$tcref->{umax}b" : "\${${dev}_mtu}b"; my $umax = $tcref->{umax} ? "$tcref->{umax}b" : "\${${dev}_mtu}b";
emit ( "run_tc class add dev $device parent $devicenumber:$parent classid $classid hfsc sc umax $umax dmax ${dmax}ms rate $rate ul rate $tcref->{ceiling}kbit" ); $rule .= " sc umax $umax dmax ${dmax}ms";
$rule .= " rate $rate" if $rawrate;
} else { } else {
emit ( "run_tc class add dev $device parent $devicenumber:$parent classid $classid hfsc sc rate $rate ul rate $tcref->{ceiling}kbit" ); $rule .= " sc rate $rate" if $rawrate;
}
$rule .= " ls rate ${lsceil}kbit" if $lsceil;
$rule .= " ul rate $tcref->{ceiling}kbit" if $tcref->{ceiling};
emit $rule;
}
if ( $tcref->{leaf} ) {
if ( $tcref->{red} ) {
1 while $devnums[++$sfq];
$sfqinhex = in_hexp( $sfq);
my ( $options, $redopts ) = ( '', $tcref->{redopts} );
while ( my ( $option, $type ) = each %validredoptions ) {
if ( my $value = $redopts->{$option} ) {
if ( $type == RED_NONE ) {
$options = join( ' ', $options, $option ) if $value;
} else {
$options = join( ' ', $options, $option, $value );
}
} }
} }
if ( $tcref->{leaf} && ! $tcref->{pfifo} ) { emit( "run_tc qdisc add dev $device parent $classid handle $sfqinhex: red${options}" );
} elsif ( $tcref->{leaf} && ! $tcref->{pfifo} ) {
1 while $devnums[++$sfq]; 1 while $devnums[++$sfq];
$sfqinhex = in_hexp( $sfq); $sfqinhex = in_hexp( $sfq);
@@ -1737,6 +1940,7 @@ sub process_traffic_shaping() {
emit( "run_tc qdisc add dev $device parent $classid handle $sfqinhex: sfq limit $tcref->{limit} perturb 10" ); emit( "run_tc qdisc add dev $device parent $classid handle $sfqinhex: sfq limit $tcref->{limit} perturb 10" );
} }
} }
}
# #
# add filters # add filters
# #
@@ -1798,14 +2002,14 @@ sub process_traffic_shaping() {
my $devicenumber = in_hexp $devref->{number}; my $devicenumber = in_hexp $devref->{number};
my $classid = join( ':', $devicenumber, $classnum); my $classid = join( ':', $devicenumber, $classnum);
$classids{$classid}=$device; $classids{$classid}=$devname;
} }
} }
} }
} }
# #
# Validate the TC configuration storing basic information in %tcdevices and %tcdevices # Validate the TC configuration storing basic information in %tcdevices and %tcclasses (complex TC only)
# #
sub process_tc() { sub process_tc() {
if ( $config{TC_ENABLED} eq 'Internal' || $config{TC_ENABLED} eq 'Shared' ) { if ( $config{TC_ENABLED} eq 'Internal' || $config{TC_ENABLED} eq 'Shared' ) {
@@ -1953,10 +2157,10 @@ sub setup_tc() {
append_file $globals{TC_SCRIPT}; append_file $globals{TC_SCRIPT};
} else { } else {
process_tcpri if $config{TC_ENABLED} eq 'Simple'; process_tcpri if $config{TC_ENABLED} eq 'Simple';
setup_traffic_shaping unless $config{TC_ENABLED} eq 'Shared'; setup_traffic_shaping if @tcdevices && $config{TC_ENABLED} ne 'Shared';
} }
if ( $config{TC_ENABLED} ) { if ( $config{MANGLE_ENABLED} ) {
our @tccmd = ( { match => sub ( $ ) { $_[0] eq 'SAVE' } , our @tccmd = ( { match => sub ( $ ) { $_[0] eq 'SAVE' } ,
target => 'CONNMARK --save-mark --mask' , target => 'CONNMARK --save-mark --mask' ,
mark => $config{TC_EXPERT} ? HIGHMARK : SMALLMARK, mark => $config{TC_EXPERT} ? HIGHMARK : SMALLMARK,
@@ -2002,6 +2206,11 @@ sub setup_tc() {
mark => HIGHMARK, mark => HIGHMARK,
mask => '', mask => '',
connmark => '' }, connmark => '' },
{ match => sub( $ ) { $_[0] =~ /^DIVERT/ },
target => 'DIVERT',
mark => HIGHMARK,
mask => '',
connmark => '' },
{ match => sub( $ ) { $_[0] =~ /^TTL/ }, { match => sub( $ ) { $_[0] =~ /^TTL/ },
target => 'TTL', target => 'TTL',
mark => NOMARK, mark => NOMARK,
@@ -2036,20 +2245,21 @@ sub setup_tc() {
if ( my $fn = open_file 'tcrules' ) { if ( my $fn = open_file 'tcrules' ) {
our $format = 1;
first_entry "$doing $fn..."; first_entry "$doing $fn...";
process_tc_rule while read_a_line; process_tc_rule while read_a_line( NORMAL_READ );
clear_comment; clear_comment;
}
} }
if ( $config{MANGLE_ENABLED} ) {
if ( my $fn = open_file 'secmarks' ) { if ( my $fn = open_file 'secmarks' ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
process_secmark_rule while read_a_line; process_secmark_rule while read_a_line( NORMAL_READ );
clear_comment; clear_comment;
} }

View File

@@ -2,7 +2,6 @@
# Shorewall 4.4 -- /usr/share/shorewall/Shorewall/Tunnels.pm # Shorewall 4.4 -- /usr/share/shorewall/Shorewall/Tunnels.pm
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2010,2011 - Tom Eastep (teastep@shorewall.net) # (c) 2007,2008,2009,2010,2011 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
@@ -62,7 +61,7 @@ sub setup_tunnels() {
} }
} }
my @options = $globals{UNTRACKED} ? state_imatch 'NEW,UNTRACKED' : state_imatch 'NEW'; my @options = have_capability( 'RAW_TABLE' ) ? state_imatch 'NEW,UNTRACKED' : state_imatch 'NEW';
add_tunnel_rule $inchainref, p => 50, @$source; add_tunnel_rule $inchainref, p => 50, @$source;
add_tunnel_rule $outchainref, p => 50, @$dest; add_tunnel_rule $outchainref, p => 50, @$dest;
@@ -126,9 +125,9 @@ sub setup_tunnels() {
sub setup_pptp_server { sub setup_pptp_server {
my ($inchainref, $outchainref, $kind, $source, $dest ) = @_; my ($inchainref, $outchainref, $kind, $source, $dest ) = @_;
add_tunnel_rule $inchainref, p => 47, @$dest; add_tunnel_rule $inchainref, p => 47, @$source;
add_tunnel_rule $outchainref, p => 47, @$source; add_tunnel_rule $outchainref, p => 47, @$dest;
add_tunnel_rule $inchainref, p => 'tcp --dport 1723', @$dest add_tunnel_rule $inchainref, p => 'tcp --dport 1723', @$source
} }
sub setup_one_openvpn { sub setup_one_openvpn {
@@ -234,7 +233,7 @@ sub setup_tunnels() {
} }
sub setup_one_tunnel($$$$) { sub setup_one_tunnel($$$$) {
my ( $kind , $zone, $gateway, $gatewayzones ) = @_; my ( $kind , $zone, $gateways, $gatewayzones ) = @_;
my $zonetype = zone_type( $zone ); my $zonetype = zone_type( $zone );
@@ -243,8 +242,14 @@ sub setup_tunnels() {
my $inchainref = ensure_rules_chain( rules_chain( ${zone}, ${fw} ) ); my $inchainref = ensure_rules_chain( rules_chain( ${zone}, ${fw} ) );
my $outchainref = ensure_rules_chain( rules_chain( ${fw}, ${zone} ) ); my $outchainref = ensure_rules_chain( rules_chain( ${fw}, ${zone} ) );
$gateway = ALLIP if $gateway eq '-'; $gateways = ALLIP if $gateways eq '-';
my ( $net, $excl ) = handle_network_list( $gateways , 'src' );
( $net, $excl ) = handle_network_list( $gateways , 'dst' );
fatal_error "Exclusion is not allowed in the GATEWAYS column" if $excl;
for my $gateway ( split_list $gateways, 'GATEWAYS' ) {
my @source = imatch_source_net $gateway; my @source = imatch_source_net $gateway;
my @dest = imatch_dest_net $gateway; my @dest = imatch_dest_net $gateway;
@@ -272,6 +277,7 @@ sub setup_tunnels() {
fatal_error "Tunnels of type $type are not supported" unless $tunnelref; fatal_error "Tunnels of type $type are not supported" unless $tunnelref;
$tunnelref->{function}->( $inchainref, $outchainref, @{$tunnelref->{params}} ); $tunnelref->{function}->( $inchainref, $outchainref, @{$tunnelref->{params}} );
}
progress_message " Tunnel \"$currentline\" $done"; progress_message " Tunnel \"$currentline\" $done";
} }
@@ -283,16 +289,16 @@ sub setup_tunnels() {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
while ( read_a_line ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $kind, $zone, $gateway, $gatewayzones ) = split_line1 'tunnels file', { type => 0, zone => 1, gateway => 2, gateway_zone => 3 }; my ( $kind, $zone, $gateway, $gatewayzones ) = split_line1 'tunnels file', { type => 0, zone => 1, gateway => 2, gateways => 2, gateway_zone => 3 , gateway_zones => 3 }, undef, 4;
fatal_error 'TYPE must be specified' if $kind eq '-'; fatal_error 'TYPE must be specified' if $kind eq '-';
fatal_error 'ZONE must be specified' if $zone eq '-';
if ( $kind eq 'COMMENT' ) { if ( $kind eq 'COMMENT' ) {
process_comment; process_comment;
} else { } else {
fatal_error 'ZONE must be specified' if $zone eq '-';
setup_one_tunnel $kind, $zone, $gateway, $gatewayzones; setup_one_tunnel $kind, $zone, $gateway, $gatewayzones;
} }
} }

View File

@@ -41,6 +41,8 @@ our @EXPORT = qw( NOTHING
IP IP
BPORT BPORT
IPSEC IPSEC
NO_UPDOWN
NO_SFILTER
determine_zones determine_zones
zone_report zone_report
@@ -55,6 +57,7 @@ our @EXPORT = qw( NOTHING
all_parent_zones all_parent_zones
complex_zones complex_zones
vserver_zones vserver_zones
on_firewall_zones
off_firewall_zones off_firewall_zones
non_firewall_zones non_firewall_zones
single_interface single_interface
@@ -62,6 +65,7 @@ our @EXPORT = qw( NOTHING
validate_interfaces_file validate_interfaces_file
all_interfaces all_interfaces
all_real_interfaces all_real_interfaces
all_plain_interfaces
all_bridges all_bridges
interface_number interface_number
find_interface find_interface
@@ -72,6 +76,7 @@ our @EXPORT = qw( NOTHING
port_to_bridge port_to_bridge
source_port_to_bridge source_port_to_bridge
interface_is_optional interface_is_optional
interface_is_required
find_interfaces_by_option find_interfaces_by_option
find_interfaces_by_option1 find_interfaces_by_option1
get_interface_option get_interface_option
@@ -80,7 +85,6 @@ our @EXPORT = qw( NOTHING
set_interface_provider set_interface_provider
interface_zones interface_zones
verify_required_interfaces verify_required_interfaces
compile_updown
validate_hosts_file validate_hosts_file
find_hosts_by_option find_hosts_by_option
find_zone_hosts_by_option find_zone_hosts_by_option
@@ -114,7 +118,8 @@ use constant { IN_OUT => 1,
# #
# @zones contains the ordered list of zones with sub-zones appearing before their parents. # @zones contains the ordered list of zones with sub-zones appearing before their parents.
# #
# %zones{<zone1> => {type => <zone type> FIREWALL, IP, IPSEC, BPORT; # %zones{<zone1> => {name => <name>,
# type => <zone type> FIREWALL, IP, IPSEC, BPORT;
# complex => 0|1 # complex => 0|1
# super => 0|1 # super => 0|1
# options => { in_out => < policy match string > # options => { in_out => < policy match string >
@@ -173,6 +178,7 @@ my %reservedName = ( all => 1,
# number => <ordinal position in the interfaces file> # number => <ordinal position in the interfaces file>
# physical => <physical interface name> # physical => <physical interface name>
# base => <shell variable base representing this interface> # base => <shell variable base representing this interface>
# provider => <Provider Name, if interface is associated with a provider>
# zones => { zone1 => 1, ... } # zones => { zone1 => 1, ... }
# } # }
# } # }
@@ -219,11 +225,14 @@ use constant { SIMPLE_IF_OPTION => 1,
IF_OPTION_WILDOK => 64 IF_OPTION_WILDOK => 64
}; };
use constant { NO_UPDOWN => 1,
NO_SFILTER => 2 };
my %validinterfaceoptions; my %validinterfaceoptions;
my %defaultinterfaceoptions = ( routefilter => 1 , wait => 60 ); my %defaultinterfaceoptions = ( routefilter => 1 , wait => 60 );
my %maxoptionvalue = ( routefilter => 2, mss => 100000 , wait => 120 ); my %maxoptionvalue = ( routefilter => 2, mss => 100000 , wait => 120 , ignore => NO_UPDOWN );
my %validhostoptions; my %validhostoptions;
@@ -281,6 +290,7 @@ sub initialize( $$ ) {
bridge => SIMPLE_IF_OPTION, bridge => SIMPLE_IF_OPTION,
detectnets => OBSOLETE_IF_OPTION, detectnets => OBSOLETE_IF_OPTION,
dhcp => SIMPLE_IF_OPTION, dhcp => SIMPLE_IF_OPTION,
ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST, maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
logmartians => BINARY_IF_OPTION, logmartians => BINARY_IF_OPTION,
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER, nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER,
@@ -291,6 +301,7 @@ sub initialize( $$ ) {
required => SIMPLE_IF_OPTION, required => SIMPLE_IF_OPTION,
routeback => SIMPLE_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_HOST + IF_OPTION_VSERVER, routeback => SIMPLE_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_HOST + IF_OPTION_VSERVER,
routefilter => NUMERIC_IF_OPTION , routefilter => NUMERIC_IF_OPTION ,
rpfilter => SIMPLE_IF_OPTION,
sfilter => IPLIST_IF_OPTION, sfilter => IPLIST_IF_OPTION,
sourceroute => BINARY_IF_OPTION, sourceroute => BINARY_IF_OPTION,
tcpflags => SIMPLE_IF_OPTION + IF_OPTION_HOST, tcpflags => SIMPLE_IF_OPTION + IF_OPTION_HOST,
@@ -316,6 +327,7 @@ sub initialize( $$ ) {
%validinterfaceoptions = ( blacklist => SIMPLE_IF_OPTION + IF_OPTION_HOST, %validinterfaceoptions = ( blacklist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
bridge => SIMPLE_IF_OPTION, bridge => SIMPLE_IF_OPTION,
dhcp => SIMPLE_IF_OPTION, dhcp => SIMPLE_IF_OPTION,
ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST, maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER, nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER,
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST, nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
@@ -323,6 +335,7 @@ sub initialize( $$ ) {
proxyndp => BINARY_IF_OPTION, proxyndp => BINARY_IF_OPTION,
required => SIMPLE_IF_OPTION, required => SIMPLE_IF_OPTION,
routeback => SIMPLE_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_HOST + IF_OPTION_VSERVER, routeback => SIMPLE_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_HOST + IF_OPTION_VSERVER,
rpfilter => SIMPLE_IF_OPTION,
sfilter => IPLIST_IF_OPTION, sfilter => IPLIST_IF_OPTION,
sourceroute => BINARY_IF_OPTION, sourceroute => BINARY_IF_OPTION,
tcpflags => SIMPLE_IF_OPTION + IF_OPTION_HOST, tcpflags => SIMPLE_IF_OPTION + IF_OPTION_HOST,
@@ -483,7 +496,8 @@ sub process_zone( \$ ) {
my $complex = 0; my $complex = 0;
my $zoneref = $zones{$zone} = { type => $type, my $zoneref = $zones{$zone} = { name => $zone,
type => $type,
parents => \@parents, parents => \@parents,
bridge => '', bridge => '',
options => { in_out => parse_zone_option_list( $options , $type, $complex , IN_OUT ) , options => { in_out => parse_zone_option_list( $options , $type, $complex , IN_OUT ) ,
@@ -545,7 +559,7 @@ sub determine_zones()
if ( my $fn = open_file 'zones' ) { if ( my $fn = open_file 'zones' ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
push @z, process_zone( $ip ) while read_a_line; push @z, process_zone( $ip ) while read_a_line( NORMAL_READ );
} else { } else {
fatal_error q(The 'zones' file does not exist or has zero size); fatal_error q(The 'zones' file does not exist or has zero size);
} }
@@ -565,6 +579,7 @@ sub determine_zones()
for ( @{$zones{$zone}{children}} ) { for ( @{$zones{$zone}{children}} ) {
next ZONE unless $ordered{$_}; next ZONE unless $ordered{$_};
} }
$ordered{$zone} = 1; $ordered{$zone} = 1;
push @zones, $zone; push @zones, $zone;
redo PUSHED; redo PUSHED;
@@ -572,7 +587,7 @@ sub determine_zones()
} }
} }
assert( scalar @zones == scalar @z ); assert( @zones == @z );
} }
@@ -825,6 +840,10 @@ sub all_zones() {
@zones; @zones;
} }
sub on_firewall_zones() {
grep ( ( $zones{$_}{type} & ( FIREWALL | VSERVER ) ) , @zones );
}
sub off_firewall_zones() { sub off_firewall_zones() {
grep ( ! ( $zones{$_}{type} & ( FIREWALL | VSERVER ) ) , @zones ); grep ( ! ( $zones{$_}{type} & ( FIREWALL | VSERVER ) ) , @zones );
} }
@@ -934,7 +953,7 @@ sub process_interface( $$ ) {
return; return;
} }
fatal_error "Invalid FORMAT ($1)"; fatal_error "Invalid FORMAT ($originalinterface)";
} }
if ( $zone eq '-' ) { if ( $zone eq '-' ) {
@@ -1029,7 +1048,7 @@ sub process_interface( $$ ) {
if ( $options eq 'ignore' ) { if ( $options eq 'ignore' ) {
fatal_error "Ignored interfaces may not be associated with a zone" if $zone; fatal_error "Ignored interfaces may not be associated with a zone" if $zone;
$options{ignore} = 1; $options{ignore} = NO_UPDOWN | NO_SFILTER;
$options = '-'; $options = '-';
} }
@@ -1149,7 +1168,23 @@ sub process_interface( $$ ) {
} }
} }
fatal_error "Invalid combination of interface options" if $options{required} && $options{optional}; fatal_error q(The 'required', 'optional' and 'ignore' options are mutually exclusive)
if ( ( $options{required} && $options{optional} ) ||
( $options{required} && $options{ignore} ) ||
( $options{optional} && $options{ignore} ) );
if ( $options{rpfilter} ) {
require_capability( 'RPFILTER_MATCH', q(The 'rpfilter' option), 's' ) ;
fatal_error q(The 'routefilter', 'sfilter' and 'rpfilter' options are mutually exclusive) if $options{routefilter} || @$filterref;
} else {
fatal_error q(The 'routefilter', 'sfilter' and 'rpfilter' options are mutually exclusive) if $options{routefilter} && @$filterref;
}
if ( supplied( my $ignore = $options{ignore} ) ) {
fatal_error "Invalid value ignore=0" if ! $ignore;
} else {
$options{ignore} = 0;
}
if ( $netsref eq 'dynamic' ) { if ( $netsref eq 'dynamic' ) {
my $ipset = $family == F_IPV4 ? "${zone}_" . chain_base $physical : "6_${zone}_" . chain_base $physical; my $ipset = $family == F_IPV4 ? "${zone}_" . chain_base $physical : "6_${zone}_" . chain_base $physical;
@@ -1171,6 +1206,10 @@ sub process_interface( $$ ) {
# No options specified -- auto-detect bridge # No options specified -- auto-detect bridge
# #
$hostoptionsref->{routeback} = $options{routeback} = is_a_bridge( $physical ) unless $export; $hostoptionsref->{routeback} = $options{routeback} = is_a_bridge( $physical ) unless $export;
#
# And give the 'ignore' option a defined value
#
$options{ignore} ||= 0;
} }
$physical{$physical} = $interfaces{$interface} = { name => $interface , $physical{$physical} = $interfaces{$interface} = { name => $interface ,
@@ -1214,7 +1253,7 @@ sub validate_interfaces_file( $ ) {
if ( my $fn = open_file 'interfaces' ) { if ( my $fn = open_file 'interfaces' ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
push @ifaces, process_interface( $nextinum++, $export ) while read_a_line; push @ifaces, process_interface( $nextinum++, $export ) while read_a_line( NORMAL_READ );
} else { } else {
fatal_error q(The 'interfaces' file does not exist or has zero size); fatal_error q(The 'interfaces' file does not exist or has zero size);
} }
@@ -1416,11 +1455,65 @@ sub interface_is_optional($) {
$optionsref && $optionsref->{optional}; $optionsref && $optionsref->{optional};
} }
#
# Return the 'required' setting of the passed interface
#
sub interface_is_required($) {
my $optionsref = $interfaces{$_[0]}{options};
$optionsref && $optionsref->{required};
}
#
# Return true if the interface is 'plain'
#
sub interface_is_plain($) {
my $interfaceref = $interfaces{$_[0]};
my $optionsref = $interfaceref->{options};
$interfaceref->{bridge} eq $interfaceref->{name} && ! ( $optionsref && ( $optionsref->{required} || $optionsref->{optional} || $optionsref->{ignore} ) )
}
#
# Return a minimal list of physical interfaces that are neither ignored, optional, required nor a bridge port.
#
sub all_plain_interfaces() {
my @plain1 = map get_physical($_), grep $_ ne '%vserver%' && interface_is_plain( $_ ), @interfaces;
my @plain2;
my @wild1;
my @wild2;
for ( @plain1 ) {
if ( /\+$/ ) {
return ( '+' ) if $_ eq '+';
push @wild1, $_;
chop;
push @wild2, $_;
} else {
push @plain2, $_;
}
}
return @plain2 unless @wild1;
@plain1 = ();
NAME:
for my $name ( @plain2) {
for ( @wild2 ) {
next NAME if substr( $name, 0, length( $_ ) ) eq $_;
}
push @plain1, $name;
}
( @plain1, @wild1 );
}
# #
# Returns reference to array of interfaces with the passed option # Returns reference to array of interfaces with the passed option
# #
sub find_interfaces_by_option( $ ) { sub find_interfaces_by_option( $;$ ) {
my $option = $_[0]; my ( $option , $nonzero ) = @_;
my @ints = (); my @ints = ();
for my $interface ( @interfaces ) { for my $interface ( @interfaces ) {
@@ -1429,7 +1522,11 @@ sub find_interfaces_by_option( $ ) {
next unless $interfaceref->{root}; next unless $interfaceref->{root};
my $optionsref = $interfaceref->{options}; my $optionsref = $interfaceref->{options};
if ( $optionsref && defined $optionsref->{$option} ) { if ( $nonzero ) {
if ( $optionsref && $optionsref->{$option} ) {
push @ints , $interface
}
} elsif ( $optionsref && defined $optionsref->{$option} ) {
push @ints , $interface push @ints , $interface
} }
} }
@@ -1540,16 +1637,16 @@ sub verify_required_interfaces( $ ) {
my $physical = get_physical $interface; my $physical = get_physical $interface;
if ( $physical =~ /\+$/ ) { if ( $physical =~ /\+$/ ) {
my $base = uc chain_base $physical;
$physical =~ s/\+$/*/; $physical =~ s/\+$/*/;
emit( 'for interface in $(find_all_interfaces); do', emit( "waittime=$wait",
'',
'for interface in $(find_all_interfaces); do',
' case $interface in', ' case $interface in',
" $physical)", " $physical)",
" waittime=$wait",
' while [ $waittime -gt 0 ]; do', ' while [ $waittime -gt 0 ]; do',
' interface_is_usable $interface && break', ' interface_is_usable $interface && break',
' sleep 1',
' waittime=$(($waittime - 1))', ' waittime=$(($waittime - 1))',
' done', ' done',
' ;;', ' ;;',
@@ -1562,8 +1659,8 @@ sub verify_required_interfaces( $ ) {
emit qq( waittime=$wait); emit qq( waittime=$wait);
emit ''; emit '';
emit q( while [ $waittime -gt 0 ]; do); emit q( while [ $waittime -gt 0 ]; do);
emit qq( interface_is_usable $physical && break);
emit q( sleep 1); emit q( sleep 1);
emit qq( interface_is_usable $physical && break);
emit ' waittime=$(($waittime - 1))'; emit ' waittime=$(($waittime - 1))';
emit q( done); emit q( done);
emit q(fi); emit q(fi);
@@ -1634,181 +1731,12 @@ sub verify_required_interfaces( $ ) {
$returnvalue; $returnvalue;
} }
#
# Emit the updown() function
#
sub compile_updown() {
emit( '',
'#',
'# Handle the "up" and "down" commands',
'#',
'updown() # $1 = interface',
'{',
);
push_indent;
emit( 'local state',
'state=cleared',
'' );
emit 'progress_message3 "$g_product $COMMAND triggered by $1"';
emit '';
if ( $family == F_IPV4 ) {
emit 'if shorewall_is_started; then';
} else {
emit 'if shorewall6_is_started; then';
}
emit( ' state=started',
'elif [ -f ${VARDIR}/state ]; then',
' case "$(cat ${VARDIR}/state)" in',
' Stopped*)',
' state=stopped',
' ;;',
' Cleared*)',
' ;;',
' *)',
' state=unknown',
' ;;',
' esac',
'else',
' state=unknown',
'fi',
''
);
emit( 'case $1 in' );
push_indent;
my $ignore = find_interfaces_by_option 'ignore';
my $required = find_interfaces_by_option 'required';
my $optional = find_interfaces_by_option 'optional';
if ( @$ignore ) {
my $interfaces = join '|', map $interfaces{$_}->{physical}, @$ignore;
$interfaces =~ s/\+/*/g;
emit( "$interfaces)",
' progress_message3 "$COMMAND on interface $1 ignored"',
' exit 0',
' ;;'
);
}
if ( @$required ) {
my $interfaces = join '|', map $interfaces{$_}->{physical}, @$required;
my $wildcard = ( $interfaces =~ s/\+/*/g );
emit( "$interfaces)",
' if [ "$COMMAND" = up ]; then' );
if ( $wildcard ) {
emit( ' if [ "$state" = started ]; then',
' COMMAND=restart',
' else',
' COMMAND=start',
' fi' );
} else {
emit( ' COMMAND=start' );
}
emit( ' progress_message3 "$g_product attempting $COMMAND"',
' detect_configuration',
' define_firewall' );
if ( $wildcard ) {
emit( ' elif [ "$state" = started ]; then',
' progress_message3 "$g_product attempting restart"',
' COMMAND=restart',
' detect_configuration',
' define_firewall' );
} else {
emit( ' else',
' COMMAND=stop',
' progress_message3 "$g_product attempting stop"',
' detect_configuration',
' stop_firewall' );
}
emit( ' fi',
' ;;'
);
}
if ( @$optional ) {
my @interfaces = map $interfaces{$_}->{physical}, @$optional;
my $interfaces = join '|', @interfaces;
if ( $interfaces =~ s/\+/*/g || @interfaces > 1 ) {
emit( "$interfaces)",
' if [ "$COMMAND" = up ]; then',
' echo 0 > ${VARDIR}/${1}.state',
' else',
' echo 1 > ${VARDIR}/${1}.state',
' fi' );
} else {
emit( "$interfaces)",
' if [ "$COMMAND" = up ]; then',
" echo 0 > \${VARDIR}/$interfaces.state",
' else',
" echo 1 > \${VARDIR}/$interfaces.state",
' fi' );
}
emit( '',
' if [ "$state" = started ]; then',
' COMMAND=restart',
' progress_message3 "$g_product attempting restart"',
' detect_configuration',
' define_firewall',
' elif [ "$state" = stopped ]; then',
' COMMAND=start',
' progress_message3 "$g_product attempting start"',
' detect_configuration',
' define_firewall',
' else',
' progress_message3 "$COMMAND on interface $1 ignored"',
' fi',
' ;;',
);
}
emit( "*)",
' case $state in',
' started)',
' COMMAND=restart',
' progress_message3 "$g_product attempting restart"',
' detect_configuration',
' define_firewall',
' ;;',
' *)',
' progress_message3 "$COMMAND on interface $1 ignored"',
' ;;',
' esac',
);
pop_indent;
emit( 'esac' );
pop_indent;
emit( '}',
'',
);
}
# #
# Process a record in the hosts file # Process a record in the hosts file
# #
sub process_host( ) { sub process_host( ) {
my $ipsec = 0; my $ipsec = 0;
my ($zone, $hosts, $options ) = split_line 'hosts file', { zone => 0, hosts => 1, options => 2 }; my ($zone, $hosts, $options ) = split_line1 'hosts file', { zone => 0, host => 1, hosts => 1, options => 2 }, {}, 3;
fatal_error 'ZONE must be specified' if $zone eq '-'; fatal_error 'ZONE must be specified' if $zone eq '-';
fatal_error 'HOSTS must be specified' if $hosts eq '-'; fatal_error 'HOSTS must be specified' if $hosts eq '-';
@@ -1935,7 +1863,7 @@ sub validate_hosts_file()
if ( my $fn = open_file 'hosts' ) { if ( my $fn = open_file 'hosts' ) {
first_entry "$doing $fn..."; first_entry "$doing $fn...";
$ipsec |= process_host while read_a_line; $ipsec |= process_host while read_a_line( NORMAL_READ );
} }
$have_ipsec = $ipsec || haveipseczones; $have_ipsec = $ipsec || haveipseczones;

View File

@@ -37,6 +37,7 @@
# --log_verbosity=<number> # Log Verbosity range -1 to 2 # --log_verbosity=<number> # Log Verbosity range -1 to 2
# --family=<number> # IP family; 4 = IPv4 (default), 6 = IPv6 # --family=<number> # IP family; 4 = IPv4 (default), 6 = IPv6
# --preview # Preview the ruleset. # --preview # Preview the ruleset.
# --shorewallrc=<path> # Path to shorewallrc file.
# --config_path=<path-list> # Search path for config files # --config_path=<path-list> # Search path for config files
# #
use strict; use strict;
@@ -65,7 +66,7 @@ sub usage( $ ) {
[ --annotate ] [ --annotate ]
[ --update ] [ --update ]
[ --convert ] [ --convert ]
[ --shorewallrc ] [ --shorewallrc=<pathname> ]
[ --config_path=<path-list> ] [ --config_path=<path-list> ]
'; ';

View File

@@ -171,28 +171,6 @@ interface_is_up() {
[ -n "$($IP -$g_family link list dev $1 2> /dev/null | grep -e '[<,]UP[,>]')" ] [ -n "$($IP -$g_family link list dev $1 2> /dev/null | grep -e '[<,]UP[,>]')" ]
} }
#
# Determine if interface is usable from a Netfilter perspective
#
interface_is_usable() # $1 = interface
{
[ "$1" = lo ] && return 0
interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != :: ] && run_isusable_exit $1
}
#
# Find interface addresses--returns the set of addresses assigned to the passed
# device
#
find_interface_addresses() # $1 = interface
{
if [ $g_family -eq 4 ]; then
$IP -f inet addr show $1 2> /dev/null | grep inet\ | sed 's/\s*inet //;s/\/.*//;s/ peer.*//'
else
$IP -f inet6 addr show $1 2> /dev/null | grep 'inet6 2' | sed 's/\s*inet6 //;s/\/.*//;s/ peer.*//'
fi
}
# #
# echo the list of networks routed out of a given interface # echo the list of networks routed out of a given interface
# #
@@ -204,7 +182,6 @@ get_routed_networks() # $1 = interface name, $2-n = Fatal error message
[ $g_family -eq 4 ] && mask=32 || mask=128 [ $g_family -eq 4 ] && mask=32 || mask=128
$IP -$g_family route show dev $1 2> /dev/null | $IP -$g_family route show dev $1 2> /dev/null |
while read address rest; do while read address rest; do
case "$address" in case "$address" in
@@ -362,6 +339,16 @@ replace_default_route() # $1 = USE_DEFAULT_RT
fi fi
} }
#
# Delete default routes with metric 0 from the passed routing table
#
delete_default_routes() # $1 = table number
{
$IP -$g_family route ls table $1 | fgrep default | fgrep -v metric | while read route; do
qt $IP -$g_family route del $route
done
}
restore_default_route() # $1 = USE_DEFAULT_RT restore_default_route() # $1 = USE_DEFAULT_RT
{ {
local result local result
@@ -594,6 +581,7 @@ distribute_load() {
local interface local interface
local totalload local totalload
local load local load
local mark
local maxload local maxload
maxload=$1 maxload=$1
@@ -605,6 +593,8 @@ distribute_load() {
if interface_up $interface; then if interface_up $interface; then
load=$(cat ${VARDIR}/${interface}_load) load=$(cat ${VARDIR}/${interface}_load)
eval ${interface}_load=$load eval ${interface}_load=$load
mark=$(cat ${VARDIR}/${interface}_mark)
eval ${interface}_mark=$mark
totalload=$( bc <<EOF totalload=$( bc <<EOF
scale=8 scale=8
$totalload + $load $totalload + $load
@@ -617,6 +607,7 @@ EOF
for interface in $@; do for interface in $@; do
qt $g_tool -t mangle -F ~$interface qt $g_tool -t mangle -F ~$interface
eval load=\$${interface}_load eval load=\$${interface}_load
eval mark=\$${interface}_mark
if [ -n "$load" ]; then if [ -n "$load" ]; then
load=$(bc <<EOF load=$(bc <<EOF
@@ -629,7 +620,7 @@ scale=8
$totalload - $load $totalload - $load
EOF EOF
) )
run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $load run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $load -j MARK --set-mark $mark
fi fi
done done
fi fi
@@ -639,9 +630,37 @@ EOF
################################################################################# #################################################################################
# IPv4-specific Functions # IPv4-specific Functions
################################################################################# #################################################################################
#
# Determine if interface is usable from a Netfilter perspective
#
interface_is_usable() # $1 = interface
{
local status;
status=0
if [ "$1" != lo ]; then
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != 0.0.0.0 ]; then
[ "$COMMAND" = enable ] || run_isusable_exit $1
status=$?
else
status=1
fi
fi
return $status
}
#
# Find interface addresses--returns the set of addresses assigned to the passed device
#
find_interface_addresses() # $1 = interface
{
$IP -f inet addr show $1 2> /dev/null | grep inet\ | sed 's/\s*inet //;s/\/.*//;s/ peer.*//'
}
#
# Find the value 'weight' in the passed arguments then echo the next value # Find the value 'weight' in the passed arguments then echo the next value
# #
find_weight() { find_weight() {
while [ $# -gt 1 ]; do while [ $# -gt 1 ]; do
[ "x$1" = xweight ] && echo $2 && return [ "x$1" = xweight ] && echo $2 && return
@@ -897,7 +916,12 @@ add_gateway() # $1 = Delta $2 = Table Number
delta=$1 delta=$1
if ! echo $route | fgrep -q ' nexthop '; then if ! echo $route | fgrep -q ' nexthop '; then
if echo $route | fgrep -q via; then
route=`echo $route | sed 's/via/nexthop via/'` route=`echo $route | sed 's/via/nexthop via/'`
else
route="nexthop $route"
fi
dev=$(find_device $route) dev=$(find_device $route)
if [ -f ${VARDIR}/${dev}_weight ]; then if [ -f ${VARDIR}/${dev}_weight ]; then
weight=`cat ${VARDIR}/${dev}_weight` weight=`cat ${VARDIR}/${dev}_weight`
@@ -1012,6 +1036,34 @@ get_all_bcasts()
################################################################################# #################################################################################
# IPv6-specific Functions # IPv6-specific Functions
################################################################################# #################################################################################
#
# Determine if interface is usable from a Netfilter perspective
#
interface_is_usable() # $1 = interface
{
local status;
status=0
if [ "$1" != lo ]; then
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != :: ]; then
[ "$COMMAND" = enable ] || run_isusable_exit $1
status=$?
else
status=1
fi
fi
return $status
}
#
# Find interface addresses--returns the set of addresses assigned to the passed device
#
find_interface_addresses() # $1 = interface
{
$IP -f inet6 addr show $1 2> /dev/null | grep 'inet6 2' | sed 's/\s*inet6 //;s/\/.*//;s/ peer.*//'
}
# #
# Get all interface addresses with VLSMs # Get all interface addresses with VLSMs
# #

View File

@@ -1,11 +0,0 @@
#
# Shorewall version 4 - blacklist Macro
#
# /usr/share/shorewall/macro.blacklist
#
# This macro handles blacklisting using BLACKLIST_DISPOSITION and BLACKLIST_LOGLEVEL
#
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP
$BLACKLIST_DISPOSITION:$BLACKLIST_LOGLEVEL

View File

@@ -348,7 +348,9 @@ case "$COMMAND" in
[ $# -eq 1 ] && exit 0 [ $# -eq 1 ] && exit 0
shift shift
[ $# -ne 1 ] && usage 2 [ $# -ne 1 ] && usage 2
updown $1 mutex_on
( updown $1 )
mutex_off
status=0 status=0
;; ;;
enable) enable)

View File

@@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be author's reputation will not be affected by problems that might be
introduced by others. introduced by others.
Finally, software patents pose a constant threat to the existence of Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a effectively restrict the users of a free program by obtaining a
@@ -111,7 +111,7 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The "work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must former contains code derived from the library, whereas the latter must
be combined with the library in order to run. be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@@ -158,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy, You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a and you may at your option offer warranty protection in exchange for a
fee. fee.
2. You may modify your copy or copies of the Library or any portion 2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1 distribute such modifications or work under the terms of Section 1
@@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in that version instead if you wish.) Do not make any other change in
these notices. these notices.
Once this change is made in a given copy, it is irreversible for Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy. subsequent copies and derivative works made from that copy.
@@ -267,7 +267,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6. distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6, Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself. whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or 6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work work containing portions of the Library, and distribute that work
@@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you use both them and the Library together in an executable that you
distribute. distribute.
7. You may place library facilities that are a work based on the 7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined facilities not covered by this License, and distribute such a combined
@@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein. restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with You are not responsible for enforcing compliance by third parties with
this License. this License.
11. If, as a consequence of a court judgment or allegation of patent 11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or conditions are imposed on you (whether by court order, agreement or
@@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by license version number, you may choose any version ever published by
the Free Software Foundation. the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free 14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these, programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is write to the author to ask for permission. For software which is
@@ -456,7 +456,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES. DAMAGES.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest If you develop a new library, and you want it to be of the greatest

View File

@@ -7,6 +7,8 @@
# http://www.shorewall.net/manpages/shorewall-interfaces.html # http://www.shorewall.net/manpages/shorewall-interfaces.html
# #
############################################################################### ###############################################################################
#ZONE INTERFACE BROADCAST OPTIONS FORMAT 2
- lo - ignore ###############################################################################
net all - dhcp,physical=+,routeback,optional #ZONE INTERFACE OPTIONS
- lo ignore
net all dhcp,physical=+,routeback,optional

View File

@@ -6,13 +6,13 @@
# The manpage is also online at # The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-rules.html # http://www.shorewall.net/manpages/shorewall-rules.html
# #
################################################################################################################################################################################### ##############################################################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER
# PORT PORT(S) DEST LIMIT GROUP # PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL #SECTION ALL
#SECTION ESTABLISHED #SECTION ESTABLISHED
#SECTION RELATED #SECTION RELATED
SECTION NEW SECTION NEW
Invalid(DROP) net $FW tcp
SSH(ACCEPT) net $FW SSH(ACCEPT) net $FW
Ping(ACCEPT) net $FW Ping(ACCEPT) net $FW

View File

@@ -41,6 +41,8 @@ MACLIST_LOG_LEVEL=info
RELATED_LOG_LEVEL= RELATED_LOG_LEVEL=
RPFILTER_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info SFILTER_LOG_LEVEL=info
SMURF_LOG_LEVEL=info SMURF_LOG_LEVEL=info
@@ -55,14 +57,20 @@ TCP_FLAGS_LOG_LEVEL=info
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
GEOIPDIR=/usr/share/xt_geoip/LE
IPTABLES= IPTABLES=
IP= IP=
IPSET= IPSET=
LOCKFILE=
MODULESDIR= MODULESDIR=
NFACCT=
PERL=/usr/bin/perl PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
@@ -106,7 +114,9 @@ ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No AUTOMAKE=No
@@ -136,6 +146,8 @@ FASTACCEPT=Yes
FORWARD_CLEAR_MARK= FORWARD_CLEAR_MARK=
HELPERS=
IMPLICIT_CONTINUE=No IMPLICIT_CONTINUE=No
IPSET_WARNINGS=Yes IPSET_WARNINGS=Yes
@@ -166,7 +178,7 @@ MUTEX_TIMEOUT=60
NULL_ROUTE_RFC1918=No NULL_ROUTE_RFC1918=No
OPTIMIZE=15 OPTIMIZE=31
OPTIMIZE_ACCOUNTING=No OPTIMIZE_ACCOUNTING=No
@@ -204,6 +216,8 @@ MACLIST_DISPOSITION=REJECT
RELATED_DISPOSITION=ACCEPT RELATED_DISPOSITION=ACCEPT
RPFILTER_DISPOSITION=DROP
SMURF_DISPOSITION=DROP SMURF_DISPOSITION=DROP
SFILTER_DISPOSITION=DROP SFILTER_DISPOSITION=DROP

View File

@@ -11,5 +11,7 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-interfaces" # For information about entries in this file, type "man shorewall-interfaces"
############################################################################### ###############################################################################
#ZONE INTERFACE BROADCAST OPTIONS FORMAT 2
net eth0 detect dhcp,tcpflags,logmartians,nosmurfs ###############################################################################
#ZONE INTERFACE OPTIONS
net eth0 dhcp,tcpflags,logmartians,nosmurfs,sourceroute=0

View File

@@ -10,14 +10,18 @@
# See the file README.txt for further details. # See the file README.txt for further details.
#------------------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------------------
# For information on entries in this file, type "man shorewall-rules" # For information on entries in this file, type "man shorewall-rules"
###################################################################################################################################################################################### ##############################################################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER
# PORT PORT(S) DEST LIMIT GROUP # PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL #SECTION ALL
#SECTION ESTABLISHED #SECTION ESTABLISHED
#SECTION RELATED #SECTION RELATED
SECTION NEW SECTION NEW
# Drop packets in the INVALID state
Invalid(DROP) net $FW tcp
# Drop Ping from the "bad" net zone.. and prevent your log from being flooded.. # Drop Ping from the "bad" net zone.. and prevent your log from being flooded..
Ping(DROP) net $FW Ping(DROP) net $FW

View File

@@ -52,6 +52,8 @@ MACLIST_LOG_LEVEL=info
RELATED_LOG_LEVEL= RELATED_LOG_LEVEL=
RPFILTER_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info SFILTER_LOG_LEVEL=info
SMURF_LOG_LEVEL=info SMURF_LOG_LEVEL=info
@@ -66,14 +68,20 @@ TCP_FLAGS_LOG_LEVEL=info
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
GEOIPDIR=/usr/share/xt_geoip/LE
IPTABLES= IPTABLES=
IP= IP=
IPSET= IPSET=
LOCKFILE=
MODULESDIR= MODULESDIR=
NFACCT=
PERL=/usr/bin/perl PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
@@ -117,7 +125,9 @@ ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No AUTOMAKE=No
@@ -147,6 +157,8 @@ FASTACCEPT=No
FORWARD_CLEAR_MARK= FORWARD_CLEAR_MARK=
HELPERS=
IMPLICIT_CONTINUE=No IMPLICIT_CONTINUE=No
IPSET_WARNINGS=Yes IPSET_WARNINGS=Yes
@@ -177,7 +189,7 @@ MUTEX_TIMEOUT=60
NULL_ROUTE_RFC1918=No NULL_ROUTE_RFC1918=No
OPTIMIZE=1 OPTIMIZE=31
OPTIMIZE_ACCOUNTING=No OPTIMIZE_ACCOUNTING=No
@@ -215,6 +227,8 @@ MACLIST_DISPOSITION=REJECT
RELATED_DISPOSITION=ACCEPT RELATED_DISPOSITION=ACCEPT
RPFILTER_DISPOSITION=DROP
SMURF_DISPOSITION=DROP SMURF_DISPOSITION=DROP
SFILTER_DISPOSITION=DROP SFILTER_DISPOSITION=DROP

View File

@@ -11,7 +11,9 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-interfaces" # For information about entries in this file, type "man shorewall-interfaces"
############################################################################### ###############################################################################
#ZONE INTERFACE BROADCAST OPTIONS FORMAT 2
net eth0 detect tcpflags,dhcp,nosmurfs,routefilter,logmartians ###############################################################################
loc eth1 detect tcpflags,nosmurfs,routefilter,logmartians #ZONE INTERFACE OPTIONS
dmz eth2 detect tcpflags,nosmurfs,routefilter,logmartians net eth0 tcpflags,dhcp,nosmurfs,routefilter,logmartians,sourceroute=0
loc eth1 tcpflags,nosmurfs,routefilter,logmartians
dmz eth2 tcpflags,nosmurfs,routefilter,logmartians

View File

@@ -10,8 +10,9 @@
# See the file README.txt for further details. # See the file README.txt for further details.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-masq" # For information about entries in this file, type "man shorewall-masq"
############################################################################## ################################################################################################################
#INTERFACE SOURCE ADDRESS PROTO PORT(S) IPSEC MARK #INTERFACE:DEST SOURCE ADDRESS PROTO PORT(S) IPSEC MARK USER/ SWITCH ORIGINAL
# GROUP DEST
eth0 10.0.0.0/8,\ eth0 10.0.0.0/8,\
169.254.0.0/16,\ 169.254.0.0/16,\
172.16.0.0/12,\ 172.16.0.0/12,\

View File

@@ -10,8 +10,8 @@
# See the file README.txt for further details. # See the file README.txt for further details.
#------------------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-rules" # For information about entries in this file, type "man shorewall-rules"
###################################################################################################################################################################################### ##############################################################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER
# PORT PORT(S) DEST LIMIT GROUP # PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL #SECTION ALL
#SECTION ESTABLISHED #SECTION ESTABLISHED
@@ -20,7 +20,7 @@ SECTION NEW
# Don't allow connection pickup from the net # Don't allow connection pickup from the net
# #
Invalid(DROP) net all Invalid(DROP) net all tcp
# #
# Accept DNS connections from the firewall to the Internet # Accept DNS connections from the firewall to the Internet
# #

View File

@@ -50,6 +50,8 @@ MACLIST_LOG_LEVEL=info
RELATED_LOG_LEVEL= RELATED_LOG_LEVEL=
RPFILTER_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info SFILTER_LOG_LEVEL=info
SMURF_LOG_LEVEL=info SMURF_LOG_LEVEL=info
@@ -64,14 +66,20 @@ TCP_FLAGS_LOG_LEVEL=info
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
GEOIPDIR=/usr/share/xt_geoip/LE
IPTABLES= IPTABLES=
IP= IP=
IPSET= IPSET=
LOCKFILE=
MODULESDIR= MODULESDIR=
NFACCT=
PERL=/usr/bin/perl PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
@@ -115,7 +123,9 @@ ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No AUTOMAKE=No
@@ -145,6 +155,8 @@ FASTACCEPT=No
FORWARD_CLEAR_MARK= FORWARD_CLEAR_MARK=
HELPERS=
IMPLICIT_CONTINUE=No IMPLICIT_CONTINUE=No
IPSET_WARNINGS=Yes IPSET_WARNINGS=Yes
@@ -175,7 +187,7 @@ MUTEX_TIMEOUT=60
NULL_ROUTE_RFC1918=No NULL_ROUTE_RFC1918=No
OPTIMIZE=1 OPTIMIZE=31
OPTIMIZE_ACCOUNTING=No OPTIMIZE_ACCOUNTING=No
@@ -213,6 +225,8 @@ MACLIST_DISPOSITION=REJECT
RELATED_DISPOSITION=ACCEPT RELATED_DISPOSITION=ACCEPT
RPFILTER_DISPOSITION=DROP
SMURF_DISPOSITION=DROP SMURF_DISPOSITION=DROP
SFILTER_DISPOSITION=DROP SFILTER_DISPOSITION=DROP

View File

@@ -11,6 +11,8 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-interfaces" # For information about entries in this file, type "man shorewall-interfaces"
############################################################################### ###############################################################################
#ZONE INTERFACE BROADCAST OPTIONS FORMAT 2
net eth0 detect dhcp,tcpflags,nosmurfs,routefilter,logmartians ###############################################################################
loc eth1 detect tcpflags,nosmurfs,routefilter,logmartians #ZONE INTERFACE OPTIONS
net eth0 dhcp,tcpflags,nosmurfs,routefilter,logmartians,sourceroute=0
loc eth1 tcpflags,nosmurfs,routefilter,logmartians

View File

@@ -10,8 +10,9 @@
# See the file README.txt for further details. # See the file README.txt for further details.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-masq" # For information about entries in this file, type "man shorewall-masq"
############################################################################### ################################################################################################################
#INTERFACE SOURCE ADDRESS PROTO PORT(S) IPSEC MARK #INTERFACE:DEST SOURCE ADDRESS PROTO PORT(S) IPSEC MARK USER/ SWITCH ORIGINAL
# GROUP DEST
eth0 10.0.0.0/8,\ eth0 10.0.0.0/8,\
169.254.0.0/16,\ 169.254.0.0/16,\
172.16.0.0/12,\ 172.16.0.0/12,\

View File

@@ -10,8 +10,8 @@
# See the file README.txt for further details. # See the file README.txt for further details.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-rules" # For information about entries in this file, type "man shorewall-rules"
###################################################################################################################################################################################### ##############################################################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER
# PORT PORT(S) DEST LIMIT GROUP # PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL #SECTION ALL
#SECTION ESTABLISHED #SECTION ESTABLISHED
@@ -20,7 +20,7 @@ SECTION NEW
# Don't allow connection pickup from the net # Don't allow connection pickup from the net
# #
Invalid(DROP) net all Invalid(DROP) net all tcp
# #
# Accept DNS connections from the firewall to the network # Accept DNS connections from the firewall to the network
# #

View File

@@ -53,6 +53,8 @@ MACLIST_LOG_LEVEL=info
RELATED_LOG_LEVEL= RELATED_LOG_LEVEL=
RPFILTER_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info SFILTER_LOG_LEVEL=info
SMURF_LOG_LEVEL=info SMURF_LOG_LEVEL=info
@@ -67,14 +69,20 @@ TCP_FLAGS_LOG_LEVEL=info
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
GEOIPDIR=/usr/share/xt_geoip/LE
IPTABLES= IPTABLES=
IP= IP=
IPSET= IPSET=
LOCKFILE=
MODULESDIR= MODULESDIR=
NFACCT=
PERL=/usr/bin/perl PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
@@ -118,7 +126,9 @@ ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No AUTOMAKE=No
@@ -148,6 +158,8 @@ FASTACCEPT=No
FORWARD_CLEAR_MARK= FORWARD_CLEAR_MARK=
HELPERS=
IMPLICIT_CONTINUE=No IMPLICIT_CONTINUE=No
IPSET_WARNINGS=Yes IPSET_WARNINGS=Yes
@@ -178,7 +190,7 @@ MUTEX_TIMEOUT=60
NULL_ROUTE_RFC1918=No NULL_ROUTE_RFC1918=No
OPTIMIZE=1 OPTIMIZE=31
OPTIMIZE_ACCOUNTING=No OPTIMIZE_ACCOUNTING=No
@@ -216,6 +228,8 @@ MACLIST_DISPOSITION=REJECT
RELATED_DISPOSITION=ACCEPT RELATED_DISPOSITION=ACCEPT
RPFILTER_DISPOSITION=DROP
SMURF_DISPOSITION=DROP SMURF_DISPOSITION=DROP
SFILTER_DISPOSITION=DROP SFILTER_DISPOSITION=DROP

View File

@@ -31,7 +31,7 @@ FORMAT 2
DEFAULTS DROP,- DEFAULTS DROP,-
BEGIN PERL; ?BEGIN PERL;
use Shorewall::IPAddrs; use Shorewall::IPAddrs;
use Shorewall::Config; use Shorewall::Config;
@@ -70,4 +70,4 @@ add_jump $chainref, $target, 0, '-d 224.0.0.0/4 ';
1; 1;
END PERL; ?END PERL;

View File

@@ -36,7 +36,7 @@ FORMAT 2
# The following magic provides different defaults for $2 thru $5, when $1 is # The following magic provides different defaults for $2 thru $5, when $1 is
# 'audit'. # 'audit'.
# #
BEGIN PERL; ?BEGIN PERL;
use Shorewall::Config; use Shorewall::Config;
my ( $p1, $p2, $p3 , $p4, $p5 ) = get_action_params( 5 ); my ( $p1, $p2, $p3 , $p4, $p5 ) = get_action_params( 5 );
@@ -54,7 +54,7 @@ if ( defined $p1 ) {
1; 1;
END PERL; ?END PERL;
DEFAULTS -,REJECT,DROP,ACCEPT,DROP DEFAULTS -,REJECT,DROP,ACCEPT,DROP

View File

@@ -13,7 +13,7 @@ FORMAT 2
DEFAULTS - DEFAULTS -
BEGIN PERL; ?BEGIN PERL;
use strict; use strict;
use Shorewall::Config qw(:DEFAULT F_IPV4 F_IPV6); use Shorewall::Config qw(:DEFAULT F_IPV4 F_IPV6);
use Shorewall::Chains; use Shorewall::Chains;
@@ -77,7 +77,7 @@ if ( $family == F_IPV4 ) {
add_ijump( $chainref, g => $target, s => IPv6_MULTICAST ); add_ijump( $chainref, g => $target, s => IPv6_MULTICAST );
} }
END PERL; ?END PERL;

View File

@@ -31,7 +31,7 @@ FORMAT 2
DEFAULTS DROP,- DEFAULTS DROP,-
BEGIN PERL; ?BEGIN PERL;
use Shorewall::IPAddrs; use Shorewall::IPAddrs;
use Shorewall::Config; use Shorewall::Config;
@@ -53,4 +53,4 @@ allow_optimize( $chainref );
1; 1;
END PERL; ?END PERL;

View File

@@ -31,7 +31,7 @@ FORMAT 2
DEFAULTS DROP,- DEFAULTS DROP,-
BEGIN PERL; ?BEGIN PERL;
use Shorewall::IPAddrs; use Shorewall::IPAddrs;
use Shorewall::Config; use Shorewall::Config;
@@ -53,4 +53,4 @@ allow_optimize( $chainref );
1; 1;
END PERL; ?END PERL;

55
Shorewall/action.RST Normal file
View File

@@ -0,0 +1,55 @@
#
# Shorewall 4 - RST Action
#
# /usr/share/shorewall/action.RST
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2012 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# RST[([<action>|-[,{audit|-}])]
#
# Default action is DROP
#
##########################################################################################
FORMAT 2
DEFAULTS DROP,-
?BEGIN PERL;
use Shorewall::Config;
use Shorewall::Chains;
my ( $action, $audit ) = get_action_params( 2 );
fatal_error "Invalid parameter ($audit) to action NotSyn" if supplied $audit && $audit ne 'audit';
fatal_error "Invalid parameter ($action) to action NotSyn" unless $action =~ /^(?:ACCEPT|DROP)$/;
my $chainref = get_action_chain;
my ( $level, $tag ) = get_action_logging;
my $target = require_audit ( $action , $audit );
log_rule_limit $level, $chainref, 'RST' , $action, '', $tag, 'add', '-p 6 --tcp-flags RST RST ' if $level ne '';
add_jump $chainref , $target, 0, '-p 6 --tcp-flags RST RST, ';
allow_optimize( $chainref );
1;
?END PERL;

View File

@@ -32,7 +32,7 @@ FORMAT 2
# The following magic provides different defaults for $2 thru $5, when $1 is # The following magic provides different defaults for $2 thru $5, when $1 is
# 'audit'. # 'audit'.
# #
BEGIN PERL; ?BEGIN PERL;
use Shorewall::Config; use Shorewall::Config;
my ( $p1, $p2, $p3 , $p4, $p5 ) = get_action_params( 5 ); my ( $p1, $p2, $p3 , $p4, $p5 ) = get_action_params( 5 );
@@ -50,7 +50,7 @@ if ( defined $p1 ) {
1; 1;
END PERL; ?END PERL;
DEFAULTS -,REJECT,REJECT,ACCEPT,DROP DEFAULTS -,REJECT,REJECT,ACCEPT,DROP

View File

@@ -13,12 +13,11 @@ FORMAT 2
DEFAULTS DROP,- DEFAULTS DROP,-
BEGIN PERL; ?BEGIN PERL;
use strict; use strict;
use Shorewall::Config qw(:DEFAULT F_IPV4 F_IPV6); use Shorewall::Config qw(:DEFAULT F_IPV4 F_IPV6);
use Shorewall::Chains; use Shorewall::Chains;
my ( $disposition, $audit ) = get_action_params( 2 ); my ( $disposition, $audit ) = get_action_params( 2 );
my $chainref = get_action_chain; my $chainref = get_action_chain;
@@ -55,7 +54,7 @@ add_ijump $chainref , g => $disposition, p => 'tcp --tcp-flags SYN,RST SYN,RST';
add_ijump $chainref , g => $disposition, p => 'tcp --tcp-flags SYN,FIN SYN,FIN'; add_ijump $chainref , g => $disposition, p => 'tcp --tcp-flags SYN,FIN SYN,FIN';
add_ijump $chainref , g => $disposition, p => 'tcp --syn --sport 0'; add_ijump $chainref , g => $disposition, p => 'tcp --syn --sport 0';
END PERL; ?END PERL;

View File

@@ -41,4 +41,5 @@ DropSmurfs # Drop smurf packets
Invalid # Handles packets in the INVALID conntrack state Invalid # Handles packets in the INVALID conntrack state
NotSyn # Handles TCP packets which do not have SYN=1 and ACK=0 NotSyn # Handles TCP packets which do not have SYN=1 and ACK=0
Reject # Default Action for REJECT policy Reject # Default Action for REJECT policy
RST # Handle packets with RST set
TCPFlags # Handle bad flag combinations. TCPFlags # Handle bad flag combinations.

View File

@@ -1,11 +0,0 @@
#
# Shorewall version 4 - Blacklist File
#
# For information about entries in this file, type "man shorewall-blacklist"
#
# Please see http://shorewall.net/blacklisting_support.htm for additional
# information.
#
###############################################################################
#ADDRESS/SUBNET PROTOCOL PORT OPTIONS

View File

@@ -0,0 +1,53 @@
#
# Shorewall version 4 - conntrack File
#
# For information about entries in this file, type "man shorewall-conntrack"
#
#############################################################################################
FORMAT 2
#ACTION SOURCE DESTINATION PROTO DEST SOURCE USER/
# PORT(S) PORT(S) GROUP
?if $AUTOHELPERS && __CT_TARGET
?if __AMANDA_HELPER
CT:helper:amanda all - udp 10080
?endif
?if __FTP_HELPER
CT:helper:ftp all - tcp 21
?endif
?if __H323_HELPER
CT:helper:RAS all - udp 1719
CT:helper:Q.931 all - tcp 1720
?endif
?if __IRC_HELPER
CT:helper:irc all - tcp 6667
?endif
?if __NETBIOS_NS_HELPER
CT:helper:netbios-ns all - udp 137
?endif
?if __PPTP_HELPER
CT:helper:pptp all - tcp 1729
?endif
?if __SANE_HELPER
CT:helper:sane all - tcp 6566
?endif
?if __SIP_HELPER
CT:helper:sip all - udp 5060
?endif
?if __SNMP_HELPER
CT:helper:snmp all - udp 161
?endif
?if __TFTP_HELPER
CT:helper:tftp all - udp 69
?endif
?endif

View File

@@ -7,8 +7,6 @@
# http://www.shorewall.net/manpages/shorewall-interfaces.html # http://www.shorewall.net/manpages/shorewall-interfaces.html
# #
############################################################################### ###############################################################################
FORMAT 1
#ZONE INTERFACE BROADCAST OPTIONS
FORMAT 2 FORMAT 2
###############################################################################
#ZONE INTERFACE OPTIONS #ZONE INTERFACE OPTIONS

View File

@@ -6,6 +6,6 @@
# The manpage is also online at # The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-masq.html # http://www.shorewall.net/manpages/shorewall-masq.html
# #
###################################################################################################### ################################################################################################################
#INTERFACE:DEST SOURCE ADDRESS PROTO PORT(S) IPSEC MARK USER/ SWITCH #INTERFACE:DEST SOURCE ADDRESS PROTO PORT(S) IPSEC MARK USER/ SWITCH ORIGINAL
# GROUP # GROUP DEST

View File

@@ -1,9 +0,0 @@
#
# Shorewall version 4 - Notrack File
#
# For information about entries in this file, type "man shorewall-notrack"
#
#####################################################################################
FORMAT 2
#ACTION SOURCE DESTINATION PROTO DEST SOURCE USER/
# PORT(S) PORT(S) GROUP

View File

@@ -6,8 +6,8 @@
# The manpage is also online at # The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-rules.html # http://www.shorewall.net/manpages/shorewall-rules.html
# #
###################################################################################################################################################################################### #################################################################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER
# PORT PORT(S) DEST LIMIT GROUP # PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL #SECTION ALL
#SECTION ESTABLISHED #SECTION ESTABLISHED

View File

@@ -41,6 +41,8 @@ MACLIST_LOG_LEVEL=info
RELATED_LOG_LEVEL= RELATED_LOG_LEVEL=
RPFILTER_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info SFILTER_LOG_LEVEL=info
SMURF_LOG_LEVEL=info SMURF_LOG_LEVEL=info
@@ -55,14 +57,20 @@ TCP_FLAGS_LOG_LEVEL=info
CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall" CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
GEOIPDIR=/usr/share/xt_geoip/LE
IPTABLES= IPTABLES=
IP= IP=
IPSET= IPSET=
LOCKFILE=
MODULESDIR= MODULESDIR=
NFACCT=
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin" PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin"
PERL=/usr/bin/perl PERL=/usr/bin/perl
@@ -106,7 +114,9 @@ ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No AUTOMAKE=No
@@ -136,6 +146,8 @@ FASTACCEPT=No
FORWARD_CLEAR_MARK= FORWARD_CLEAR_MARK=
HELPERS=
IMPLICIT_CONTINUE=No IMPLICIT_CONTINUE=No
IPSET_WARNINGS=Yes IPSET_WARNINGS=Yes
@@ -204,6 +216,8 @@ MACLIST_DISPOSITION=REJECT
RELATED_DISPOSITION=ACCEPT RELATED_DISPOSITION=ACCEPT
RPFILTER_DISPOSITION=DROP
SMURF_DISPOSITION=DROP SMURF_DISPOSITION=DROP
SFILTER_DISPOSITION=DROP SFILTER_DISPOSITION=DROP

View File

@@ -10,6 +10,8 @@
# See http://shorewall.net/PacketMarking.html for a detailed description of # See http://shorewall.net/PacketMarking.html for a detailed description of
# the Netfilter/Shorewall packet marking mechanism. # the Netfilter/Shorewall packet marking mechanism.
########################################################################################################################################## ##########################################################################################################################################
FORMAT 2
##########################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP #ACTION SOURCE DEST PROTO DEST SOURCE USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP
# PORT(S) PORT(S) # PORT(S) PORT(S)

View File

@@ -7,5 +7,5 @@
# http://www.shorewall.net/manpages/shorewall-tunnels.html # http://www.shorewall.net/manpages/shorewall-tunnels.html
# #
############################################################################### ###############################################################################
#TYPE ZONE GATEWAY GATEWAY #TYPE ZONE GATEWAY(S) GATEWAY
# ZONE # ZONE(S)

View File

@@ -22,7 +22,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
VERSION=xxx #The Build script inserts the actual version VERSION=4.5.5 #The Build script inserts the actual version
# #
# Change to the directory containing this script # Change to the directory containing this script
@@ -244,27 +244,6 @@ esac
OWNERSHIP="-o $OWNER -g $GROUP" OWNERSHIP="-o $OWNER -g $GROUP"
#
# Determine where to install the firewall script
#
if [ $PRODUCT = shorewall -a "$BUILD" = "$HOST" ]; then
#
# Fix up 'use Digest::' if SHA is installed
#
if perl -e 'use Digest::SHA;' 2> /dev/null ; then
sed -i 's/Digest::SHA1/Digest::SHA/' Perl/Shorewall/Chains.pm
fi
#
# Verify that Perl is installed
#
if ! perl -c Perl/compiler.pl; then
echo "ERROR: $Product $VERSION requires Perl which either is not installed or is not able to compile the Shorewall Perl code" >&2
echo " Try perl -c $PWD/Perl/compiler.pl" >&2
exit 1
fi
fi
case "$HOST" in case "$HOST" in
cygwin) cygwin)
echo "Installing Cygwin-specific configuration..." echo "Installing Cygwin-specific configuration..."
@@ -295,6 +274,51 @@ case "$HOST" in
;; ;;
esac esac
if [ $PRODUCT = shorewall ]; then
if [ -n "$DIGEST" ]; then
#
# The user specified which digest to use
#
if [ "$DIGEST" != SHA ]; then
if [ "$BUILD" = "$HOST" ] && ! eval perl -e \'use Digest::$DIGEST\;\' 2> /dev/null ; then
echo "ERROR: Perl compilation with Digest::$DIGEST failed" >&2
exit 1;
fi
eval sed -i \'s/Digest::SHA/Digest::$DIGEST/\' Perl/Shorewall/Chains.pm
fi
elif [ "$BUILD" = "$HOST" ]; then
#
# Fix up 'use Digest::' if SHA1 is installed
#
DIGEST=SHA
if ! perl -e 'use Digest::SHA;' 2> /dev/null ; then
if perl -e 'use Digest::SHA1;' 2> /dev/null ; then
sed -i 's/Digest::SHA/Digest::SHA1/' Perl/Shorewall/Chains.pm
DIGEST=SHA1
else
echo "ERROR: Shorewall $VERSION requires either Digest::SHA or Digest::SHA1" >&2
exit 1
fi
fi
fi
if [ "$BUILD" = "$HOST" ]; then
#
# Verify that Perl and all required modules are installed
#
echo "Compiling the Shorewall Perl Modules with Digest::$DIGEST"
if ! perl -c Perl/compiler.pl; then
echo "ERROR: $Product $VERSION requires Perl which either is not installed or is not able to compile the Shorewall Perl code" >&2
echo " Try perl -c $PWD/Perl/compiler.pl" >&2
exit 1
fi
else
echo "Using Digest::$DIGEST"
fi
fi
if [ $BUILD != cygwin ]; then if [ $BUILD != cygwin ]; then
if [ `id -u` != 0 ] ; then if [ `id -u` != 0 ] ; then
echo "Not setting file owner/group permissions, not running as root." echo "Not setting file owner/group permissions, not running as root."
@@ -333,18 +357,11 @@ echo "$PRODUCT control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
# Install the Firewall Script # Install the Firewall Script
# #
if [ -n "$INITFILE" ]; then if [ -n "$INITFILE" ]; then
if [ -f "$INITSOURCE" ]; then if [ -f "${INITSOURCE}" ]; then
install_file $INITSOURCE ${DESTDIR}${INITDIR}/$INITFILE 0544 install_file $INITSOURCE ${DESTDIR}${INITDIR}/$INITFILE 0544
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${INITDIR}/$INITFILE [ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${INITDIR}/$INITFILE
echo "$Product script installed in ${DESTDIR}${INITDIR}/$INITFILE" echo "$Product script installed in ${DESTDIR}${INITDIR}/$INITFILE"
fi fi
if [ -n "$AUXINITSOURCE" -a -f "$AUXINITSOURCE" ]; then
install_file $AUXINITSOURCE ${DESTDIR}${INITDIR}/$AUXINITFILE 0544
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${INITDIR}/$AUXINITFILE
echo "$Product script installed in ${DESTDIR}${INITDIR}/$AUXINITFILE"
fi
fi fi
# #
@@ -354,7 +371,7 @@ mkdir -p ${DESTDIR}/${CONFDIR}/$PRODUCT
mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT
mkdir -p ${DESTDIR}${PERLLIBDIR}/Shorewall mkdir -p ${DESTDIR}${PERLLIBDIR}/Shorewall
mkdir -p ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles mkdir -p ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles
mkdir -p ${DESTDIR}/var/lib/$PRODUCT mkdir -p ${DESTDIR}${VARDIR}/$PRODUCT
chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT
chmod 755 ${DESTDIR}${SHAREDIR}/$PRODUCT chmod 755 ${DESTDIR}${SHAREDIR}/$PRODUCT
@@ -617,14 +634,14 @@ if [ -f masq ]; then
fi fi
fi fi
# #
# Install the Notrack file # Install the Conntrack file
# #
run_install $OWNERSHIP -m 0644 notrack ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles run_install $OWNERSHIP -m 0644 conntrack ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles
run_install $OWNERSHIP -m 0644 notrack.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles run_install $OWNERSHIP -m 0644 conntrack.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles
if [ -z "$SPARSE" -a ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/notrack ]; then if [ ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/conntrack ]; then
run_install $OWNERSHIP -m 0600 notrack${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/notrack run_install $OWNERSHIP -m 0600 conntrack${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/conntrack
echo "Notrack file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/notrack" echo "Conntrack file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/conntrack"
fi fi
# #
@@ -681,10 +698,6 @@ if [ -z "$SPARSE" -a ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/tunnels ]; then
echo "Tunnels file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/tunnels" echo "Tunnels file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/tunnels"
fi fi
if [ -z "$SPARSE" -a ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/blacklist ]; then
run_install $OWNERSHIP -m 0600 blacklist${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/blacklist
echo "Blacklist file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/blacklist"
fi
# #
# Install the blacklist rules file # Install the blacklist rules file
# #
@@ -957,12 +970,6 @@ fi
cd .. cd ..
#
# Install the Standard Actions file
#
install_file actions.std ${DESTDIR}${SHAREDIR}/$PRODUCT/actions.std 0644
echo "Standard actions file installed as ${DESTDIR}${SHAREDIR}d/$PRODUCT/actions.std"
# #
# Install the Makefiles # Install the Makefiles
# #
@@ -992,9 +999,9 @@ cd ..
# #
# Install the libraries # Install the libraries
# #
for f in lib.* ; do for f in lib.* Perl/lib.*; do
if [ -f $f ]; then if [ -f $f ]; then
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644 install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$(basename $f) 0644
echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f" echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
fi fi
done done
@@ -1114,7 +1121,7 @@ if [ -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
perl -p -w -i -e 's/^STARTUP_ENABLED=No/STARTUP_ENABLED=Yes/;s/^IP_FORWARDING=On/IP_FORWARDING=Keep/;s/^SUBSYSLOCK=.*/SUBSYSLOCK=/;' ${CONFDIR}/$PRODUCT/$PRODUCT.conf perl -p -w -i -e 's/^STARTUP_ENABLED=No/STARTUP_ENABLED=Yes/;s/^IP_FORWARDING=On/IP_FORWARDING=Keep/;s/^SUBSYSLOCK=.*/SUBSYSLOCK=/;' ${CONFDIR}/$PRODUCT/$PRODUCT.conf
update-rc.d $PRODUCT enable update-rc.d $PRODUCT enable
elif [ -n "$SYSTEMD" ]; then elif [ -n "$SYSTEMD" ]; then
if systemctl enable $PRODUCT; then if systemctl enable ${PRODUCT}.service; then
echo "$Product will start automatically at boot" echo "$Product will start automatically at boot"
fi fi
elif mywhich insserv; then elif mywhich insserv; then

View File

@@ -181,7 +181,7 @@ get_config() {
if [ "$2" = Yes ]; then if [ "$2" = Yes ]; then
case $STARTUP_ENABLED in case $STARTUP_ENABLED in
No|no|NO) No|no|NO)
echo " ERROR: $g_product startup is disabled. To enable startup, set STARTUP_ENABLED=Yes in ${CONFDIR}/${g_program}.conf" >&2 echo " ERROR: $g_product startup is disabled. To enable startup, set STARTUP_ENABLED=Yes in ${g_confdir}/${g_program}.conf" >&2
exit 2 exit 2
;; ;;
Yes|yes|YES) Yes|yes|YES)
@@ -508,6 +508,10 @@ start_command() {
AUTOMAKE= AUTOMAKE=
option=${option#c} option=${option#c}
;; ;;
T*)
g_confess=Yes
option=${option#T}
;;
*) *)
usage 1 usage 1
;; ;;
@@ -880,6 +884,10 @@ restart_command() {
g_purge=Yes g_purge=Yes
option=${option%p} option=${option%p}
;; ;;
T*)
g_confess=Yes
option=${option#T}
;;
*) *)
usage 1 usage 1
;; ;;
@@ -964,6 +972,27 @@ refresh_command() {
finished=1 finished=1
option= option=
;; ;;
d*)
g_debug=Yes
option=${option#d}
;;
n*)
g_noroutes=Yes
option=${option#n}
;;
T*)
g_confess=Yes
option=${option#T}
;;
D)
if [ $# -gt 1 ]; then
g_shorewalldir="$2"
option=
shift
else
fatal_error "ERROR: the -D option requires a directory name"
fi
;;
*) *)
usage 1 usage 1
;; ;;
@@ -1341,6 +1370,10 @@ reload_command() # $* = original arguments less the command.
option= option=
shift shift
;; ;;
T*)
g_confess=Yes
option=${option#T}
;;
*) *)
usage 1 usage 1
;; ;;
@@ -1538,7 +1571,7 @@ usage() # $1 = exit status
echo " allow <address> ..." echo " allow <address> ..."
echo " check [ -e ] [ -r ] [ -p ] [ -r ] [ -T ] [ <directory> ]" echo " check [ -e ] [ -r ] [ -p ] [ -r ] [ -T ] [ <directory> ]"
echo " clear" echo " clear"
echo " compile [ -e ] [ -d ] [ <directory name> ] [ <path name> ]" echo " compile [ -e ] [ -p ] [ -t ] [ -d ] [ -T ] [ <directory name> ] [ <path name> ]"
echo " delete <interface>[:<host-list>] ... <zone>" echo " delete <interface>[:<host-list>] ... <zone>"
echo " disable <interface>" echo " disable <interface>"
echo " drop <address> ..." echo " drop <address> ..."
@@ -1556,7 +1589,7 @@ usage() # $1 = exit status
fi fi
echo " iptrace <iptables match expression>" echo " iptrace <iptables match expression>"
echo " load [ -s ] [ -c ] [ -r <root user> ] [ <directory> ] <system>" echo " load [ -s ] [ -c ] [ -r <root user> ] [ -T ] [ <directory> ] <system>"
echo " logdrop <address> ..." echo " logdrop <address> ..."
echo " logreject <address> ..." echo " logreject <address> ..."
echo " logwatch [<refresh interval>]" echo " logwatch [<refresh interval>]"
@@ -1567,11 +1600,11 @@ usage() # $1 = exit status
echo " noiptrace <ip6tables match expression>" echo " noiptrace <ip6tables match expression>"
fi fi
echo " refresh [ <chain>... ]" echo " refresh [ -d ] [ -n ] [ -T ] [ -D <directory> ] [ <chain>... ]"
echo " reject <address> ..." echo " reject <address> ..."
echo " reload [ -s ] [ -c ] [ -r <root user> ] [ <directory> ] <system>" echo " reload [ -s ] [ -c ] [ -r <root user> ] [ -T ] [ <directory> ] <system>"
echo " reset [ <chain> ... ]" echo " reset [ <chain> ... ]"
echo " restart [ -n ] [ -p ] [-d] [ -f ] [ -c ][ <directory> ]" echo " restart [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ <directory> ]"
echo " restore [ -n ] [ <file name> ]" echo " restore [ -n ] [ <file name> ]"
echo " safe-restart [ -t <timeout> ] [ <directory> ]" echo " safe-restart [ -t <timeout> ] [ <directory> ]"
echo " safe-start [ -t <timeout> ] [ <directory> ]" echo " safe-start [ -t <timeout> ] [ <directory> ]"
@@ -1595,11 +1628,13 @@ usage() # $1 = exit status
echo " show macros" echo " show macros"
echo " show marks" echo " show marks"
echo " show [ -x ] mangle|nat|raw|rawpost|routing" echo " show [ -x ] mangle|nat|raw|rawpost|routing"
echo " show nfacct"
echo " show policies" echo " show policies"
echo " show routing"
echo " show tc [ device ]" echo " show tc [ device ]"
echo " show vardir" echo " show vardir"
echo " show zones" echo " show zones"
echo " start [ -f ] [ -n ] [ -p ] [ -c ] [ <directory> ]" echo " start [ -f ] [ -n ] [ -p ] [ -c ] [ -T ] [ <directory> ]"
echo " status" echo " status"
echo " stop" echo " stop"
echo " try <directory> [ <timeout> ]" echo " try <directory> [ <timeout> ]"

View File

@@ -294,8 +294,25 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>NFLOG[(nflog-parameters)] - Added in <term><emphasis
Shorewall-4.4.20.</term> role="bold">NFACCT</emphasis>(<replaceable>object</replaceable>)</term>
<listitem>
<para>Added in Shorewall 4.5.7. Provides a form of accounting
that survives <command>shorewall stop/shorewall</command>
start and <command>shorewall restart</command>. Requires the
NFaccnt Match capability in your kernel and iptables.
<replaceable>object</replaceable> names an nfacct object (see
man nfaccnt(8)). Multiple rules can specify the same
<replaceable>object</replaceable>; all packets that match any
of the rules increment the packet and bytes count of the
object.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">NFLOG</emphasis>[(nflog-parameters)]
- Added in Shorewall-4.4.20.</term>
<listitem> <listitem>
<para>Causes each matching packet to be sent via the currently <para>Causes each matching packet to be sent via the currently
@@ -306,7 +323,7 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>COMMENT</term> <term><emphasis role="bold">COMMENT</emphasis></term>
<listitem> <listitem>
<para>The remainder of the line is treated as a comment which <para>The remainder of the line is treated as a comment which
@@ -539,7 +556,8 @@
<varlistentry> <varlistentry>
<term><emphasis role="bold">IPSEC - <emphasis>option-list</emphasis> <term><emphasis role="bold">IPSEC - <emphasis>option-list</emphasis>
(Optional - Added in Shorewall 4.4.13 )</emphasis></term> (Optional - Added in Shorewall 4.4.13 but broken until 4.5.4.1
)</emphasis></term>
<listitem> <listitem>
<para>The option-list consists of a comma-separated list of options <para>The option-list consists of a comma-separated list of options
@@ -653,29 +671,52 @@
match the rule.</para> match the rule.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis role="bold">in</emphasis></term>
<listitem>
<para>May only be used in the FORWARD section and must be the
first or the only item the list. Indicates that matching
packets have been decrypted in input.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">out</emphasis></term>
<listitem>
<para>May only be used in the FORWARD section and must be the
first or the only item in the list. Indicates that matching
packets will be encrypted on output.</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
<para>If this column is non-empty, then:</para> <para>If this column is non-empty and sections are not used,
then:</para>
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para>A chain NAME may appearing in the ACTION column must be a <para>A chain NAME appearing in the ACTION column must be a
chain branched either directly or indirectly from the <emphasis chain branched either directly or indirectly from the <emphasis
role="bold">accountin</emphasis> or <emphasis role="bold">accipsecin</emphasis> or <emphasis
role="bold">accountout</emphasis> chain.</para> role="bold">accipsecout</emphasis> chain.</para>
</listitem> </listitem>
<listitem> <listitem>
<para>The CHAIN column must contain either <emphasis <para>The CHAIN column must contain either <emphasis
role="bold">accountin</emphasis> or <emphasis role="bold">accipsecin</emphasis> or <emphasis
role="bold">accountout</emphasis> or a chain branched either role="bold">accipsecout</emphasis> or a chain branched either
directly or indirectly from those chains.</para> directly or indirectly from those chains.</para>
</listitem> </listitem>
</itemizedlist>
<listitem>
<para>These rules will NOT appear in the <emphasis <para>These rules will NOT appear in the <emphasis
role="bold">accounting</emphasis> chain.</para> role="bold">accounting</emphasis> chain.</para>
</listitem> </listitem>
</itemizedlist>
</listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>

View File

@@ -23,8 +23,10 @@
<refsect1> <refsect1>
<title>Description</title> <title>Description</title>
<para>The blacklist file is used to perform static blacklisting. You can <para>The blacklist file is used to perform static blacklisting by source
blacklist by source address (IP or MAC), or by application.</para> address (IP or MAC), or by application. The use of this file is deprecated
and beginning with Shorewall 4.5.7, the file is no longer
installed.</para>
<para>The columns in the file are as follows (where the column name is <para>The columns in the file are as follows (where the column name is
followed by a different name in parentheses, the different name is used in followed by a different name in parentheses, the different name is used in

View File

@@ -60,7 +60,31 @@
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term>blacklog</term> <term><emphasis role="bold">BLACKLIST</emphasis></term>
<listitem>
<para>Added in Shorewall 4.5.3. This is actually a macro that
expands as follows:</para>
<itemizedlist>
<listitem>
<para>If BLACKLIST_LOGLEVEL is specified in <ulink
url="shorewall.conf.html">shorewall.conf</ulink>(5), then
the macro expands to <emphasis
role="bold">blacklog</emphasis>.</para>
</listitem>
<listitem>
<para>Otherwise it expands to the action specified for
BLACKLIST_DISPOSITION in <ulink
url="shorewall.conf.html">shorewall.conf</ulink>(5).</para>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">blacklog</emphasis></term>
<listitem> <listitem>
<para>May only be used if BLACKLIST_LOGLEVEL is specified in <para>May only be used if BLACKLIST_LOGLEVEL is specified in

View File

@@ -3,33 +3,34 @@
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"> "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<refentry> <refentry>
<refmeta> <refmeta>
<refentrytitle>shorewall6-notrack</refentrytitle> <refentrytitle>shorewall6-conntrack</refentrytitle>
<manvolnum>5</manvolnum> <manvolnum>5</manvolnum>
</refmeta> </refmeta>
<refnamediv> <refnamediv>
<refname>notrack</refname> <refname>conntrack</refname>
<refpurpose>shorewall notrack file</refpurpose> <refpurpose>shorewall conntrack file</refpurpose>
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<cmdsynopsis> <cmdsynopsis>
<command>/etc/shorewall/notrack</command> <command>/etc/shorewall/conntrack</command>
</cmdsynopsis> </cmdsynopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
<title>Description</title> <title>Description</title>
<para>The original intent of the notrack file was to exempt certain <para>The original intent of the <emphasis role="bold">notrack</emphasis>
traffic from Netfilter connection tracking. Traffic matching entries in file was to exempt certain traffic from Netfilter connection tracking.
this file were not to be tracked.</para> Traffic matching entries in the file were not to be tracked.</para>
<para>The role of the file was expanded in Shorewall 4.4.27 to include all <para>The role of the file was expanded in Shorewall 4.4.27 to include all
rules tht can be added in the Netfilter <emphasis rules that can be added in the Netfilter <emphasis
role="bold">raw</emphasis> table.</para> role="bold">raw</emphasis> table. In 4.5.7, the file's name was changed to
<emphasis role="bold">conntrack</emphasis>.</para>
<para>The file supports two different column layouts: FORMAT 1 and FORMAT <para>The file supports two different column layouts: FORMAT 1 and FORMAT
2, FORMAT 1 being the default. The two differ in that FORMAT 2 has an 2, FORMAT 1 being the default. The two differ in that FORMAT 2 has an
@@ -45,6 +46,13 @@
<para>where <replaceable>format</replaceable> is either <emphasis <para>where <replaceable>format</replaceable> is either <emphasis
role="bold">1</emphasis> or <emphasis role="bold">2</emphasis>.</para> role="bold">1</emphasis> or <emphasis role="bold">2</emphasis>.</para>
<para>Comments may be attached to Netfilter rules generated from entries
in this file through the use of COMMENT lines. These lines begin with the
word COMMENT; the remainder of the line is treated as a comment which is
attached to subsequent rules until another COMMENT line is found or until
the end of the file is reached. To stop adding comments to rules, use a
line with only the word COMMENT.</para>
<para>The columns in the file are as follows (where the column name is <para>The columns in the file are as follows (where the column name is
followed by a different name in parentheses, the different name is used in followed by a different name in parentheses, the different name is used in
the alternate specification syntax).</para> the alternate specification syntax).</para>
@@ -53,35 +61,132 @@
<varlistentry> <varlistentry>
<term><emphasis role="bold">ACTION</emphasis> - {<emphasis <term><emphasis role="bold">ACTION</emphasis> - {<emphasis
role="bold">NOTRACK</emphasis>|<emphasis role="bold">NOTRACK</emphasis>|<emphasis
role="bold">CT</emphasis>:<replaceable>option</replaceable>[:<replaceable>arg,...</replaceable>]}</term> role="bold">CT</emphasis>:<emphasis
role="bold">helper</emphasis>:<replaceable>name</replaceable>[(<replaceable>arg</replaceable>=<replaceable>val</replaceable>[,...])|<emphasis
role="bold">CT:notrack</emphasis>}</term>
<listitem> <listitem>
<para>This column is only present when FORMAT = 2. Values other than <para>This column is only present when FORMAT = 2. Values other than
NOTRACK require <firstterm>CT Target </firstterm>support in your NOTRACK require <firstterm>CT Target </firstterm>support in your
iptables and kernel.</para> iptables and kernel.</para>
<para>Possible values for <replaceable>option</replaceable> and
<replaceable>arg</replaceable>s are:</para>
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para><option>notrack</option> (no <para><option>NOTRACK</option> or
<replaceable>arg</replaceable>)</para> <option>CT:notrack</option></para>
<para>Disables connection tracking for this packet, the same as <para>Disables connection tracking for this packet.</para>
if NOTRACK has been specified in this column.</para>
</listitem> </listitem>
<listitem> <listitem>
<para><option>helper</option>:<replaceable>name</replaceable></para> <para><option>helper</option>:<replaceable>name</replaceable></para>
<para>Use the helper identified by the name to this connection. <para>Attach the helper identified by the
This is more flexible than loading the conntrack helper with <replaceable>name</replaceable> to this connection. This is more
preset ports.</para> flexible than loading the conntrack helper with preset
</listitem> ports.</para>
<para>At this writing, the available helpers are:</para>
<variablelist>
<varlistentry>
<term>amanda</term>
<listitem> <listitem>
<para><option>ctevents</option>:<replaceable>event</replaceable>,...</para> <para>Requires that the amanda netfilter helper is
present.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>ftp</term>
<listitem>
<para>Requires that the FTP netfilter helper is
present.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>irc</term>
<listitem>
<para>Requires that the IRC netfilter helper is
present.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>netbios-ns</term>
<listitem>
<para>Requires that the netbios_ns (sic) helper is
present.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>RAS and Q.931</term>
<listitem>
<para>These require that the H323 netfilter helper is
present.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pptp</term>
<listitem>
<para>Requires that the pptp netfilter helper is
present.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>sane</term>
<listitem>
<para>Requires that the SANE netfilter helper is
present.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>sip</term>
<listitem>
<para>Requires that the SIP netfilter helper is
present.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>snmp</term>
<listitem>
<para>Requires that the SNMP netfilter helper is
present.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>tftp</term>
<listitem>
<para>Requires that the TFTP netfilter helper is
present.</para>
</listitem>
</varlistentry>
</variablelist>
<para>May be followed by an option list of
<replaceable>arg</replaceable>=<replaceable>val</replaceable>
pairs in parentheses:</para>
<itemizedlist>
<listitem>
<para><option>ctevents</option>=<replaceable>event</replaceable>[,...]</para>
<para>Only generate the specified conntrack events for this <para>Only generate the specified conntrack events for this
connection. Possible event types are: <emphasis connection. Possible event types are: <emphasis
@@ -92,24 +197,21 @@
role="bold">assured</emphasis>, <emphasis role="bold">assured</emphasis>, <emphasis
role="bold">protoinfo</emphasis>, <emphasis role="bold">protoinfo</emphasis>, <emphasis
role="bold">helper</emphasis>, <emphasis role="bold">helper</emphasis>, <emphasis
role="bold">mark</emphasis> (this is connection mark, not packet role="bold">mark</emphasis> (this is connection mark, not
mark), <emphasis role="bold">natseqinfo</emphasis>, and packet mark), <emphasis role="bold">natseqinfo</emphasis>,
<emphasis role="bold">secmark</emphasis>.</para> and <emphasis role="bold">secmark</emphasis>. If more than
one <emphasis>event</emphasis> is listed, the
<replaceable>event</replaceable> list must be enclosed in
parentheses (e.g., ctevents=(new,related)).</para>
</listitem> </listitem>
<listitem> <listitem>
<para><option>expevents</option><option>:new</option></para> <para><option>expevents</option><option>=new</option></para>
<para>Only generate a new expectation events for this <para>Only generate a <emphasis role="bold">new</emphasis>
connection.</para> expectation events for this connection.</para>
</listitem> </listitem>
</itemizedlist>
<listitem>
<para><option>zone</option>:<replaceable>id</replaceable></para>
<para>Assign this packet to zone <replaceable>id</replaceable>
and only have lookups done in that zone. By default, packets
have zone 0.</para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
@@ -130,13 +232,9 @@
url="shorewall-exclusion.html">shorewall-exclusion</ulink> url="shorewall-exclusion.html">shorewall-exclusion</ulink>
(5)).</para> (5)).</para>
<para>Comments may be attached to Netfilter rules generated from <para>Beginning with Shorewall 4.5.7, <option>all</option> can be
entries in this file through the use of COMMENT lines. These lines used as the <replaceable>zone</replaceable> name to mean
begin with the word COMMENT; the remainder of the line is treated as <firstterm>all zones</firstterm>.</para>
a comment which is attached to subsequent rules until another
COMMENT line is found or until the end of the file is reached. To
stop adding comments to rules, use a line with only the word
COMMENT.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -225,6 +323,14 @@
</variablelist> </variablelist>
</refsect1> </refsect1>
<refsect1>
<title>EXAMPLE</title>
<programlisting>#ACTION SOURCE DEST PROTO DEST SOURCE USER/GROUP
# PORT(S) PORT(S)
CT:helper:ftp(expevents=new) fw - tcp 21 </programlisting>
</refsect1>
<refsect1> <refsect1>
<title>FILES</title> <title>FILES</title>

View File

@@ -27,6 +27,34 @@
interfaces to Shorewall. The order of entries in this file is not interfaces to Shorewall. The order of entries in this file is not
significant in determining zone composition.</para> significant in determining zone composition.</para>
<para>Beginning with Shorewall 4.5.3, the interfaces file supports two
different formats:</para>
<variablelist>
<varlistentry>
<term>FORMAT 1 (default - deprecated)</term>
<listitem>
<para>There is a BROADCAST column which can be used to specify the
broadcast address associated with the interface.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>FORMAT 2</term>
<listitem>
<para>The BROADCAST column is omitted.</para>
</listitem>
</varlistentry>
</variablelist>
<para>The format is specified by a line as follows:</para>
<blockquote>
<para><emphasis role="bold">FORMAT {1|2}</emphasis></para>
</blockquote>
<para>The columns in the file are as follows.</para> <para>The columns in the file are as follows.</para>
<variablelist> <variablelist>
@@ -128,6 +156,8 @@ loc eth2 -</programlisting>
role="bold">detect</emphasis>|<emphasis>address</emphasis>[,<emphasis>address</emphasis>]...}</term> role="bold">detect</emphasis>|<emphasis>address</emphasis>[,<emphasis>address</emphasis>]...}</term>
<listitem> <listitem>
<para>Only available if FORMAT 1.</para>
<para>If you use the special value <emphasis <para>If you use the special value <emphasis
role="bold">detect</emphasis>, Shorewall will detect the broadcast role="bold">detect</emphasis>, Shorewall will detect the broadcast
address(es) for you if your iptables and kernel include Address Type address(es) for you if your iptables and kernel include Address Type
@@ -313,13 +343,22 @@ loc eth2 -</programlisting>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">ignore</emphasis></term> <term><emphasis role="bold">ignore[=1]</emphasis></term>
<listitem> <listitem>
<para>When specified, causes the generated script to ignore <para>When specified, causes the generated script to ignore
up/down events from Shorewall-init for this device. up/down events from Shorewall-init for this device.
Additionally, the option exempts the interface from hairpin Additionally, the option exempts the interface from hairpin
filtering.</para> filtering. When '=1' is omitted, the ZONE column must contain
'-' and <option>ignore</option> must be the only
OPTION.</para>
<para>Beginning with Shorewall 4.5.5, may be specified as
'<option>ignore=1</option>' which only causes the generated
script to ignore up/down events from Shorewall-init; hairpin
filtering is still applied. In this case, the above
restrictions on the ZONE and OPTIONS columns are
lifted.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -597,6 +636,20 @@ loc eth2 -</programlisting>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>rpfilter</term>
<listitem>
<para>Added in Shorewall 4.5.7. This is an anti-spoofing
measure that requires the 'RPFilter Match' capability in your
iptables and kernel. It provides a more efficient alternative
to the <option>sfilter</option> option below. It performs a
function similar to <option>routefilter</option> (see above)
but works with Multi-ISP configurations that do now use
balanced routes.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>sfilter=(<emphasis>net</emphasis>[,...])</term> <term>sfilter=(<emphasis>net</emphasis>[,...])</term>
@@ -705,11 +758,14 @@ loc eth2 -</programlisting>
connected to your local network and that your local subnet is connected to your local network and that your local subnet is
192.168.1.0/24. The interface gets its IP address via DHCP from 192.168.1.0/24. The interface gets its IP address via DHCP from
subnet 206.191.149.192/27. You have a DMZ with subnet 192.168.2.0/24 subnet 206.191.149.192/27. You have a DMZ with subnet 192.168.2.0/24
using eth2.</para> using eth2. Your iptables and/or kernel do not support "Address Type
Match" and you prefer to specify broadcast addresses explicitly
rather than having Shorewall detect them.</para>
<para>Your entries for this setup would look like:</para> <para>Your entries for this setup would look like:</para>
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS <programlisting>FORMAT 1
#ZONE INTERFACE BROADCAST OPTIONS
net eth0 206.191.149.223 dhcp net eth0 206.191.149.223 dhcp
loc eth1 192.168.1.255 loc eth1 192.168.1.255
dmz eth2 192.168.2.255</programlisting> dmz eth2 192.168.2.255</programlisting>
@@ -723,10 +779,11 @@ dmz eth2 192.168.2.255</programlisting>
<para>The same configuration without specifying broadcast addresses <para>The same configuration without specifying broadcast addresses
is:</para> is:</para>
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS <programlisting>FORMAT 2
net eth0 detect dhcp #ZONE INTERFACE OPTIONS
loc eth1 detect net eth0 dhcp
dmz eth2 detect</programlisting> loc eth1
dmz eth2</programlisting>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -737,7 +794,8 @@ dmz eth2 detect</programlisting>
<para>You have a simple dial-in system with no ethernet <para>You have a simple dial-in system with no ethernet
connections.</para> connections.</para>
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS <programlisting>FORMAT 2
#ZONE INTERFACE OPTIONS
net ppp0 -</programlisting> net ppp0 -</programlisting>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -749,8 +807,9 @@ net ppp0 -</programlisting>
<para>You have a bridge with no IP address and you want to allow <para>You have a bridge with no IP address and you want to allow
traffic through the bridge.</para> traffic through the bridge.</para>
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS <programlisting>FORMAT 2
- br0 - routeback</programlisting> #ZONE INTERFACE OPTIONS
- br0 routeback</programlisting>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
@@ -772,10 +831,9 @@ net ppp0 -</programlisting>
shorewall-blacklist(5), shorewall-hosts(5), shorewall-maclist(5), shorewall-blacklist(5), shorewall-hosts(5), shorewall-maclist(5),
shorewall-masq(5), shorewall-nat(5), shorewall-netmap(5), shorewall-masq(5), shorewall-nat(5), shorewall-netmap(5),
shorewall-params(5), shorewall-policy(5), shorewall-providers(5), shorewall-params(5), shorewall-policy(5), shorewall-providers(5),
shorewall-proxyarp(5), shorewall-rtrules(5), shorewall-proxyarp(5), shorewall-rtrules(5), shorewall-routestopped(5),
shorewall-routestopped(5), shorewall-rules(5), shorewall.conf(5), shorewall-rules(5), shorewall.conf(5), shorewall-secmarks(5),
shorewall-secmarks(5), shorewall-tcclasses(5), shorewall-tcdevices(5), shorewall-tcclasses(5), shorewall-tcdevices(5), shorewall-tcrules(5),
shorewall-tcrules(5), shorewall-tos(5), shorewall-tunnels(5), shorewall-tos(5), shorewall-tunnels(5), shorewall-zones(5)</para>
shorewall-zones(5)</para>
</refsect1> </refsect1>
</refentry> </refentry>

View File

@@ -509,6 +509,22 @@
restart</command>.</para> restart</command>.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis role="bold">ORIGINAL DEST</emphasis> (origdest) -
[<emphasis
role="bold">-</emphasis>|<emphasis>address</emphasis>[,<emphasis>address</emphasis>]...[<emphasis>exclusion</emphasis>]|<emphasis>exclusion</emphasis>]</term>
<listitem>
<para>(Optional) Added in Shorewall 4.5.6. This column may be
included and may contain one or more addresses (host or network)
separated by commas. Address ranges are not allowed. When this
column is supplied, rules are generated that require that the
original destination address matches one of the listed addresses. It
is useful for specifying that SNAT should occur only for connections
that were acted on by a DNAT when they entered the firewall.</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>

View File

@@ -87,8 +87,7 @@
being zero). Otherwise, the value must be between 1 and 255. Each being zero). Otherwise, the value must be between 1 and 255. Each
provider must be assigned a unique mark value. This column may be provider must be assigned a unique mark value. This column may be
omitted if you don't use packet marking to direct connections to a omitted if you don't use packet marking to direct connections to a
particular provider and you don't specify <option>track</option> in particular provider.</para>
the OPTIONS column.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -271,6 +270,20 @@
<filename>shorewall.conf</filename>.</para> <filename>shorewall.conf</filename>.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis role="bold">tproxy</emphasis></term>
<listitem>
<para>Added in Shorewall 4.5.4. Used for supporting the TPROXY
action in shorewall-tcrules(5). See <ulink
url="http://www.shorewall.net/Shorewall_Squid_Usage.html">http://www.shorewall.net/Shorewall_Squid_Usage.html</ulink>.
When specified, the MARK, DUPLICATE and GATEWAY columns should
be empty, INTERFACE should be set to 'lo' and
<option>tproxy</option> should be the only OPTION. Only one
<option>tproxy</option> provider is allowed.</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -503,6 +503,19 @@
rule, it is passed on to the next rule.</para> rule, it is passed on to the next rule.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>HELPER</term>
<listitem>
<para>Added in Shorewall 4.5.7. This action requires that the
HELPER column contains the name of the Netfilter helper to be
associated with connections matching this connection. May only
be specified in the NEW section and is useful for being able
to specify a helper when the applicable policy is ACCEPT. No
destination zone should be specified in HELPER rules.</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
<para>The <replaceable>target</replaceable> may optionally be <para>The <replaceable>target</replaceable> may optionally be
@@ -563,7 +576,7 @@
role="bold">-</emphasis>]}<emphasis role="bold">-</emphasis>]}<emphasis
role="bold">[:</emphasis><emphasis>interface</emphasis>][<emphasis role="bold">[:</emphasis><emphasis>interface</emphasis>][<emphasis
role="bold">:</emphasis>{<emphasis>address-or-range</emphasis>[,<emphasis>address-or-range</emphasis>]...[<emphasis>exclusion</emphasis>]|<emphasis>exclusion</emphasis>|<emphasis role="bold">:</emphasis>{<emphasis>address-or-range</emphasis>[,<emphasis>address-or-range</emphasis>]...[<emphasis>exclusion</emphasis>]|<emphasis>exclusion</emphasis>|<emphasis
role="bold">+</emphasis><emphasis>ipset</emphasis>}</term> role="bold">+</emphasis><emphasis>ipset</emphasis>|<replaceable>^countrycode-list</replaceable>}</term>
<listitem> <listitem>
<para>Source hosts to which the rule applies. May be a <para>Source hosts to which the rule applies. May be a
@@ -639,6 +652,18 @@
url="shorewall-interfaces.html">shorewall-interfaces</ulink> url="shorewall-interfaces.html">shorewall-interfaces</ulink>
(5).</para> (5).</para>
<para>Beginning with Shorewall 4.5.4, A
<replaceable>countrycode-list</replaceable> may be specified. A
countrycode-list is a comma-separated list of up to 15 two-character
ISO-3661 country codes enclosed in square brackets ('[...]') and
preceded by a caret ('^'). When a single country code is given, the
square brackets may be omitted. A list of country codes supported by
Shorewall may be found at <ulink
url="http://www.shorewall.net/ISO-3661.html">http://www.shorewall.net/ISO-3661.html</ulink>.
Specifying a <replaceable>countrycode-list</replaceable> requires
<firstterm>GeoIP Match</firstterm> support in your iptables and
Kernel.</para>
<para>You may exclude certain hosts from the set already defined <para>You may exclude certain hosts from the set already defined
through use of an <emphasis>exclusion</emphasis> (see <ulink through use of an <emphasis>exclusion</emphasis> (see <ulink
url="shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para> url="shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para>
@@ -726,7 +751,7 @@
role="bold">+</emphasis>][<emphasis role="bold">+</emphasis>][<emphasis
role="bold">-</emphasis>]}<emphasis role="bold">-</emphasis>]}<emphasis
role="bold">[:{</emphasis><emphasis>interface</emphasis>|<emphasis>address-or-range</emphasis>[,<emphasis>address-or-range</emphasis>]...[<emphasis>exclusion</emphasis>]|<emphasis>exclusion</emphasis>|<emphasis role="bold">[:{</emphasis><emphasis>interface</emphasis>|<emphasis>address-or-range</emphasis>[,<emphasis>address-or-range</emphasis>]...[<emphasis>exclusion</emphasis>]|<emphasis>exclusion</emphasis>|<emphasis
role="bold">+</emphasis><emphasis>ipset</emphasis>}][<option>:</option><replaceable>port</replaceable>[:<emphasis role="bold">+</emphasis><emphasis>ipset</emphasis>|<emphasis>^countrycode-list</emphasis>}][<option>:</option><replaceable>port</replaceable>[:<emphasis
role="bold">random</emphasis>]]</term> role="bold">random</emphasis>]]</term>
<listitem> <listitem>
@@ -744,6 +769,18 @@
"+" to indicate that the rule is to apply to intra-zone traffic as "+" to indicate that the rule is to apply to intra-zone traffic as
well as inter-zone traffic.</para> well as inter-zone traffic.</para>
<para>Beginning with Shorewall 4.5.4, A
<replaceable>countrycode-list</replaceable> may be specified. A
countrycode-list is a comma-separated list of up to 15 two-character
ISO-3661 country codes enclosed in square brackets ('[...]') and
preceded by a caret ('^'). When a single country code is given, the
square brackets may be omitted. A list of country codes supported by
Shorewall may be found at <ulink
url="http://www.shorewall.net/ISO-3661.html">http://www.shorewall.net/ISO-3661.html</ulink>.
Specifying a <replaceable>countrycode-list</replaceable> requires
<firstterm>GeoIP Match</firstterm> support in your iptables and
Kernel.</para>
<para>When <emphasis role="bold">none</emphasis> is used either in <para>When <emphasis role="bold">none</emphasis> is used either in
the <emphasis role="bold">SOURCE</emphasis> or <emphasis the <emphasis role="bold">SOURCE</emphasis> or <emphasis
role="bold">DEST</emphasis> column, the rule is ignored.</para> role="bold">DEST</emphasis> column, the rule is ignored.</para>
@@ -782,7 +819,7 @@
</orderedlist></para> </orderedlist></para>
<blockquote> <blockquote>
<para/> <para></para>
<para>Except when <emphasis role="bold">all</emphasis>[<emphasis <para>Except when <emphasis role="bold">all</emphasis>[<emphasis
role="bold">+]|[-</emphasis>] is specified, the server may be role="bold">+]|[-</emphasis>] is specified, the server may be
@@ -1060,8 +1097,7 @@
<varlistentry> <varlistentry>
<term><emphasis role="bold">USER/GROUP</emphasis> (user) - [<emphasis <term><emphasis role="bold">USER/GROUP</emphasis> (user) - [<emphasis
role="bold">!</emphasis>][<emphasis>user-name-or-number</emphasis>][<emphasis role="bold">!</emphasis>][<emphasis>user-name-or-number</emphasis>][<emphasis
role="bold">:</emphasis><emphasis>group-name-or-number</emphasis>][<emphasis role="bold">:</emphasis><emphasis>group-name-or-number</emphasis>]</term>
role="bold">+</emphasis><emphasis>program-name</emphasis>]</term>
<listitem> <listitem>
<para>This optional column may only be non-empty if the SOURCE is <para>This optional column may only be non-empty if the SOURCE is
@@ -1102,15 +1138,11 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>+upnpd</term> <term>2001-2099</term>
<listitem> <listitem>
<para>program named upnpd</para> <para>UIDs 2001 through 2099 (Shorewall 4.5.6 and
later)</para>
<important>
<para>The ability to specify a program name was removed from
Netfilter in kernel version 2.6.14.</para>
</important>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
@@ -1332,6 +1364,54 @@
restart</command>.</para> restart</command>.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis role="bold">HELPER</emphasis> - [helper]</term>
<listitem>
<para>Added in Shorewall 4.5.7.</para>
<para>In the NEW section, causes the named conntrack
<replaceable>helper</replaceable> to be associated with this
connection; the contents of this column are ignored unless ACTION is
ACCEPT*, DNAT* or REDIRECT*.</para>
<para>In the RELATED section, will only match if the related
connection has the named <replaceable>helper</replaceable>
associated with it.</para>
<para>The <replaceable>helper</replaceable> may be one of:</para>
<simplelist>
<member><option>amanda</option></member>
<member><option>ftp</option></member>
<member><option>irc</option></member>
<member><option>netbios-ns</option></member>
<member><option>pptp</option></member>
<member><option>Q.931</option></member>
<member><option>RAS</option></member>
<member><option>sane</option></member>
<member><option>sip</option></member>
<member><option>snmp</option></member>
<member><option>tftp</option></member>
</simplelist>
<para>If the HELPERS option is specified in <ulink
url="shorewall.conf.html">shorewall.conf</ulink>(5), then any module
specified in this column most be listed in the HELPERS
setting.</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>
@@ -1535,6 +1615,19 @@
DNAT net dmz:$BACKUP tcp 80 - - - - - - - - primary_down</programlisting> DNAT net dmz:$BACKUP tcp 80 - - - - - - - - primary_down</programlisting>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>Example 13:</term>
<listitem>
<para>Drop all email from the <emphasis>Anonymous Proxy</emphasis>
and <emphasis>Satellite Provider</emphasis> address ranges:</para>
<programlisting> #ACTION SOURCE DEST PROTO DEST
# PORT(S)
DROP net:^A1,A2 fw tcp 25</programlisting>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>
@@ -1551,7 +1644,10 @@
url="http://www.shorewall.net/ipsets.html">http://www.shorewall.net/ipsets.html</ulink></para> url="http://www.shorewall.net/ipsets.html">http://www.shorewall.net/ipsets.html</ulink></para>
<para><ulink <para><ulink
url="http://shorewall.net/configuration_file_basics.htm#Pairs">http://shorewall.net/configuration_file_basics.htm#Pairs</ulink></para> url="http://shorewall.net/configuration_file_basics.htm#Pairs">http://www.shorewall.net/configuration_file_basics.htm#Pairs</ulink></para>
<para><ulink
url="http://www.shorewall.net/shorewall_logging.html">http://www.shorewall.net/shorewall_logging.html</ulink></para>
<para>shorewall(8), shorewall-accounting(5), shorewall-actions(5), <para>shorewall(8), shorewall-accounting(5), shorewall-actions(5),
shorewall-blacklist(5), shorweall-blrules(5), shorewall-hosts(5), shorewall-blacklist(5), shorweall-blrules(5), shorewall-hosts(5),

View File

@@ -11,7 +11,7 @@
<refnamediv> <refnamediv>
<refname>tcclasses</refname> <refname>tcclasses</refname>
<refpurpose>Shorewall file to define HTB classes</refpurpose> <refpurpose>Shorewall file to define HTB and HFSC classes</refpurpose>
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
@@ -166,8 +166,8 @@
marking the traffic you want to fit in the classes defined in here. marking the traffic you want to fit in the classes defined in here.
Must be specified as '-' if the <emphasis Must be specified as '-' if the <emphasis
role="bold">classify</emphasis> option is given for the interface in role="bold">classify</emphasis> option is given for the interface in
<ulink <ulink url="shorewall-tcdevices.html">shorewall-tcdevices</ulink>(5)
url="shorewall-tcdevices.html">shorewall-tcdevices</ulink>(5)</para> and you are running Shorewall 4.5.5 or earlier.</para>
<para>You can use the same marks for different interfaces.</para> <para>You can use the same marks for different interfaces.</para>
</listitem> </listitem>
@@ -175,7 +175,7 @@
<varlistentry> <varlistentry>
<term><emphasis role="bold">RATE</emphasis> - <term><emphasis role="bold">RATE</emphasis> -
<emphasis>rate</emphasis>[:<emphasis>dmax</emphasis>[:<emphasis>umax</emphasis>]]</term> {-|<emphasis>rate</emphasis>[:<emphasis>dmax</emphasis>[:<emphasis>umax</emphasis>]]}</term>
<listitem> <listitem>
<para>The minimum bandwidth this class should get, when the traffic <para>The minimum bandwidth this class should get, when the traffic
@@ -185,11 +185,12 @@
class exceed the CEIL of the parent class, things don't work class exceed the CEIL of the parent class, things don't work
well.</para> well.</para>
<para>When using the HFSC queuing discipline, leaf classes may <para>When using the HFSC queuing discipline, this column specify
specify <replaceable>dmax</replaceable>, the maximum delay in the real-time (RT) service curve. leaf classes may specify
milliseconds that the first queued packet for this class should <replaceable>dmax</replaceable>, the maximum delay in milliseconds
experience. May be expressed as an integer, optionally followed by that the first queued packet for this class should experience. May
'ms' with no intervening white space (e.g., 10ms).</para> be expressed as an integer, optionally followed by 'ms' with no
intervening white space (e.g., 10ms).</para>
<para>HFSC leaf classes may also specify <para>HFSC leaf classes may also specify
<replaceable>umax</replaceable>, the largest packet expected in this <replaceable>umax</replaceable>, the largest packet expected in this
@@ -198,12 +199,18 @@
followed by 'b' with no intervening white space (e.g., 800b). followed by 'b' with no intervening white space (e.g., 800b).
<replaceable>umax</replaceable> may only be given if <replaceable>umax</replaceable> may only be given if
<replaceable>dmax</replaceable> is also given.</para> <replaceable>dmax</replaceable> is also given.</para>
<para>Beginning with Shorewall 4.5.6, HFSC classes may omit this
column (e.g, '-' in the column), provided that an
<replaceable>lsrate</replaceable> is specified (see CEIL below).
These rates are used to arbitrate between classes of the same
priority.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">CEIL</emphasis> - <term><emphasis role="bold">CEIL</emphasis> -
<emphasis>rate</emphasis></term> [<emphasis>lsrate</emphasis>:]<emphasis>rate</emphasis></term>
<listitem> <listitem>
<para>The maximum bandwidth this class is allowed to use when the <para>The maximum bandwidth this class is allowed to use when the
@@ -214,6 +221,9 @@
here for setting the maximum bandwidth to the RATE of the parent here for setting the maximum bandwidth to the RATE of the parent
class, or the OUT-BANDWIDTH of the device if there is no parent class, or the OUT-BANDWIDTH of the device if there is no parent
class.</para> class.</para>
<para>Beginning with Shorewall 4.5.6, you can also specify an
<replaceable>lsrate</replaceable> (link sharing rate).</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -253,7 +263,7 @@
<para>This is the default class for that interface where all <para>This is the default class for that interface where all
traffic should go, that is not classified otherwise.</para> traffic should go, that is not classified otherwise.</para>
<para></para> <para/>
<note> <note>
<para>You must define <emphasis <para>You must define <emphasis
@@ -310,7 +320,7 @@
limited to 64 bytes because we want only packets WITHOUT limited to 64 bytes because we want only packets WITHOUT
payload to match.</para> payload to match.</para>
<para></para> <para/>
<note> <note>
<para>This option is only valid for ONE class per <para>This option is only valid for ONE class per
@@ -430,6 +440,121 @@
assumed.</para> assumed.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>red=(<replaceable>redoption</replaceable>=<replaceable>value</replaceable>,
...)</term>
<listitem>
<para>Added in Shorewall 4.5.6. When specified on a leaf
class, causes the class to use the RED (Random Early
Detection) queuing discipline rather than SFQ. See tc-red (8)
for additional information.</para>
<para>Allowable redoptions are:</para>
<variablelist>
<varlistentry>
<term>min <replaceable>min</replaceable></term>
<listitem>
<para>Average queue size at which marking becomes a
possibility.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>max <replaceable>max</replaceable></term>
<listitem>
<para>At this average queue size, the marking
probability is maximal. Must be at least twice
<replaceable>min</replaceable> to prevent synchronous
retransmits, higher for low
<replaceable>min</replaceable>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>probability
<replaceable>probability</replaceable></term>
<listitem>
<para>Maximum probability for marking, specified as a
floating point number from 0.0 to 1.0. Suggested values
are 0.01 or 0.02 (1 or 2%, respectively).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>limit <replaceable>limit</replaceable></term>
<listitem>
<para>Hard limit on the real (not average) queue size in
bytes. Further packets are dropped. Should be set higher
than
<replaceable>max</replaceable>+<replaceable>burst</replaceable>.
It is advised to set this a few times higher than
<replaceable>max</replaceable>. Shorewall requires that
<replaceable>limit</replaceable> be at least twice
<replaceable>min</replaceable>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>burst <replaceable>burst</replaceable></term>
<listitem>
<para>Used for determining how fast the average queue
size is influenced by the real queue size. Larger values
make the calculation more sluggish, allowing longer
bursts of traffic before marking starts. Real life
experiments support the following guideline:
(<replaceable>min</replaceable>+<replaceable>min</replaceable>+<replaceable>max</replaceable>)/(3*<replaceable>avpkt</replaceable>).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>avpkt <replaceable>avpkt</replaceable></term>
<listitem>
<para>Optional. Specified in bytes. Used with burst to
determine the time constant for average queue size
calculations. 1000 is a good value and is the Shorewall
default.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>bandwidth
<replaceable>bandwidth</replaceable></term>
<listitem>
<para>Optional. This rate is used for calculating the
average queue size after some idle time. Should be set
to the bandwidth of your interface. Does not mean that
RED will shape for you!</para>
</listitem>
</varlistentry>
<varlistentry>
<term>ecn</term>
<listitem>
<para>RED can either 'mark' or 'drop'. Explicit
Congestion Notification allows RED to notify remote
hosts that their rate exceeds the amount of bandwidth
available. Non-ECN capable hosts can only be notified by
dropping a packet. If this parameter is specified,
packets which indicate that their hosts honor ECN will
only be marked and not dropped, unless the queue size
hits <replaceable>limit</replaceable> bytes. Needs a tc
binary with RED support compiled in. Recommended.</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -503,6 +628,10 @@
<para><ulink <para><ulink
url="http://shorewall.net/configuration_file_basics.htm#Pairs">http://shorewall.net/configuration_file_basics.htm#Pairs</ulink></para> url="http://shorewall.net/configuration_file_basics.htm#Pairs">http://shorewall.net/configuration_file_basics.htm#Pairs</ulink></para>
<para>tc-hfsc(7)</para>
<para>tc-red(8)</para>
<para>shorewall(8), shorewall-accounting(5), shorewall-actions(5), <para>shorewall(8), shorewall-accounting(5), shorewall-actions(5),
shorewall-blacklist(5), shorewall-hosts(5), shorewall_interfaces(5), shorewall-blacklist(5), shorewall-hosts(5), shorewall_interfaces(5),
shorewall-ipsets(5), shorewall-maclist(5), shorewall-masq(5), shorewall-ipsets(5), shorewall-maclist(5), shorewall-masq(5),

View File

@@ -179,7 +179,17 @@
<varlistentry> <varlistentry>
<term><emphasis role="bold">OPTIONS</emphasis> - {<emphasis <term><emphasis role="bold">OPTIONS</emphasis> - {<emphasis
role="bold">-</emphasis>|<emphasis role="bold">-</emphasis>|<emphasis
role="bold">{classify</emphasis>|hfsc} ,...}</term> role="bold">{classify</emphasis>|<emphasis
role="bold">hfsc</emphasis>|<emphasis
role="bold">linklayer</emphasis>={<emphasis
role="bold">ethernet</emphasis>|<emphasis
role="bold">atm</emphasis>|<emphasis
role="bold">adsl</emphasis>}|<emphasis
role="bold">tsize</emphasis>=<replaceable>tsize</replaceable>|<emphasis
role="bold">mtu</emphasis>=<replaceable>mtu</replaceable>|<emphasis
role="bold">mpu</emphasis>=<replaceable>mpu</replaceable>|<emphasis
role="bold">overhead</emphasis>=<replaceable>overhead</replaceable>}
,...}</term>
<listitem> <listitem>
<para><option>classify</option> ― When specified, Shorewall will not <para><option>classify</option> ― When specified, Shorewall will not
@@ -190,7 +200,34 @@
<para><option>hfsc</option> - Shorewall normally uses the <para><option>hfsc</option> - Shorewall normally uses the
<firstterm>Hierarchical Token Bucket</firstterm> queuing discipline. <firstterm>Hierarchical Token Bucket</firstterm> queuing discipline.
When <option>hfsc</option> is specified, the <firstterm>Hierarchical When <option>hfsc</option> is specified, the <firstterm>Hierarchical
Fair Service Curves</firstterm> discipline is used instead.</para> Fair Service Curves</firstterm> discipline is used instead (see
tc-hfsc (7)).</para>
<para><emphasis role="bold">linklayer</emphasis> - Added in
Shorewall 4.5.6. Type of link (ethernet, atm, adsl). When specified,
causes scheduler packet size manipulation as described in tc-stab
(8). When this option is given, the following options may also be
given after it:</para>
<blockquote>
<para><emphasis
role="bold">mtu</emphasis>=<replaceable>mtu</replaceable> - The
device MTU; default 2048 (will be rounded up to a power of
two)</para>
<para><emphasis
role="bold">mpu</emphasis>=<replaceable>mpubytes</replaceable> -
Minimum packet size used in calculations. Smaller packets will be
rounded up to this size</para>
<para><emphasis
role="bold">tsize</emphasis>=<replaceable>tablesize</replaceable>
- Size table entries; default is 512</para>
<para><emphasis
role="bold">overhead</emphasis>=<replaceable>overheadbytes</replaceable>
- Number of overhead bytes per packet.</para>
</blockquote>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -240,6 +277,8 @@
<refsect1> <refsect1>
<title>See ALSO</title> <title>See ALSO</title>
<para>tc-hfsc (7)</para>
<para><ulink <para><ulink
url="http://shorewall.net/traffic_shaping.htm">http://shorewall.net/traffic_shaping.htm</ulink></para> url="http://shorewall.net/traffic_shaping.htm">http://shorewall.net/traffic_shaping.htm</ulink></para>

View File

@@ -35,7 +35,7 @@
<term>IPV4</term> <term>IPV4</term>
<listitem> <listitem>
<para>Following entriess apply to IPv4.</para> <para>Following entries apply to IPv4.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -38,6 +38,34 @@
url="http://shorewall.net/MultiISP.html">http://shorewall.net/MultiISP.html</ulink>.</para> url="http://shorewall.net/MultiISP.html">http://shorewall.net/MultiISP.html</ulink>.</para>
</important> </important>
<para>Beginning with Shorewall 4.5.4, the tcrules file supports two
different formats:</para>
<variablelist>
<varlistentry>
<term>FORMAT 1 (default - deprecated)</term>
<listitem>
<para>The older limited-function version of TPROXY is
supported.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>FORMAT 2</term>
<listitem>
<para>The newer version of TPROXY is supported.</para>
</listitem>
</varlistentry>
</variablelist>
<para>The format is specified by a line as follows:</para>
<blockquote>
<para><emphasis role="bold">FORMAT {1|2}</emphasis></para>
</blockquote>
<para>The columns in the file are as follows (where the column name is <para>The columns in the file are as follows (where the column name is
followed by a different name in parentheses, the different name is used in followed by a different name in parentheses, the different name is used in
the alternate specification syntax).</para> the alternate specification syntax).</para>
@@ -407,9 +435,23 @@ SAME $FW 0.0.0.0/0 tcp 80,443</programlisting>
classes will have a value &gt; 256.</para> classes will have a value &gt; 256.</para>
</listitem> </listitem>
<listitem>
<para><emphasis role="bold">DIVERT</emphasis></para>
<para>Added in Shorewall 4.5.4 and only available when FORMAT is
2. Two DIVERT rule should preceed the TPROXY rule and should
select DEST PORT tcp 80 and SOURCE PORT tcp 80 respectively
(assuming that tcp port 80 is being proxied). DIVERT avoids
sending packets to the TPROXY target once a socket connection to
Squid3 has been established by TPROXY. DIVERT marks the packet
with a unique mark and exempts it from any rules that
follow.</para>
</listitem>
<listitem> <listitem>
<para><emphasis <para><emphasis
role="bold">TPROXY</emphasis>(<replaceable>mark</replaceable>[/<replaceable>mask</replaceable>][,[<replaceable>port</replaceable>][,[<replaceable>address</replaceable>]]])</para> role="bold">TPROXY</emphasis>(<replaceable>mark</replaceable>[,[<replaceable>port</replaceable>][,[<replaceable>address</replaceable>]]])
-- FORMAT 1</para>
<para>Transparently redirects a packet without altering the IP <para>Transparently redirects a packet without altering the IP
header. Requires a local provider to be defined in <ulink header. Requires a local provider to be defined in <ulink
@@ -440,6 +482,34 @@ SAME $FW 0.0.0.0/0 tcp 80,443</programlisting>
</itemizedlist> </itemizedlist>
</listitem> </listitem>
<listitem>
<para><emphasis
role="bold">TPROXY</emphasis>([<replaceable>port</replaceable>][,<replaceable>address</replaceable>])
-- FORMAT 2</para>
<para>Transparently redirects a packet without altering the IP
header. Requires a tproxy provider to be defined in <ulink
url="shorewall-providers.html">shorewall-providers</ulink>(5).</para>
<para>There are three parameters to TPROXY - neither is
required:</para>
<itemizedlist>
<listitem>
<para><replaceable>port</replaceable> - the port on which
the proxy server is listening. If omitted, the original
destination port.</para>
</listitem>
<listitem>
<para><replaceable>address</replaceable> - a local (to the
firewall) IP address on which the proxy server is listening.
If omitted, the IP address of the interface on which the
request arrives.</para>
</listitem>
</itemizedlist>
</listitem>
<listitem> <listitem>
<para><emphasis role="bold">TTL</emphasis>([<emphasis <para><emphasis role="bold">TTL</emphasis>([<emphasis
role="bold">-</emphasis>|<emphasis role="bold">-</emphasis>|<emphasis
@@ -503,6 +573,9 @@ SAME $FW 0.0.0.0/0 tcp 80,443</programlisting>
AF43 =&gt; 0x26 AF43 =&gt; 0x26
EF =&gt; 0x2e</programlisting> EF =&gt; 0x2e</programlisting>
<para>To indicate more than one class, add their hex values
together and specify the result.</para>
<para>May be optionally followed by ':' and a capital letter <para>May be optionally followed by ':' and a capital letter
designating the chain where classification is to occur.</para> designating the chain where classification is to occur.</para>
@@ -541,6 +614,9 @@ Maximize-Reliability =&gt; 0x04,
Minimize-Cost =&gt; 0x02, Minimize-Cost =&gt; 0x02,
Normal-Service =&gt; 0x00</programlisting> Normal-Service =&gt; 0x00</programlisting>
<para>To indicate more than one class, add their hex values
together and specify the result.</para>
<para>When <replaceable>tos</replaceable> is given as a number, <para>When <replaceable>tos</replaceable> is given as a number,
it may be optionally followed by '/' and a it may be optionally followed by '/' and a
<replaceable>mask</replaceable>. When no <replaceable>mask</replaceable>. When no

View File

@@ -96,13 +96,16 @@
<emphasis>tos</emphasis></term> <emphasis>tos</emphasis></term>
<listitem> <listitem>
<para>Must be one of the following;</para> <para>Must may one of the following;</para>
<programlisting> <emphasis role="bold">tos-minimize-delay</emphasis> (16) <programlisting> <emphasis role="bold">tos-minimize-delay</emphasis> (16)
<emphasis role="bold">tos-maximize-throughput</emphasis> (8) <emphasis role="bold">tos-maximize-throughput</emphasis> (8)
<emphasis role="bold">tos-maximize-reliability</emphasis> (4) <emphasis role="bold">tos-maximize-reliability</emphasis> (4)
<emphasis role="bold">tos-minimize-cost</emphasis> (2) <emphasis role="bold">tos-minimize-cost</emphasis> (2)
<emphasis role="bold">tos-normal-service</emphasis> (0)</programlisting> <emphasis role="bold">tos-normal-service</emphasis> (0)</programlisting>
<para>To specify more than one flag, add their values together and
specify the numeric result.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -125,8 +125,9 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">GATEWAY</emphasis> - <term><emphasis role="bold">GATEWAY</emphasis>(S) (gateway or
<emphasis>address-or-range</emphasis></term> gateways) - <emphasis>address-or-range</emphasis> <emphasis
role="bold">[ , ... ]</emphasis></term>
<listitem> <listitem>
<para>The IP address of the remote tunnel gateway. If the remote <para>The IP address of the remote tunnel gateway. If the remote
@@ -134,12 +135,17 @@
as <emphasis role="bold">0.0.0.0/0</emphasis>. May be specified as a as <emphasis role="bold">0.0.0.0/0</emphasis>. May be specified as a
network address and if your kernel and iptables include iprange network address and if your kernel and iptables include iprange
match support then IP address ranges are also allowed.</para> match support then IP address ranges are also allowed.</para>
<para>Beginning with Shorewall 4.5.3, a list of addresses or ranges
may be given. Exclusion (<ulink
url="shorewall-exclusion.html">shorewall-exclusion</ulink> (5) ) is
not supported.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">GATEWAY ZONES</emphasis> (gateway_zone) - <term><emphasis role="bold">GATEWAY ZONES</emphasis> (gateway_zone or
[<emphasis>zone</emphasis>[<emphasis gateway_zones) - [<emphasis>zone</emphasis>[<emphasis
role="bold">,</emphasis><emphasis>zone</emphasis>]...]</term> role="bold">,</emphasis><emphasis>zone</emphasis>]...]</term>
<listitem> <listitem>
@@ -148,7 +154,7 @@
comma-separated list of the names of the zones that the host might comma-separated list of the names of the zones that the host might
be in. This column only applies to IPSEC tunnels where it enables be in. This column only applies to IPSEC tunnels where it enables
ISAKMP traffic to flow through the tunnel to the remote ISAKMP traffic to flow through the tunnel to the remote
gateway.</para> gateway(s).</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>

View File

@@ -283,14 +283,14 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">AUTO_COMMENT=</emphasis>[<emphasis <term><emphasis role="bold">AUTOCOMMENT=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term> role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
<listitem> <listitem>
<para>If set, if there is not a current comment when a macro is <para>Formerly named AUTO_COMMENT. If set, if there is not a current
invoked, the behavior is as if the first line of the macro file was comment when a macro is invoked, the behavior is as if the first
"COMMENT &lt;macro name&gt;". The AUTO_COMMENT option has a default line of the macro file was "COMMENT &lt;macro name&gt;". The
value of 'Yes'.</para> AUTO_COMMENT option has a default value of 'Yes'.</para>
<para>The setting of the AUTOMAKE option is ignored if the <para>The setting of the AUTOMAKE option is ignored if the
<command>start</command> or <command>restart</command> command <command>start</command> or <command>restart</command> command
@@ -299,6 +299,49 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis role="bold">AUTOHELPERS=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
<listitem>
<para>Added in Shorewall 4.5.7. When set to <option>Yes</option>
(the default), the generated ruleset will automatically associate
helpers with applications that require them (FTP, IRC, etc.). When
configuring your firewall on systems running kernel 3.5 or later, it
is recommended that you:</para>
<orderedlist>
<listitem>
<para>Set AUTOHELPERS=No.</para>
</listitem>
<listitem>
<para>Either:</para>
<orderedlist numeration="loweralpha">
<listitem>
<para>Modify <ulink
url="shorewall-conntrack.html">shorewall-conntrack</ulink>
(5) to only apply helpers where they are required; or</para>
</listitem>
<listitem>
<para>Specify the appropriate helper in the HELPER column in
<ulink url="shorewall-rules.html">shorewall-rules</ulink>
(5).</para>
<note>
<para>The macros for those applications requiring a helper
automatically specify the appropriate HELPER where
required.</para>
</note>
</listitem>
</orderedlist>
</listitem>
</orderedlist>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">AUTOMAKE=</emphasis>[<emphasis <term><emphasis role="bold">AUTOMAKE=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term> role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
@@ -669,6 +712,81 @@ net all DROP info</programlisting>then the chain name is 'net2all'
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis
role="bold">GEOIPDIR</emphasis>=[<emphasis>pathname</emphasis>]</term>
<listitem>
<para>Added in Shorewall 4.5.4. Specifies the pathname of the
directory containing the <firstterm>GeoIP Match</firstterm>
database. See <ulink
url="http://www.shorewall.net/ISOCODES.html">http://www.shorewall.net/ISOCODES.html</ulink>.
If not specified, the default value is
<filename>/usr/share/xt_geoip/LE</filename> which is the default
location of the little-endian database.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">HELPERS</emphasis>=[<emphasis>helper</emphasis>[,<replaceable>helper</replaceable>...]]</term>
<listitem>
<para>Added in Shorewall 4.5.7. This option lists the Netfilter
application helps that are to be enabled. If not specified, the
default is to enable all helpers.</para>
<para>Possible values for <replaceable>helper</replaceable>
are:</para>
<itemizedlist>
<listitem>
<para>amanda</para>
</listitem>
<listitem>
<para>ftp</para>
</listitem>
<listitem>
<para>h323</para>
</listitem>
<listitem>
<para>irc</para>
</listitem>
<listitem>
<para>netbios-ns</para>
</listitem>
<listitem>
<para>pptp</para>
</listitem>
<listitem>
<para>sane</para>
</listitem>
<listitem>
<para>sip</para>
</listitem>
<listitem>
<para>snmp</para>
</listitem>
<listitem>
<para>tftp</para>
</listitem>
</itemizedlist>
<para>When HELPERS is specified on a system running Kernel 3.5.0 or
later, automatic association of helpers to connections is
disabled.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">HIGH_ROUTE_MARKS=</emphasis>{<emphasis <term><emphasis role="bold">HIGH_ROUTE_MARKS=</emphasis>{<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>}</term> role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>}</term>
@@ -938,6 +1056,19 @@ net all DROP info</programlisting>then the chain name is 'net2all'
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis
role="bold">LOCKFILE</emphasis>=[<emphasis>pathname</emphasis>]</term>
<listitem>
<para>Specifies the name of the Shorewall lock file, used to prevent
simultaneous state-changing commands. If not specified,
${VARDIR}/shorewall/lock is assumed (${VARDIR} is normally /var/lib
but can be changed when Shorewall-core is installed -- see the
output of <command>shorewall show vardir</command>).</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">LOG_MARTIANS=</emphasis>[<emphasis <term><emphasis role="bold">LOG_MARTIANS=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">Yes</emphasis>|<emphasis
@@ -1409,6 +1540,17 @@ net all DROP info</programlisting>then the chain name is 'net2all'
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis
role="bold">NFACCT=</emphasis>[<emphasis>pathname</emphasis>]</term>
<listitem>
<para>Added in Shorewall 4.5.7. Specifies the pathname of the nfacct
utiliity. If not specified, Shorewall will use the PATH settting to
find the program.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">NULL_ROUTE_RFC1918=</emphasis>[<emphasis <term><emphasis role="bold">NULL_ROUTE_RFC1918=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term> role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
@@ -1525,6 +1667,23 @@ net all DROP info</programlisting>then the chain name is 'net2all'
chain are appended to it.</para> chain are appended to it.</para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
<para>An additional optimization was added in Shorewall 4.5.4.
If the last rule in a chain is an unqualified jump to a simple
target, then all immediately preceding rules with the same
simple target are omitted.</para>
<para>For example, consider this chain:</para>
<programlisting> -A fw-net -p udp --dport 67:68 -j ACCEPT
-A fw-net -p udp --sport 1194 -j ACCEPT
-A fw-net -p 41 -j ACCEPT
-A fw-net -j ACCEPT
</programlisting>
<para>Since all of the rules are jumps to the simple target
ACCEPT, this chain is totally optimized away and jumps to the
chain are replace with jumps to ACCEPT.</para>
</listitem> </listitem>
<listitem> <listitem>
@@ -1834,6 +1993,33 @@ net all DROP info</programlisting>then the chain name is 'net2all'
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis role="bold">RPFILTER_DISPOSITION=</emphasis>[<emphasis
role="bold">DROP</emphasis>|<emphasis
role="bold">REJECT</emphasis>|A_DROP|A_REJECT]</term>
<listitem>
<para>Added in Shorewall 4.5.7. Determines the disposition of
packets entering from interfaces the <option>rpfilter</option>
option (see <ulink
url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5)).
Packets disposed of by this option are those whose response packets
would not be sent through the same interface receiving the
packet.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">RPFILTER_LOG_LEVEL=</emphasis><emphasis>log-level</emphasis></term>
<listitem>
<para>Added in shorewall 4.5.7. Determines the logging of packets
disposed via the RPFILTER_DISPOSITION. The default value is
<option>info</option>.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">SAVE_IPSETS=</emphasis>{<emphasis <term><emphasis role="bold">SAVE_IPSETS=</emphasis>{<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>}</term> role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>}</term>
@@ -1855,7 +2041,7 @@ net all DROP info</programlisting>then the chain name is 'net2all'
<listitem> <listitem>
<para>Added in Shorewall 4.4.20. Determines the disposition of <para>Added in Shorewall 4.4.20. Determines the disposition of
packets matching the <option>filter</option> option (see <ulink packets matching the <option>sfilter</option> option (see <ulink
url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5)) and url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5)) and
of <firstterm>hairpin</firstterm> packets on interfaces without the of <firstterm>hairpin</firstterm> packets on interfaces without the
<option>routeback</option> option.<footnote> <option>routeback</option> option.<footnote>
@@ -1871,7 +2057,7 @@ net all DROP info</programlisting>then the chain name is 'net2all'
<listitem> <listitem>
<para>Added on Shorewall 4.4.20. Determines the logging of packets <para>Added on Shorewall 4.4.20. Determines the logging of packets
matching the <option>filter</option> option (see <ulink matching the <option>sfilter</option> option (see <ulink
url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5)) and url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5)) and
of <firstterm>hairpin</firstterm> packets on interfaces without the of <firstterm>hairpin</firstterm> packets on interfaces without the
<option>routeback</option> option.<footnote> <option>routeback</option> option.<footnote>

View File

@@ -283,6 +283,8 @@
<arg><option>-r</option> <replaceable>root-user-name</replaceable></arg> <arg><option>-r</option> <replaceable>root-user-name</replaceable></arg>
<arg><option>-T</option></arg>
<arg><replaceable>directory</replaceable></arg> <arg><replaceable>directory</replaceable></arg>
<arg choice="plain"><replaceable>system</replaceable></arg> <arg choice="plain"><replaceable>system</replaceable></arg>
@@ -349,7 +351,9 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>refresh</option><arg <arg
choice="plain"><option>refresh</option><arg><option>-n</option></arg><arg><option>-d</option></arg><arg><option>-T</option></arg><arg>-<option>D</option>
<replaceable>directory</replaceable> </arg><arg
rep="repeat"><replaceable>chain</replaceable></arg></arg> rep="repeat"><replaceable>chain</replaceable></arg></arg>
</cmdsynopsis> </cmdsynopsis>
@@ -381,6 +385,8 @@
<arg><option>-r</option> <replaceable>root-user-name</replaceable></arg> <arg><option>-r</option> <replaceable>root-user-name</replaceable></arg>
<arg><option>-T</option></arg>
<arg><replaceable>directory</replaceable></arg> <arg><replaceable>directory</replaceable></arg>
<arg choice="plain"><replaceable>system</replaceable></arg> <arg choice="plain"><replaceable>system</replaceable></arg>
@@ -415,6 +421,8 @@
<arg><option>-c</option></arg> <arg><option>-c</option></arg>
<arg><option>-T</option></arg>
<arg><replaceable>directory</replaceable></arg> <arg><replaceable>directory</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
@@ -599,6 +607,8 @@
<arg><option>-c</option></arg> <arg><option>-c</option></arg>
<arg><option>-T</option></arg>
<arg><replaceable>directory</replaceable></arg> <arg><replaceable>directory</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
@@ -1038,6 +1048,10 @@
<para>If <option>-r</option> is included, it specifies that the root <para>If <option>-r</option> is included, it specifies that the root
user on <replaceable>system</replaceable> is named user on <replaceable>system</replaceable> is named
<replaceable>root-user-name</replaceable> rather than "root".</para> <replaceable>root-user-name</replaceable> rather than "root".</para>
<para>The <option>-T</option> option was added in Shorewall 4.5.3
and causes a Perl stack trace to be included with each
compiler-generated error and warning message.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -1113,6 +1127,20 @@
list or until an entry in the list names another table. Built-in list or until an entry in the list names another table. Built-in
chains such as FORWARD may not be refreshed.</para> chains such as FORWARD may not be refreshed.</para>
<para>The <option>-n</option> option was added in Shorewall 4.5.3
causes Shorewall to avoid updating the routing table(s).</para>
<para>The <option>-d </option>option was added in Shorewall 4.5.3
causes the compiler to run under the Perl debugger.</para>
<para>The <option>-T</option> option was added in Shorewall 4.5.3
and causes a Perl stack trace to be included with each
compiler-generated error and warning message.</para>
<para>The -<option>D</option> option was added in Shorewall 4.5.3
and causes Shorewall to look in the given
<emphasis>directory</emphasis> first for configuration files.</para>
<para>Example:<programlisting><command>shorewall refresh net2fw nat:net_dnat</command> #Refresh the 'net2loc' chain in the filter table and the 'net_dnat' chain in the nat table</programlisting></para> <para>Example:<programlisting><command>shorewall refresh net2fw nat:net_dnat</command> #Refresh the 'net2loc' chain in the filter table and the 'net_dnat' chain in the nat table</programlisting></para>
<para>The <emphasis role="bold">refresh</emphasis> command has <para>The <emphasis role="bold">refresh</emphasis> command has
@@ -1166,6 +1194,10 @@
<para>If <option>-r</option> is included, it specifies that the root <para>If <option>-r</option> is included, it specifies that the root
user on <replaceable>system</replaceable> is named user on <replaceable>system</replaceable> is named
<replaceable>root-user-name</replaceable> rather than "root".</para> <replaceable>root-user-name</replaceable> rather than "root".</para>
<para>The <option>-T</option> option was added in Shorewall 4.5.3
and causes a Perl stack trace to be included with each
compiler-generated error and warning message.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -1210,6 +1242,10 @@
url="shorewall.conf.html">shorewall.conf</ulink>(5). When both url="shorewall.conf.html">shorewall.conf</ulink>(5). When both
<option>-f</option> and <option>-c</option>are present, the result <option>-f</option> and <option>-c</option>are present, the result
is determined by the option that appears last.</para> is determined by the option that appears last.</para>
<para>The <option>-T</option> option was added in Shorewall 4.5.3
and causes a Perl stack trace to be included with each
compiler-generated error and warning message.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -1541,6 +1577,10 @@
url="shorewall.conf.html">shorewall.conf</ulink>(5). When both url="shorewall.conf.html">shorewall.conf</ulink>(5). When both
<option>-f</option> and <option>-c</option>are present, the result <option>-f</option> and <option>-c</option>are present, the result
is determined by the option that appears last.</para> is determined by the option that appears last.</para>
<para>The <option>-T</option> option was added in Shorewall 4.5.3
and causes a Perl stack trace to be included with each
compiler-generated error and warning message.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -45,17 +45,22 @@
# used during firewall compilation, then the generated firewall program will likewise not # used during firewall compilation, then the generated firewall program will likewise not
# require Shorewall to be installed. # require Shorewall to be installed.
SHAREDIR=/usr/share/shorewall6-lite g_program=shorewall6-lite
VARDIR=/var/lib/shorewall6-lite
CONFDIR=/etc/shorewall6-lite
g_product="Shorewall6 Lite"
g_family=6
g_base=shorewall6
g_basedir=/usr/share/shorewall6-lite
. /usr/share/shorewall6-lite/lib.base #
. /usr/share/shorewall6/lib.cli # This is modified by the installer when ${SHAREDIR} != /usr/share
. /usr/share/shorewall6-lite/configpath #
. /usr/share/shorewall/shorewallrc
g_libexec="$LIBEXECDIR"
g_sharedir="$SHAREDIR"/shorewall6-lite
g_sbindir="$SBINDIR"
g_vardir="$VARDIR"
g_confdir="$CONFDIR"/shorewall6-lite
g_readrc=1
. ${SHAREDIR}/shorewall/lib.cli
. ${SHAREDIR}/shorewall-lite/configpath
[ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin [ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin

View File

@@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be author's reputation will not be affected by problems that might be
introduced by others. introduced by others.
Finally, software patents pose a constant threat to the existence of Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a effectively restrict the users of a free program by obtaining a
@@ -111,7 +111,7 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The "work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must former contains code derived from the library, whereas the latter must
be combined with the library in order to run. be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@@ -158,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy, You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a and you may at your option offer warranty protection in exchange for a
fee. fee.
2. You may modify your copy or copies of the Library or any portion 2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1 distribute such modifications or work under the terms of Section 1
@@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in that version instead if you wish.) Do not make any other change in
these notices. these notices.
Once this change is made in a given copy, it is irreversible for Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy. subsequent copies and derivative works made from that copy.
@@ -267,7 +267,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6. distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6, Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself. whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or 6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work work containing portions of the Library, and distribute that work
@@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you use both them and the Library together in an executable that you
distribute. distribute.
7. You may place library facilities that are a work based on the 7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined facilities not covered by this License, and distribute such a combined
@@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein. restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with You are not responsible for enforcing compliance by third parties with
this License. this License.
11. If, as a consequence of a court judgment or allegation of patent 11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or conditions are imposed on you (whether by court order, agreement or
@@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by license version number, you may choose any version ever published by
the Free Software Foundation. the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free 14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these, programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is write to the author to ask for permission. For software which is
@@ -456,7 +456,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES. DAMAGES.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest If you develop a new library, and you want it to be of the greatest

Some files were not shown because too many files have changed in this diff Show More