Compare commits

...

185 Commits

Author SHA1 Message Date
Tom Eastep
34f2aeacea Correct 'sed' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-22 09:59:30 -07:00
Tom Eastep
b160845713 Avoid compiler crash when LOAD_HELPERS_ONLY=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-20 15:22:43 -07:00
Tom Eastep
b44628ddc8 Only specify 'counters' to ipset of IPSET_MATCH_COUNTERS is present
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-20 09:07:36 -07:00
Tom Eastep
31b6e9e299 Fix another DEST bug in mangle inline action handling :-(
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-18 10:15:43 -07:00
Tom Eastep
9fc56bb896 Correct typo in process_mangle_inline()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-17 09:29:32 -07:00
Tom Eastep
2c191bf595 Correct .conf manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-16 15:07:34 -07:00
Tom Eastep
4bb942f1f9 Restrict hypen as range separator to use with integers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-16 13:29:00 -07:00
Tom Eastep
04051454bf Reverse bad ECN handling patch
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-16 12:27:45 -07:00
Tom Eastep
e6f3d429a1 Renew timeout on matched dbl entries
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-16 09:42:45 -07:00
Tom Eastep
fad9dce3e6 Correct handling of ECN file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-16 08:33:01 -07:00
Tom Eastep
342f4ee0f2 Add the --exits option to ADD with timeout
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-15 16:43:44 -07:00
Tom Eastep
28849e60cf Correct example in the shorewall6-masq manpage
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-14 15:55:36 -07:00
Tom Eastep
b5906812a2 Accept '-' as the separator in a port range.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-14 10:10:03 -07:00
Tom Eastep
289825a76f Update to logging article
- correct a typo
- recommend using NFLOG rather than ULOG
2016-10-12 10:02:59 -07:00
Tom Eastep
b80d4c2320 Don't allow shell meta characters in interface names
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-11 17:01:45 -07:00
Tom Eastep
d5aaa66e0b Detect bad characters in interface names
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-11 10:56:41 -07:00
Tom Eastep
49fae96b09 Update the manpages for 'blacklist' verbosity
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-10 19:45:42 -07:00
Tom Eastep
b3e59322b6 Clean up the output of 'blacklist'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-10 13:26:01 -07:00
Tom Eastep
8c522a5c4d Correct typo in lib.private
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-09 10:58:29 -07:00
Tom Eastep
abf57a4d1f Correct indentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-09 09:29:04 -07:00
Tom Eastep
3058f2fb84 Delete code supporting old kernel/iproute2 IPv6 restrictions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-07 11:02:36 -07:00
Tom Eastep
0bf5ca7e0c Rename lsm->foolsm in MultiISP article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-07 08:01:11 -07:00
Tom Eastep
b5e7e41708 Correct NFQUEUE! manpage description
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-07 05:50:24 -07:00
Tom Eastep
eb6ae5e186 Correct handling of DYNAMIC_BLACKLIST options
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-05 16:56:29 -07:00
Tom Eastep
941604ad01 Correct issue with updating DBL timeout
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-05 15:41:40 -07:00
Tom Eastep
14e8568d9e Add the FIREWALL .conf option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-05 15:03:54 -07:00
Tom Eastep
ca7ca4bdfe Add a 'timeout' option to DYNAMIC_BLACKLIST
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-05 12:56:47 -07:00
Tom Eastep
c19e732e42 Correct typo
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-04 10:00:00 -07:00
Tom Eastep
8d731c81e4 Add 'disconnect' option to ipset-based dynamic blacklisting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-04 09:09:45 -07:00
Tom Eastep
6ad7d47eb6 Correct DYNAMIC_BLACKLISTING documentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-03 08:19:19 -07:00
Tom Eastep
ed48eed0c6 Change order of options in .conf files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-02 15:14:31 -07:00
Tom Eastep
97186e5402 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2016-10-02 14:04:02 -07:00
Roberto C. Sánchez
64ab43f14f Fix typos 2016-10-02 17:01:46 -04:00
Tom Eastep
36cd8d28a7 Merge branch '5.0.12' 2016-10-02 08:04:54 -07:00
Tom Eastep
1b032f7524 Correct permissions of files created by the 'save' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-01 13:49:35 -07:00
Tom Eastep
641a7146ca Merge branch '5.0.12'
Conflicts:
	Shorewall/Perl/lib.runtime

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-01 09:59:15 -07:00
Tom Eastep
72dbb4c3c3 Handle persistent provider enable/disable correctly
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-30 16:01:04 -07:00
Tom Eastep
bc591ccee4 Don't assume that statistically balanced providers are optional
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-30 14:01:16 -07:00
Tom Eastep
c7e403bad0 Don't assume that statistical provider interfaces are optional
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-30 13:37:58 -07:00
Tom Eastep
f989c2f5f6 Document 'persistent'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-30 11:34:57 -07:00
Tom Eastep
156313edd2 Correctly handle down persistent interface during 'disable'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-27 11:47:37 -07:00
Tom Eastep
35bd1db7fb Handle Down or missing interfaces in 'delete_gateway()'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-27 11:43:26 -07:00
Tom Eastep
792b3b696c Add ZERO_MARKS option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-26 16:04:26 -07:00
Tom Eastep
3f8ddb11ab Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2016-09-25 08:00:43 -07:00
Tom Eastep
fa9ee6d69e Clear packet marks in PREROUTING and OUTPUT
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-24 15:46:04 -07:00
Tom Eastep
0f287dfe60 Add 'reload' to config basic document as appropriate
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-24 08:05:47 -07:00
Tom Eastep
ef4b1c2030 Add a TIME Columns section to the config file basics doc
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-22 15:45:18 -07:00
Tom Eastep
8065e62f12 Support for the 'contiguous' option in TIME columns
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-22 14:22:11 -07:00
Tom Eastep
e81a4788c6 Implement DEFAULT_PAGER in shorewallrc
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-21 10:20:48 -07:00
Tom Eastep
d854185c56 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2016-09-20 08:47:07 -07:00
Tom Eastep
afc212495f Make POSTROUTING the default chain for CHECKSUM
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-18 08:57:49 -07:00
Tom Eastep
059b1c6c8c Remove superfluous logic
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-13 11:13:19 -07:00
Tom Eastep
2f75901068 Restore 'use Shorewall::Config(shorewall)' in embedded Perl handling
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-13 09:29:51 -07:00
Tom Eastep
8bb7c2363b Support '+' after a zone list in the policy files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-10 10:06:38 -07:00
Tom Eastep
7e32a10176 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2016-09-10 08:48:48 -07:00
Tom Eastep
2c90a8bfb5 Allow zone lists in the SOURCE and DEST columns of the policy files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-10 08:47:48 -07:00
Tom Eastep
5ea91f21f4 Correct the mangle manpage
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-05 19:20:25 -07:00
Tom Eastep
3954636fb5 Document 'comment' in the alternate input format
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-09-01 14:46:54 -07:00
Tom Eastep
bb8af36d3f Minor cleanup in the Rules module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-08-31 13:01:49 -07:00
Tom Eastep
4ec2c2087d Delete obsolete comments
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-08-29 12:40:28 -07:00
Tom Eastep
a05b957498 Corrections in the shorewall[6].conf manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-08-15 10:24:23 -07:00
Tom Eastep
31d35e0cbd Minor cleanup of the Chains module
- Correct typos
- Correct 'P' trace entries
- Add parens and comments to calls

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-08-15 09:22:11 -07:00
Tom Eastep
bcacce7ed0 Rename a variable to avoid confusion
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-08-14 15:45:24 -07:00
Tom Eastep
646c20491a Fix indentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-08-14 15:45:00 -07:00
Tom Eastep
fa1173baaa Correct typo in a comment
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-08-14 10:24:29 -07:00
Tom Eastep
72e21be89d Add a handle back to the flow classifier
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-08-04 11:03:36 -07:00
Tom Eastep
1b1e2c58f9 Allow optional provider interfaces to match a wildcard
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-08-02 15:44:19 -07:00
Tom Eastep
d3591c071d Correct dump instructions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-08-02 09:23:49 -07:00
Tom Eastep
decf9d3b3e Correct comment formatting in 'trace' output
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-07-30 09:03:19 -07:00
Tom Eastep
a05623f49e Don't delete duplicate COUNT rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-07-30 08:24:53 -07:00
Tom Eastep
0b9cd93769 Default DSCP rules to the POSTROUTING chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-07-27 13:59:15 -07:00
Tom Eastep
d9e992b164 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code
Conflicts:
	Shorewall/Perl/Shorewall/Config.pm
2016-07-25 07:33:04 -07:00
Tom Eastep
372359839b Add 'comment' to alternative input
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-07-24 15:08:55 -07:00
Tom Eastep
40dea5f597 Add 'comment' to alternative input
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-07-19 15:43:40 -07:00
Tom Eastep
4a6338d857 Correct/complete Scott Sumate's LOGFILE enhancement
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-07-15 14:25:02 -07:00
Scott Shumate
55ee0113ea Added support for systemd logging by configuring LOGFILE=systemd 2016-07-15 13:40:23 -05:00
Tom Eastep
65d5249bd8 Link to Digimer's article on Shorewall/REL7
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-07-07 12:44:28 -07:00
Roberto C. Sánchez
0364c15be1 Fix typos, thanks to Marco Di Cerbo for reporting them 2016-07-06 08:46:32 -04:00
Roberto C. Sánchez
76b2b0de78 Debian init script: fix name of force-reload target (Closes: #830110) 2016-07-06 08:43:21 -04:00
Roberto C. Sánchez
7c9876241c Debian init scripts: add run-level 1 to Default-Stop specification 2016-07-04 17:37:00 -04:00
Roberto C. Sánchez
8b36c2c1cf Debian init scripts: more accurately describe what action is being taken 2016-07-04 13:34:33 -04:00
Tom Eastep
a02c745a83 Avoid silly duplicate rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-30 17:49:43 -07:00
Tom Eastep
094fd8129c Update copyright and version info in the config basics doc
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-25 12:11:34 -07:00
Tom Eastep
544be8c937 Change SuSE shorewallrc to use systemd
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-21 13:50:10 -07:00
Tom Eastep
47557aa4f7 Correct additional issues with 'update'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-18 10:24:52 -07:00
Tom Eastep
93ee4432de Allow <user>: in USER columns
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-18 09:44:35 -07:00
Tom Eastep
8c543ca6f8 Transfer permissions during file updates
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-16 16:04:32 -07:00
Tom Eastep
e71fb3249a Add 'dbl' interface option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-15 16:35:41 -07:00
Tom Eastep
56b6db1a3d Make the allow command work with both ipset and chain dynamic blacklisting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-14 13:42:20 -07:00
Tom Eastep
ea56d4ed19 Make ipset-based dynamic blacklisting work in the FORWARD chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-13 15:02:12 -07:00
Tom Eastep
c65721a139 Correct a warning message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-13 12:21:16 -07:00
Tom Eastep
f979ccb16d Merge branch '5.0.9' 2016-06-09 14:47:44 -07:00
Tom Eastep
24b396bc67 Avoid run-time Perl diagnostic when validating a null log level
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-09 09:12:13 -07:00
Tom Eastep
cd0837beb5 Avoid run-time Perl diagnostic when validating a null log level
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-09 09:00:12 -07:00
Tom Eastep
4869f61a25 'allow' now works with ipset-based dynamic blacklisting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-09 08:44:25 -07:00
Tom Eastep
6eb8416c2b Don't link SysV init script if $SERVICEDIR is given on Debian.
- Fixes issue with package build environment.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-08 15:56:56 -07:00
Matt Darfeuille
0925636995 (Fwd) [Shorewall-users] Shorewall-lite on OpenWRT
On 7 Jun 2016 at 8:21, Tom Eastep wrote:

> On 06/07/2016 06:40 AM, Matt Darfeuille wrote:
> > On 5 Jun 2016 at 12:53, Tom Eastep wrote:
> >
> >> On 06/05/2016 12:33 PM, Matt Darfeuille wrote:
> >>> On 5 Jun 2016 at 7:57, Tom Eastep wrote:
> >>>
> >>>> On 05/29/2016 02:00 AM, Matt Darfeuille wrote:
> >>>>
> >>>> Hi Matt,
> >>>>
> >>>>>
> >>>>> -------------- Enclosure number 1 ----------------
> >>>>> >From 6ff651108df33ab8be4562caef03a8582e9eac5e Mon Sep 17 00:00:00 2001
> >>>>> From: Matt Darfeuille <matdarf@gmail.com>
> >>>>> Date: Tue, 24 May 2016 13:10:28 +0200
> >>>>> Subject: [PATCH 1/8] Emulate 'ps -p' using grep to work on openwrt
> >>>>>
> >>>>> Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
> >>>>> ---
> >>>>>  Shorewall-core/lib.common | 2 +-
> >>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>>
> >>>>> diff --git a/Shorewall-core/lib.common b/Shorewall-core/lib.common
> >>>>> index 03ecb2a..fcb02ee 100644
> >>>>> --- a/Shorewall-core/lib.common
> >>>>> +++ b/Shorewall-core/lib.common
> >>>>> @@ -776,7 +776,7 @@ mutex_on()
> >>>>>  		error_message "WARNING: Stale lockfile ${lockf} removed"
> >>>>>  	    elif [ $lockpid -eq $$ ]; then
> >>>>>                  return 0
> >>>>> -	    elif ! qt ps p ${lockpid}; then
> >>>>> +	    elif ! qt ps | grep -v grep | grep ${lockpid}; then
> >>>>
> >>>> I don't see how this can work -- 'qt ps' will produce no output yet the
> >>>> code pipes into tandem greps.
> >>>>
> >>>> Do you really want this instead?
> >>>>
> >>>> elif ! ps | grep -v grep | qt grep ${lockpid}; then
> >>>>
> >>>
> >>> Oops sorry Tom, that's what I meant(do you want the corrected
> >>> patch?)!
> >>
> >> Yes, please.
> >>
> >
> > Tom, along with correcting this faulty commit I realize, after some
> > more testing, that I've also sent unnecessary commits.
> >
> > Should I revert these 3 commits(git revert ...):
> > Set proper permissions for the LOCKFILE on openwrt
> > 2ded346cb557212389212fd5adcd4c6800edbb62
> > Create lockfile before using openwrt's lock utility
> > 08e8796ff1abc3b24b8bbd40bf5e0a2b36464d61
> > Emulate 'ps -p' using grep to work on openwrt
> > 6ff651108df33ab8be4562caef03a8582e9eac5e
> >
> > or should I simply create new commits that will correct these faulty
> > commits?
> >
> > In other words what's the best way to correct submited commits.
> >
>
> Matt,
>
> Either way is fine.
>

Hopefully these 3 commits will do it(code-fixes.patch):

Patch 1 will correct the error you have point out!
On OpenWRT the lock utility doesn't allow to append the pid of the
currently running script to the LOCKFILE that's why I've simply
deleted that line(patch 2).
I've also reordered the permissions line to be added after the line
that will lock the file specified by the LOCKFILE variable(patch 3).

and two other patches:
While installing shorewall-init using the DESTDIR variable on debian,
'mkdir' would complain if the directory ${DESTDIR}/${etc}/default
already exist; corrected using 'mkdir -p ...'(patch 4).
The last patch will correct a typo in the blacklisting_support
article.

-Matt

-------------- Enclosure number 1 ----------------
>From 1a2ff15c8dc994030e819d2882570d188b99c501 Mon Sep 17 00:00:00 2001
From: Matt Darfeuille <matdarf@gmail.com>
Date: Wed, 8 Jun 2016 09:09:46 +0200
Subject: [PATCH 1/5] Correct pid detection mutex_on()

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-08 15:40:48 -07:00
Matt Darfeuille
cd4e9654d8 (Fwd) [Shorewall-users] Shorewall-lite on OpenWRT
------- Forwarded message follows -------
From:	istvan@istvan.org
To:	shorewall-users@lists.sourceforge.net
Date sent:	Thu, 19 May 2016 09:10:21 +0200
Subject:	[Shorewall-users] Shorewall-lite on OpenWRT
Send reply to:	Shorewall Users <shorewall-users@lists.sourceforge.net>
	<mailto:shorewall-users-request@lists.sourceforge.net?subject=unsubscribe>
	<mailto:shorewall-users-request@lists.sourceforge.net?subject=subscribe>

Hi there,

I use Shorewall on an OpenWRT distribution and I experience 2
problems.
I have solved them myself and report them here to help others with
it.

Shorewall version: shorewall[6]-lite 5.0.4
OpenWRT version: Chaos Calmer 15.05, r46767

Problem 1:
Shorewall uses the lock utility from openwrt. I believe it is used in

the wrong way. File lib.common line 775
First it passes arguments which the utility doesn't use/know. The
util
accepts them dumbly and continues to create a lockfile. It has no
time-out functionality. I do not know the meaning of the r1 argument.
Second the mutex_off simply deletes the lockfile by using the utility

rm. This way a stale lock process keeps running. After a while the
router is running a high number of stale processes which has impact
on
the load of the router. The correct way is to use "lock -u
/lib/shorewall-lite/lock". This way the lockfile will be removed and
the
process will be terminated accordingly. To make it work for me, I no
more let shorewall use the lock utility by using an ugly hack.

Problem 2:
An fgrep on the output of the type utility is wrongly coded. The
output
of the type command probably has been changed. File lib.cli line 4343
It is coded: "if type $1 2> /dev/null | fgrep -q 'is a function';
then"
To make it work for me, it should be coded: "if type $1 2> /dev/null
|
fgrep -q 'is a shell function'; then"

With regards,

Stefan
------- End of forwarded message -------

Tom, attached as code.patch, are the patches that I  believe will
correct those issues

In addition to those patches I've also added 3 patches:
- Patch 1 will emulate the -p flag of the ps utility which is not
available on openwrt.
- The last two patches will add "file" to the progress message of
SYSCONFFILE to make it more consistent among the installers.

In shorewall-init/install.sh the else clause between  the line 586
and 597 will only work for a sysvinit script.
Should I make it also work for a systemd service script or can't we
simply remove that else clause?

In the compiled firewall script the comments before and after the
functions imported from lib.common have two slashes in the path:
$ grep -H lib.common firewall
firewall:#   Functions imported from /usr/share/shorewall//lib.common
firewall:#   End of imports from /usr/share/shorewall//lib.common

-Matt

-------------- Enclosure number 1 ----------------
>From 6ff651108df33ab8be4562caef03a8582e9eac5e Mon Sep 17 00:00:00 2001
From: Matt Darfeuille <matdarf@gmail.com>
Date: Tue, 24 May 2016 13:10:28 +0200
Subject: [PATCH 1/8] Emulate 'ps -p' using grep to work on openwrt

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-08 15:40:36 -07:00
Tom Eastep
cd01df4200 Allow more than 9 interfaces with Simple TC
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-06-07 14:43:37 -07:00
Tom Eastep
7798c52a19 Fix DOCKER=Yes when docker0 is defined and Docker isn't started.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-22 17:50:51 -07:00
Tom Eastep
2809d6896c Clarify dynamic sub-zones
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-18 08:20:23 -07:00
Tom Eastep
1d066bdfa4 Minor updates to the Shorewall 5 article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-18 08:19:47 -07:00
Tom Eastep
9b7088158b Correct ipv6-route header number
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-10 07:12:01 -07:00
Tom Eastep
625d763372 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code
Conflicts:
	Shorewall/Perl/Shorewall/Config.pm
2016-05-07 13:50:01 -07:00
Tom Eastep
82169a0bfd Use 'date' format for compiletime rather than localtime format
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-07 13:48:16 -07:00
Tom Eastep
0d16b2820a Use 'date' format for compiletime rather than localtime format
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-06 13:28:22 -07:00
Tom Eastep
d4df67966d Turn on AUTOMAKE in the sample configurations
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-06 08:46:11 -07:00
Tom Eastep
f16bb887f3 Report versions as Shorewall's rather than Shorewall6's
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-05 15:41:46 -07:00
Tom Eastep
64fb662bb1 Verify Shorewall6 version when compiling for IPv6
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-05 15:22:47 -07:00
Tom Eastep
ce20e5592b Cross-check core and standard versions during compilation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-05 13:53:26 -07:00
Tom Eastep
590243a787 Add NFLOG as a supported mangle action
- Also document nflog-parameters
- Correct range of nflog groups

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-03 11:27:34 -07:00
Tom Eastep
9dd0346987 Apply Paul Gear's patch for Ubuntu 16.04
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-05-02 07:25:37 -07:00
Tom Eastep
ccfa181a6d Tweak compile_info_command()
- Fix comment
- use $globals{VERSION} for the version number

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-30 14:12:34 -07:00
Tom Eastep
d959fd4445 Fix link
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-30 08:37:20 -07:00
Tom Eastep
b7de785396 Correct typo in manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-30 08:34:43 -07:00
Tom Eastep
24d40f4cc2 Add VERBOSE_MESSAGES option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-30 08:00:56 -07:00
Tom Eastep
244f2cefe5 Update comment describing info_command()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-29 15:42:48 -07:00
Tom Eastep
ec23ca67f8 Remove the parentheses from around the start/stop time
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-29 15:32:17 -07:00
Tom Eastep
a2345325dd Move show_status() to before its first reference
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-29 15:31:55 -07:00
Tom Eastep
1308560aba Display compilation date/time in 'status -a' output
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-29 14:12:53 -07:00
Tom Eastep
41923cb80e Improve compile time/date implementation
- Rename the command from 'date' to 'info'
- Return the complete date/time/version string in the command

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-29 12:31:17 -07:00
Tom Eastep
2a40012fc4 Include compile time and date in the output of 'shorewall status'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-27 16:25:21 -07:00
Matt Darfeuille
05a15c6f8b patches and request
Tom,

Some patches for the trunk repo(fixes.patch):

Patch1: Fix a typo in the path being printed for the standard actions
file.
Patch2: Will only install the shorewall's manpages if the variable
MANDIR is none-empty(I did it only for the sake of completeness)!
Patch3: Will only install the shorewall-lite's manpages if the
variable MANDIR is none-empty.
Patch4: Correct multiple product name's typos in
shorewall-init/install.sh.
Patch5: Remove ~/.shorewallrc when shorewall-core is uninstalled.

And two other  patches for the release repo(changelog-1.patch):

Patch1: Changed restart to reload for the line: 'Update DHCP
article(refresh -> restart).
Patch2: Rephrased the line for the newly added ?WARNING and ?INFO
directives.

Request:
Could the date of the compiled firewall script also be displayed when
'shorewall status' is executed?

-Matt

-------------- Enclosure number 2 ----------------
>From a5ae24bbe9b25aefdbcc4d7c8e5d013a36b03078 Mon Sep 17 00:00:00 2001
From: Matt Darfeuille <matdarf@gmail.com>
Date: Sat, 23 Apr 2016 14:44:19 +0200
Subject: [PATCH 1/5] Fix typo in printed path for standard actions file

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-27 15:07:44 -07:00
Tom Eastep
a92d10f19c Merge branch '5.0.8' 2016-04-27 10:23:51 -07:00
Tom Eastep
47edfaf093 Create standard error messages in the CLI
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-27 10:13:24 -07:00
Tom Eastep
67c2587890 Correct typos in the Events article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-25 16:09:10 -07:00
Tom Eastep
f6b7eb4ea0 Correct handling of persistent provider with no IP address
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-25 12:27:00 -07:00
Tom Eastep
200ad3f874 Correct typos in the Events article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-25 09:00:45 -07:00
Tom Eastep
800c06e8c9 Rename lib.core to lib.runtime
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-21 08:12:41 -07:00
Tom Eastep
f16e3f1fbe Issue warning when enable/disable won't work correctly
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-19 10:42:50 -07:00
Tom Eastep
71bd7a4647 Update the STARTUP_LOG description in shorewall[6].conf
- Update list of commands

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-19 07:49:37 -07:00
Tom Eastep
ab95607f5f Document ?WARNING and ?INFO
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-18 14:47:08 -07:00
Tom Eastep
f9bbca8b05 Expand the list of commands that write to STARTUP_LOG
- add the safe-* commands

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-18 14:16:13 -07:00
Tom Eastep
0faf3b6db1 Send INFO messages to STDERR rather than STDOUT 2016-04-18 13:59:29 -07:00
Tom Eastep
3253c882e9 Merge branch '5.0.8' 2016-04-18 12:36:28 -07:00
Tom Eastep
5212dba7cb Add an ESTABLISHED,RELATED rule for docker0
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-18 10:13:05 -07:00
Tom Eastep
35a22eedac Reword error message when tcclass MARK is too large
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-18 10:06:04 -07:00
Tom Eastep
2b7ef0fe32 Update the tcclasses manpage to discuss fw mark filter priority
- Also correct default priorities for tos= and tcp-ack

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-18 09:18:48 -07:00
Tom Eastep
b53de922d1 Catch 0 in the MARK column of the tcclasses file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-18 08:50:10 -07:00
Matt Darfeuille
365ffaf645 questions
On 17 Apr 2016 at 7:45, Tom Eastep wrote:

> On 04/17/2016 06:23 AM, Matt Darfeuille wrote:
>
> >> Tom, I neglected the git part of that request!(sorry):
> >>
> >> Could changes be also made in the git code repo that take for account
> >> case insensitive system?:
> >>
> >> What I suggest doing is using the deprecated extension when the case
> >> of a file is changed in the code so git wouldn't show 'Modified: ...'
> >> and simply modifying shorewall/install.sh to strip the file from the
> >> deprecated extension and then copying it to the deprecated directory.
> >>
> >> In other words: when changing the case of a file tracked by git could
> >> case-insensitivity platform be taken in to account?
> >>
> >> -Matt
> >>
> >> P.S. I'll test SW_LOGGERTAG tomorrow!!!:)
> >
> > Or do you have a better solution, if no, I could do the changes to
> > shorewall/install.sh!?
>
> Sure -- go ahead. We'll do it in the master branch, though, since I've
> now created a 5.0.8 branch for the upcoming release.
>
> >
> > You might want to apply the attached patch to changelog.txt in the
> > release repo!
> >
>
> Applied -- thanks!
>
> -Tom
> --
> Tom Eastep        \ When I die, I want to go like my Grandfather who
> Shoreline,         \ died peacefully in his sleep. Not screaming like
> Washington, USA     \ all of the passengers in his car
> http://shorewall.net \________________________________________________
>
>

Attached as case.patch are 3 patches:

1 and 2 simply rename the deprecated files(adding .deprecated)

Patch 3 will modify Shorewall/install.sh to reflect the new naming
scheme!

I didn't have the time to test SW_LOGGERTAG but will do so in the
coming days!!!:)

-Matt

-------------- Enclosure number 1 ----------------
From 2ecd761b414af61c5854d6427fb9ec8ab1365c7b Mon Sep 17 00:00:00 2001
From: Matt Darfeuille <matdarf@gmail.com>
Date: Sun, 17 Apr 2016 18:34:40 +0200
Subject: [PATCH 1/3] Rename macro.SNMPTrap to macro.SNMPTrap.deprecated

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-17 13:50:17 -07:00
Tom Eastep
ae852b513d Correct indentation issue
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-17 10:23:18 -07:00
Tom Eastep
9611b588e3 Use a uniform format for log timestamps
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-16 09:52:35 -07:00
Tom Eastep
eb95532248 Enable compiler logging on reload and restart
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-16 09:52:17 -07:00
Tom Eastep
fb8dbcf44b Use a uniform format for log timestamps
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-16 09:49:38 -07:00
Tom Eastep
62a14aab28 Enable compiler logging on reload and restart
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-16 09:37:42 -07:00
Tom Eastep
335f2968f8 Implement ?INFO and ?WARNING
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-16 09:20:09 -07:00
Tom Eastep
32f888a7d4 Add an ENVIRONMENT section to the CLI manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-15 15:41:55 -07:00
Tom Eastep
c725372639 Correct logging of 'reloaded' message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-15 14:46:21 -07:00
Tom Eastep
524838ae47 Implement $SW_LOGGERTAG
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-15 14:29:51 -07:00
Tom Eastep
549af8b402 Update config files where address and gateway variables can be used
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-15 10:51:39 -07:00
Tom Eastep
6aa0ecae4f Re-factor the code for saving/loading ipsets
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-14 15:15:47 -07:00
Tom Eastep
434e042494 Add the deprecated/ directories to the CONFIG_PATH
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-14 14:17:06 -07:00
Tom Eastep
9fa0df2fd1 Move the code that generates zap_ipsets() to after save_ipsets() generation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-14 09:56:48 -07:00
Tom Eastep
074655d1bd Fix AUTOMAKE and the start command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-14 09:43:21 -07:00
Tom Eastep
216bc715e8 Clean up V4/V5 ipset enforcement
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-14 09:00:38 -07:00
Tom Eastep
541ecb67b4 Update dhcp article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-13 17:36:56 -07:00
Tom Eastep
dbd42e1d5d More ipset fixes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-12 16:29:13 -07:00
Tom Eastep
04ec8273ef Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2016-04-12 07:13:29 -07:00
Tuomo Soini
772f88b1fd action.A_Reject: improve comment text
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2016-04-12 13:17:56 +03:00
Tuomo Soini
3e0b8c60a2 Reverse the order of ICMP and Broadcast checking in the default actions
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2016-04-12 10:12:29 +03:00
Tom Eastep
fc2b555cdb Correct date formatting in startup_error()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-11 15:24:35 -07:00
Tom Eastep
16afd880b2 Reverse the order of ICMP and Broadcast checking in the default actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-11 11:16:46 -07:00
Tom Eastep
76a5841fcd Reverse the order of Broadcast and ICMP checking in the default actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-11 10:47:11 -07:00
Tom Eastep
9758e8cdc5 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2016-04-11 10:41:44 -07:00
Tom Eastep
2cf3706864 Correct handling of a zone with two interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-11 10:32:26 -07:00
Tom Eastep
3028dafbac Correct DBL 'src-dst' handling
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-11 09:13:17 -07:00
Tom Eastep
16a31c3d29 Make MINIUPNPD work with DOCKER
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-11 09:02:44 -07:00
Tom Eastep
d3f377e915 Don't double-save the dynamic blacklisting ipset
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-11 08:37:39 -07:00
Tuomo Soini
54a5748395 macros: RedisCluster and RedisSentinel
http://redis.io/topics/sentinel

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2016-04-11 14:39:21 +03:00
Tom Eastep
6c00f72f44 Create ipsets with the 'counters' option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-10 18:09:41 -07:00
Tom Eastep
8dc88898c8 Tidy up the output of 'shorewall[6][-lite] show bl'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-10 17:22:22 -07:00
Tom Eastep
deaaecdf1c Add 'nodbl' interface option.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-10 16:09:39 -07:00
Tom Eastep
05e4049174 Ipset-based blacklisting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-10 16:07:56 -07:00
Tom Eastep
ef10515a42 Correct FASTACCEPT description
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-10 07:20:45 -07:00
Tom Eastep
5db6cb1b7d Correct load_ipsets()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-09 16:07:10 -07:00
Tom Eastep
76c8917aa7 Add a sixth parameter to Drop and Reject
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-08 09:10:45 -07:00
Tom Eastep
be58d530c4 Document 'logjump'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-08 09:09:59 -07:00
Tom Eastep
321476fd51 Tweak terminating() implementation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-08 08:24:57 -07:00
Tom Eastep
bd6b32eb25 Add a progress message for REJECT_ACTION processing
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-07 10:30:54 -07:00
Tom Eastep
4fdf54eca1 Tweak process_reject_action()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-07 10:02:48 -07:00
Tom Eastep
70bbd21b35 Ensure that the REJECT_ACTION is terminating
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-07 09:34:38 -07:00
Tom Eastep
87a9b95f73 Catch case where a transformed rule jumps to its own chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-07 08:58:50 -07:00
Tom Eastep
ecd7261365 Use -g when target is a terminating chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-07 08:48:36 -07:00
Tom Eastep
293cd1d66a Always go to the reject chain rather than jump to it
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-06 09:14:06 -07:00
Tom Eastep
436b5d89ce Correct comment
- The chain will only exist if logging wasn't specified for the same
  disposition.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-04-06 08:50:29 -07:00
89 changed files with 3396 additions and 1100 deletions

View File

@@ -235,7 +235,8 @@ for on in \
SPARSE \
ANNOTATED \
VARLIB \
VARDIR
VARDIR \
DEFAULT_PAGER
do
echo "$on=${options[${on}]}"
echo "$on=${options[${on}]}" >> shorewallrc

View File

@@ -209,7 +209,8 @@ for ( qw/ HOST
SPARSE
ANNOTATED
VARLIB
VARDIR / ) {
VARDIR
DEFAULT_PAGER / ) {
my $val = $options{$_} || '';

View File

@@ -191,6 +191,8 @@ setup_logread() {
else
g_logread="logread"
fi
elif [ "$LOGFILE" = "systemd" ]; then
g_logread="journalctl -r"
elif [ -r $LOGFILE ]; then
if qt mywhich tac; then
g_logread="tac $LOGFILE"
@@ -339,7 +341,15 @@ show_classifiers() {
#
# Display blacklist chains
#
blacklist_filter() {
awk \
'BEGIN { prnt=0; }; \
/^Members:/ { print "Dynamic:"; prnt=1; next; }; \
{ if (prnt == 1) print; };'
}
show_bl() {
[ -n "$g_blacklistipset" ] && ipset -L $g_blacklistipset | blacklist_filter && echo
$g_tool -L $g_ipt_options | \
awk 'BEGIN {prnt=0; };
/^$/ {if (prnt == 1) print ""; prnt=0; };
@@ -456,7 +466,8 @@ do_save() {
if $iptables_save | grep -v -- '-A dynamic.* -j ACCEPT' > ${VARDIR}/restore-$$; then
cp -f ${VARDIR}/firewall $g_restorepath
mv -f ${VARDIR}/restore-$$ ${g_restorepath}-iptables
chmod +x $g_restorepath
chmod 700 $g_restorepath
chmod 600 ${g_restorepath}-iptables
echo " Currently-running Configuration Saved to $g_restorepath"
run_user_exit save
else
@@ -477,6 +488,7 @@ do_save() {
if ${arptables}-save > ${VARDIR}/restore-$$; then
if grep -q '^-A' ${VARDIR}/restore-$$; then
mv -f ${VARDIR}/restore-$$ ${g_restorepath}-arptables
chmod 600 ${g_restorepath}-arptables
else
rm -f ${VARDIR}/restore-$$
fi
@@ -523,7 +535,7 @@ do_save() {
#
# Don't save an 'empty' file
#
grep -qE -- '^(-N|create )' ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${g_restorepath}-ipsets
grep -qE -- '^(-N|create )' ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${g_restorepath}-ipsets && chmod 600 ${g_restorepath}-ipsets
fi
fi
;;
@@ -723,12 +735,29 @@ list_zone() {
done
}
option_error() {
fatal_error "The $COMMAND command does not accept this option: -$1"
}
too_many_arguments() {
fatal_error "Too many arguments: $1"
}
missing_argument() {
fatal_error "Missing argument"
}
missing_option_value() {
fatal_error "The $1 option requires a value"
}
version_command() {
local finished
finished=0
local all
all=
local product
local compiletime
while [ $finished -eq 0 -a $# -gt 0 ]; do
option=$1
@@ -747,7 +776,7 @@ version_command() {
option=${option#a}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -759,7 +788,7 @@ version_command() {
esac
done
[ $# -gt 0 ] && usage 1
[ $# -gt 0 ] && too_many_arguments
if [ -n "$all" ]; then
echo "shorewall-core: $(cat ${SHAREDIR}/shorewall/coreversion)"
@@ -771,8 +800,16 @@ version_command() {
done
if [ "$(id -u)" -eq 0 -a -f $g_firewall ]; then
echo $g_echo_n "$g_firewall was compiled by Shorewall version "
$g_firewall version
compiletime=$(run_it $g_firewall info 2>/dev/null)
case $compiletime in
compiled\ *)
echo "$g_firewall was $compiletime"
;;
*)
echo "$g_firewall was compiled by Shorewall version $(run_it $g_firewall version))"
;;
esac
fi
else
echo $SHOREWALL_VERSION
@@ -1057,7 +1094,7 @@ show_connections() {
shift
conntrack -f ipv4 -L $@ | show_connections_filter
else
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments
if [ -f /proc/net/ip_conntrack ]; then
cat /proc/net/ip_conntrack | show_connections_filter
else
@@ -1070,7 +1107,7 @@ show_connections() {
echo
conntrack -f ipv6 -L $@ | show_connections_filter
else
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments
if [ -f /proc/sys/net/netfilter/nf_conntrack_count -a -f /proc/sys/net/nf_conntrack ]; then
local count=$(cat /proc/sys/net/netfilter/nf_conntrack_count)
local max=$(cat /proc/sys/net/netfilter/nf_conntrack_max)
@@ -1191,7 +1228,7 @@ show_command() {
option=${option#f}
;;
t)
[ $# -eq 1 ] && usage 1
[ $# -eq 1 ] && missing_option_value -t
case $2 in
mangle|nat|filter|raw|rawpost)
@@ -1219,7 +1256,7 @@ show_command() {
option=${option#b}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -1241,37 +1278,37 @@ show_command() {
eval show_connections $@ $g_pager
;;
nat)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_nat $g_pager
;;
raw)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_raw $g_pager
;;
rawpost)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_rawpost $g_pager
;;
tos|mangle)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_mangle $g_pager
;;
log)
[ $# -gt 2 ] && usage 1
[ $# -gt 2 ] && too_many_arguments $2
setup_logread
eval show_log $g_pager
;;
tc)
[ $# -gt 2 ] && usage 1
[ $# -gt 2 ] && too_many_arguments $2
eval show_tc $@ $g_pager
;;
classifiers|filters)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_classifiers_command $g_pager
;;
zones)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
if [ -f ${VARDIR}/zones ]; then
echo "$g_product $SHOREWALL_VERSION Zones at $g_hostname - $(date)"
echo
@@ -1294,7 +1331,7 @@ show_command() {
fi
;;
capabilities)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
determine_capabilities
VERBOSITY=2
if [ -n "$g_filemode" ]; then
@@ -1304,11 +1341,11 @@ show_command() {
fi
;;
ip)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_ip_addresses $g_pager
;;
routing)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_routing_command $g_pager
;;
config)
@@ -1337,26 +1374,26 @@ show_command() {
echo $VARDIR;
;;
policies)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_policies $g_pager
;;
ipa)
[ $g_family -eq 4 ] || usage 1
[ $# -gt 1 ] && usage 1
[ $g_family -eq 4 ] || fatal_error "'show ipa' is now available in $g_product"
[ $# -gt 1 ] && too_many_arguments $2
eval show_ipa $g_pager
;;
marks)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
echo "$g_product $SHOREWALL_VERSION Mark Layout at $g_hostname - $(date)"
echo
[ -f ${VARDIR}/marks ] && cat ${VARDIR}/marks;
;;
nfacct)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_nfacct_command $g_pager
;;
arptables)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
resolve_arptables
if [ -n "$arptables" -a -x $arptables ]; then
eval show_arptables $g_pager
@@ -1365,22 +1402,22 @@ show_command() {
fi
;;
event)
[ $# -gt 1 ] || usage 1
[ $# -gt 1 ] || too_many_arguments $2
echo "$g_product $SHOREWALL_VERSION events at $g_hostname - $(date)"
echo
shift
show_events $@
;;
events)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_events_command $g_pager
;;
bl|blacklists)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_blacklists $g_pager
;;
opens)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
echo "$g_product $SHOREWALL_VERSION Temporarily opened connections at $g_hostname - $(date)"
if chain_exists dynamic; then
@@ -1396,12 +1433,12 @@ show_command() {
*)
case $1 in
actions)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_actions_sorted $g_pager
return
;;
macro)
[ $# -ne 2 ] && usage 1
[ $# -ne 2 ] && too_many_arguments $2
for directory in $(split $CONFIG_PATH); do
if [ -f ${directory}/macro.$2 ]; then
echo "Shorewall $SHOREWALL_VERSION Macro $2 at $g_hostname - $(date)"
@@ -1413,7 +1450,7 @@ show_command() {
return
;;
macros)
[ $# -gt 1 ] && usage 1
[ $# -gt 1 ] && too_many_arguments $2
eval show_macros $g_pager
return
;;
@@ -1424,7 +1461,7 @@ show_command() {
if [ $# -gt 0 ]; then
if [ $1 = dynamic -a $# -gt 1 ]; then
shift
[ $# -eq 1 ] || usage 1
[ $# -eq 1 ] || too_many_arguments $2
list_zone $1
return;
fi
@@ -1499,6 +1536,49 @@ dump_filter_wrapper() {
eval dump_filter $g_pager
}
show_status() {
local compiletime
local state
if product_is_started ; then
[ $VERBOSITY -ge 1 ] && echo "$g_product is running"
status=0
else
[ $VERBOSITY -ge 1 ] && echo "$g_product is stopped"
status=4
fi
if [ -f ${VARDIR}/state ]; then
state="$(cat ${VARDIR}/state)"
case $state in
Stopped*|Closed*|Clear*)
status=3
;;
esac
else
state=Unknown
fi
if [ $VERBOSITY -ge 1 ]; then
if [ -f $g_firewall ]; then
compiletime=$(run_it $g_firewall info 2>/dev/null)
case $compiletime in
compiled\ *)
state="$state ($g_firewall $compiletime)"
;;
*)
state="$state ($g_firewall compiled by Shorewall version $(run_it $g_firewall version))"
;;
esac
fi
echo "State:$state"
echo
fi
}
#
# Dump Command Executor
#
@@ -1538,7 +1618,7 @@ do_dump_command() {
option=${option#c}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -1557,7 +1637,7 @@ do_dump_command() {
[ $VERBOSITY -lt 2 ] && VERBOSITY=2
[ -n "$g_debugging" ] && set -x
[ $# -eq 0 ] || usage 1
[ $# -eq 0 ] || too_many_arguments $1
clear_term
echo "$g_product $SHOREWALL_VERSION Dump at $g_hostname - $(date)"
echo
@@ -1752,7 +1832,7 @@ restore_command() {
option=${option#C}
;;
*)
usage 1
option_error
;;
esac
done
@@ -1772,7 +1852,7 @@ restore_command() {
validate_restorefile '<restore file>'
;;
*)
usage 1
too_many_arguments $2
;;
esac
@@ -2378,7 +2458,7 @@ hits_command() {
option=${option#t}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -2390,7 +2470,7 @@ hits_command() {
esac
done
[ $# -eq 0 ] || usage 1
[ $# -eq 0 ] || too_many_arguments $1
clear_term
echo "$g_product $SHOREWALL_VERSION Hits at $g_hostname - $(date)"
@@ -2446,21 +2526,46 @@ hits_command() {
# 'allow' command executor
#
allow_command() {
[ -n "$g_debugging" ] && set -x
[ $# -eq 1 ] && usage 1
[ $# -eq 1 ] && missing_argument
if product_is_started ; then
local allowed
local which
which='-s'
local range
range='--src-range'
local dynexists
if ! chain_exists dynamic; then
if [ -n "$g_blacklistipset" ]; then
case ${IPSET:=ipset} in
*/*)
if [ ! -x "$IPSET" ]; then
fatal_error "IPSET=$IPSET does not exist or is not executable"
fi
;;
*)
IPSET="$(mywhich $IPSET)"
[ -n "$IPSET" ] || fatal_error "The ipset utility cannot be located"
;;
esac
fi
if chain_exists dynamic; then
dynexists=Yes
elif [ -z "$g_blacklistipset" ]; then
fatal_error "Dynamic blacklisting is not enabled in the current $g_product configuration"
fi
[ -n "$g_nolock" ] || mutex_on
while [ $# -gt 1 ]; do
shift
allowed=''
case $1 in
from)
which='-s'
@@ -2473,29 +2578,48 @@ allow_command() {
continue
;;
*-*)
if qt $g_tool -D dynamic -m iprange $range $1 -j reject ||\
qt $g_tool -D dynamic -m iprange $range $1 -j DROP ||\
qt $g_tool -D dynamic -m iprange $range $1 -j logdrop ||\
qt $g_tool -D dynamic -m iprange $range $1 -j logreject
if [ -n "$g_blacklistipset" ]; then
if qt $IPSET -D $g_blacklistipset $1; then
allowed=Yes
fi
fi
if [ -n "$dynexists" ]; then
if qt $g_tool -D dynamic -m iprange $range $1 -j reject ||\
qt $g_tool -D dynamic -m iprange $range $1 -j DROP ||\
qt $g_tool -D dynamic -m iprange $range $1 -j logdrop ||\
qt $g_tool -D dynamic -m iprange $range $1 -j logreject
then
echo "$1 Allowed"
else
echo "$1 Not Dropped or Rejected"
allowed=Yes
fi
fi
;;
*)
if qt $g_tool -D dynamic $which $1 -j reject ||\
qt $g_tool -D dynamic $which $1 -j DROP ||\
qt $g_tool -D dynamic $which $1 -j logdrop ||\
qt $g_tool -D dynamic $which $1 -j logreject
if [ -n "$g_blacklistipset" ]; then
if qt $IPSET -D $g_blacklistipset $1; then
allowed=Yes
fi
fi
if [ -n "$dynexists" ]; then
if qt $g_tool -D dynamic $which $1 -j reject ||\
qt $g_tool -D dynamic $which $1 -j DROP ||\
qt $g_tool -D dynamic $which $1 -j logdrop ||\
qt $g_tool -D dynamic $which $1 -j logreject
then
echo "$1 Allowed"
else
echo "$1 Not Dropped or Rejected"
allowed=Yes
fi
fi
;;
esac
if [ -n "$allowed" ]; then
progress_message2 "$1 Allowed"
else
error_message "WARNING: $1 already allowed (not dynamically blacklisted)"
fi
done
[ -n "$g_nolock" ] || mutex_off
else
error_message "ERROR: $g_product is not started"
@@ -2517,8 +2641,6 @@ logwatch_command() {
-*)
option=${option#-}
[ -z "$option" ] && usage 1
while [ -n "$option" ]; do
case $option in
v*)
@@ -2538,7 +2660,7 @@ logwatch_command() {
option=
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -2557,7 +2679,7 @@ logwatch_command() {
elif [ $# -eq 0 ]; then
logwatch 30
else
usage 1
too_many_arguments $2
fi
}
@@ -3301,36 +3423,6 @@ report_capabilities1() {
report_capabilities_unsorted1 | sort
}
show_status() {
if product_is_started ; then
[ $VERBOSITY -ge 1 ] && echo "$g_product is running"
status=0
else
[ $VERBOSITY -ge 1 ] && echo "$g_product is stopped"
status=4
fi
if [ -f ${VARDIR}/state ]; then
state="$(cat ${VARDIR}/state)"
case $state in
Stopped*|Closed*|Clear*)
status=3
;;
esac
else
state=Unknown
fi
if [ $VERBOSITY -ge 1 ]; then
if [ -f $g_firewall ]; then
state="$state ($g_firewall compiled by Shorewall version $($g_firewall version))"
fi
echo "State:$state"
echo
fi
}
interface_status() {
case $(cat $1) in
0)
@@ -3384,7 +3476,7 @@ status_command() {
option=${option#i}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -3396,7 +3488,7 @@ status_command() {
esac
done
[ $# -eq 0 ] || usage 1
[ $# -eq 0 ] || missing_argument
[ $VERBOSITY -ge 1 ] && echo "${g_product}-$SHOREWALL_VERSION Status at $g_hostname - $(date)" && echo
show_status
@@ -3444,6 +3536,59 @@ reject_command() {
fi
}
blacklist_command() {
local family
[ $# -gt 0 ] || fatal_error "Missing address"
[ -z "$g_blacklistipset" ] && fatal_error "The blacklist command is not supported in the current $g_product configuration"
case ${IPSET:=ipset} in
*/*)
if [ ! -x "$IPSET" ]; then
fatal_error "IPSET=$IPSET does not exist or is not executable"
fi
;;
*)
IPSET="$(mywhich $IPSET)"
[ -n "$IPSET" ] || fatal_error "The ipset utility cannot be located"
;;
esac
if $IPSET -A $g_blacklistipset $@ -exist; then
local message
progress_message2 "$1 Blacklisted"
if [ -n "$g_disconnect" ]; then
message="$(conntrack -D -s $1 2>&1)"
if [ -n "$message" -a $VERBOSITY -gt 0 ]; then
if [ $VERBOSITY -gt 1 ]; then
echo "$message" | awk '/have been deleted/ { sub( /^.*: /, "" ); sub( / /, " src " ); }; { print; }'
else
echo "$message" | head -n1 | sed 's/^.*: //; s/ / src /'
fi
fi
if [ $g_disconnect = src-dst ]; then
message="$(conntrack -D -d $1 2>&1)"
if [ -n "$message" -a $VERBOSITY -gt 0 ]; then
if [ $VERBOSITY -gt 1 ]; then
echo "$message" | awk '/have been deleted/ { sub( /^.*: /, "" ); sub( / /, " dst " ); }; { print; }'
else
echo "$message" | head -n1 | sed 's/^.*: //; s/ / dst /'
fi
fi
fi
fi
else
error_message "ERROR: Address $1 not blacklisted"
return 1
fi
return 0
}
save_command() {
local finished
finished=0
@@ -3467,7 +3612,7 @@ save_command() {
option=${option#C}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -3487,7 +3632,7 @@ save_command() {
validate_restorefile '<restore file>'
;;
*)
usage 1
too_many_arguments $2
;;
esac
@@ -3506,6 +3651,9 @@ save_command() {
forget_command() {
case $# in
0)
missing_argument
;;
1)
;;
2)
@@ -3513,7 +3661,7 @@ forget_command() {
validate_restorefile '<restore file>'
;;
*)
usage 1
too_many_arguments $3
;;
esac
@@ -3535,7 +3683,7 @@ ipcalc_command() {
local address
local vlsm
[ $g_family -eq 6 ] && usage 1
[ $g_family -eq 6 ] && fatal_error "$g_product does not support the ipcalc command"
if [ $# -eq 2 ]; then
address=${2%/*}
@@ -3543,13 +3691,15 @@ ipcalc_command() {
elif [ $# -eq 3 ]; then
address=$2
vlsm=$(ip_vlsm $3)
elif [ $# -eq 0 ]; then
missing_argument
else
usage 1
too_many_arguments $4
fi
valid_address $address || fatal_error "Invalid IP address: $address"
[ -z "$vlsm" ] && usage 2
[ "x$address" = "x$vlsm" ] && usage 2
[ -z "$vlsm" ] && fatal_error "Missing VLSM"
[ "x$address" = "x$vlsm" ] && "Invalid VLSM"
[ $vlsm -gt 32 ] && fatal_error "Invalid VLSM: /$vlsm"
address=$address/$vlsm
@@ -3563,7 +3713,7 @@ ipcalc_command() {
iprange_command() {
local range
[ $g_family -eq 6 ] && usage 1
[ $g_family -eq 6 ] && fatal_error "$g_product does not support the iprange command"
range=''
@@ -3581,15 +3731,19 @@ iprange_command() {
ip_range $range
;;
*)
usage 1
fatal_error "Invalid ip range: $range"
;;
esac
}
ipdecimal_command() {
[ $# -eq 2 ] || usage 1
if [ $# eq 1 ]; then
missing_argument
else
[ $# -eq 2 ] || too_many_arguments $3
fi
[ $g_family -eq 6 ] && usage 1
[ $g_family -eq 6 ] && fatal_error "$g_product does not support the iprange command"
case $2 in
*.*.*.*)
@@ -3637,6 +3791,68 @@ verify_firewall_script() {
fi
}
setup_dbl() {
local original
original=$DYNAMIC_BLACKLIST
case $DYNAMIC_BLACKLIST in
*:*,)
fatal_error "Invalid value ($original) for DYNAMIC_BLACKLIST"
;;
ipset*,disconnect*)
if qt mywhich conntrack; then
g_disconnect=src
DYNAMIC_BLACKLIST=$(echo $DYNAMIC_BLACKLIST | sed 's/,disconnect//')
else
fatal_error "The 'disconnect' option requires that the conntrack utility be installed"
fi
;;
esac
case $DYNAMIC_BLACKLIST in
ipset*,src-dst*)
#
# This utility doesn't need to know about 'src-dst'
#
DYNAMIC_BLACKLIST=$(echo $DYNAMIC_BLACKLIST | sed 's/,src-dst//')
[ -n "$g_disconnect" ] && g_disconnect=src-dst
;;
esac
case $DYNAMIC_BLACKLIST in
ipset*,timeout*)
#
# This utility doesn't need to know about 'timeout=nnn'
#
DYNAMIC_BLACKLIST=$(echo $DYNAMIC_BLACKLIST | sed -r 's/,timeout=[[:digit:]]+//')
;;
esac
case $DYNAMIC_BLACKLIST in
[Nn]o)
DYNAMIC_BLACKLIST='';
;;
[Yy]es)
;;
ipset|ipset::*|ipset-only|ipset-only::*)
g_blacklistipset=SW_DBL$g_family
;;
ipset:[a-zA-Z]*)
g_blacklistipset=${DYNAMIC_BLACKLIST#ipset:}
g_blacklistipset=${g_blacklistipset%%:*}
;;
ipset-only:[a-zA-Z]*)
g_blacklistipset=${DYNAMIC_BLACKLIST#ipset-only:}
g_blacklistipset=${g_blacklistipset%%:*}
;;
*)
fatal_error "Invalid value ($original) for DYNAMIC_BLACKLIST"
;;
esac
}
################################################################################
# The remaining functions are used by the Lite cli - they are overloaded by
# the Standard CLI by loading lib.cli-std
@@ -3776,6 +3992,8 @@ get_config() {
g_loopback=$(find_loopback_interfaces)
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
if [ -n "$PAGER" -a -t 1 ]; then
case $PAGER in
/*)
@@ -3783,7 +4001,7 @@ get_config() {
[ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
;;
*)
g_pager=$(mywhich pager 2> /dev/null)
g_pager=$(mywhich $PAGER 2> /dev/null)
[ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
;;
esac
@@ -3793,6 +4011,10 @@ get_config() {
g_pager="| $g_pager"
fi
if [ -n "$DYNAMIC_BLACKLIST" ]; then
setup_dbl
fi
lib=$(find_file lib.cli-user)
[ -f $lib ] && . $lib
@@ -3819,7 +4041,7 @@ start_command() {
rc=$?
else
error_message "${VARDIR}/firewall is missing or is not executable"
logger -p kern.err "ERROR:$g_product start failed"
mylogger kern.err "ERROR:$g_product start failed"
rc=6
fi
@@ -3865,7 +4087,7 @@ start_command() {
option=${option%p}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -3881,7 +4103,7 @@ start_command() {
0)
;;
*)
usage 1
too_many_arguments $1
;;
esac
@@ -3925,7 +4147,7 @@ restart_command() {
option=${option#C}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -3941,7 +4163,7 @@ restart_command() {
0)
;;
*)
usage 1
too_many_arguments $1
;;
esac
@@ -3952,7 +4174,7 @@ restart_command() {
rc=$?
else
error_message "${VARDIR}/firewall is missing or is not executable"
logger -p kern.err "ERROR:$g_product $COMMAND failed"
mylogger kern.err "ERROR:$g_product $COMMAND failed"
rc=6
fi
@@ -3983,6 +4205,7 @@ usage() # $1 = exit status
echo "where <command> is one of:"
echo " add <interface>[:<host-list>] ... <zone>"
echo " allow <address> ..."
echo " blacklist <address> [ <option> ... ]"
ecko " [ check | ck ] [ -e ] [ -r ] [ -p ] [ -r ] [ -T ] [ -i ] [ <directory> ]"
echo " clear"
ecko " [ compile | co ] [ -e ] [ -p ] [ -t ] [ -c ] [ -d ] [ -T ] [ -i ] [ <directory name> ] [ <path name> ]"
@@ -4134,6 +4357,8 @@ shorewall_cli() {
g_loopback=
g_compiled=
g_pager=
g_blacklistipset=
g_disconnect=
VERBOSE=
VERBOSITY=1
@@ -4155,7 +4380,8 @@ shorewall_cli() {
while [ -n "$option" ]; do
case $option in
c)
[ $# -eq 1 -o -n "$g_lite" ] && usage 1
[ $# -eq 1 ] && missing_option_value -c
[ -n "$g_lite" ] && fatal_error "$g_product does not support the -c option"
if [ ! -d $2 ]; then
if [ -e $2 ]; then
@@ -4170,7 +4396,7 @@ shorewall_cli() {
shift
;;
e*)
[ -n "$g_lite" ] && usage 1
[ -n "$g_lite" ] && fatal_error "$g_product does not support the -e option"
g_export=Yes
option=${option#e}
;;
@@ -4232,7 +4458,7 @@ shorewall_cli() {
option=
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -4297,7 +4523,7 @@ shorewall_cli() {
start_command $@
;;
stop|clear)
[ $# -ne 1 ] && usage 1
[ $# -ne 1 ] && too_many_arguments $2
get_config
[ -x $g_firewall ] || fatal_error "$g_product has never been started"
[ -n "$g_nolock" ] || mutex_on
@@ -4325,6 +4551,13 @@ shorewall_cli() {
fatal_error "$g_product is not running"
fi
;;
blacklist)
get_config Yes
shift
[ -n "$g_nolock" ] || mutex_on
blacklist_command $@
[ -n "$g_nolock" ] || mutex_off
;;
run)
[ $# -gt 1 ] || fatal_error "Missing function name"
get_config Yes
@@ -4347,7 +4580,7 @@ shorewall_cli() {
dump_command $@
;;
hits)
[ $g_family -eq 6 ] && usage 1
[ $g_family -eq 6 ] && fatal_error "$g_product does not support the hits command"
get_config Yes No Yes
[ -n "$g_debugging" ] && set -x
shift
@@ -4365,19 +4598,19 @@ shorewall_cli() {
drop)
get_config
[ -n "$g_debugging" ] && set -x
[ $# -eq 1 ] && usage 1
[ $# -eq 1 ] && missing_argument
drop_command $@
;;
logdrop)
get_config
[ -n "$g_debugging" ] && set -x
[ $# -eq 1 ] && usage 1
[ $# -eq 1 ] && missing_argument
logdrop_command $@
;;
reject|logreject)
get_config
[ -n "$g_debugging" ] && set -x
[ $# -eq 1 ] && usage 1
[ $# -eq 1 ] && missing_argument
reject_command $@
;;
open|close)
@@ -4442,6 +4675,11 @@ shorewall_cli() {
# It's a shell function -- call it
#
$@
elif type $1 2> /dev/null | fgrep -q 'is a shell function'; then
#
# It's a shell function -- call it
#
$@
else
#
# It isn't a function visible to this script -- try
@@ -4450,7 +4688,7 @@ shorewall_cli() {
run_it $g_firewall $g_debugging call $@
fi
else
usage 1
missing_argument
fi
;;
help)
@@ -4468,7 +4706,7 @@ shorewall_cli() {
noiptrace_command $@
;;
savesets)
[ $# -eq 1 ] || usage 1
[ $# -eq 1 ] || too_many_arguments $2
get_config
[ -n "$g_debugging" ] && set -x
savesets1
@@ -4477,7 +4715,7 @@ shorewall_cli() {
if [ -z "$g_lite" ]; then
compiler_command $@
else
usage 1
fatal_error "Invalid command: $COMMAND"
fi
;;
esac

View File

@@ -25,6 +25,22 @@
# scripts rather than loaded at run-time.
#
#########################################################################################
#
# Wrapper around logger that sets the tag according to $SW_LOGGERTAG
#
mylogger() {
local level
level=$1
shift
if [ -n "$SW_LOGGERTAG" ]; then
logger -p $level -t "$SW_LOGGERTAG" $*
else
logger -p $level $*
fi
}
#
# Issue a message and stop
#
@@ -33,24 +49,24 @@ startup_error() # $* = Error Message
echo " ERROR: $@: Firewall state not changed" >&2
if [ $LOG_VERBOSITY -ge 0 ]; then
timestamp="$(date +'%b %d %T') "
timestamp="$(date +'%b %e %T') "
echo "${timestamp} ERROR: $@" >> $STARTUP_LOG
fi
case $COMMAND in
start)
logger -p kern.err "ERROR:$g_product start failed:Firewall state not changed"
mylogger kern.err "ERROR:$g_product start failed:Firewall state not changed"
;;
restart)
logger -p kern.err "ERROR:$g_product restart failed:Firewall state not changed"
mylogger kern.err "ERROR:$g_product restart failed:Firewall state not changed"
;;
restore)
logger -p kern.err "ERROR:$g_product restore failed:Firewall state not changed"
mylogger kern.err "ERROR:$g_product restore failed:Firewall state not changed"
;;
esac
if [ $LOG_VERBOSITY -ge 0 ]; then
timestamp="$(date +'%b %d %T') "
timestamp="$(date +'%b %e %T') "
case $COMMAND in
start)
@@ -696,9 +712,9 @@ find_file()
set_state () # $1 = state
{
if [ $# -gt 1 ]; then
echo "$1 ($(date)) from $2" > ${VARDIR}/state
echo "$1 $(date) from $2" > ${VARDIR}/state
else
echo "$1 ($(date))" > ${VARDIR}/state
echo "$1 $(date)" > ${VARDIR}/state
fi
}
@@ -760,7 +776,7 @@ mutex_on()
error_message "WARNING: Stale lockfile ${lockf} removed"
elif [ $lockpid -eq $$ ]; then
return 0
elif ! qt ps p ${lockpid}; then
elif ! ps | grep -v grep | qt grep ${lockpid}; then
rm -f ${lockf}
error_message "WARNING: Stale lockfile ${lockf} from pid ${lockpid} removed"
fi
@@ -772,10 +788,8 @@ mutex_on()
echo $$ > ${lockf}
chmod u-w ${lockf}
elif qt mywhich lock; then
lock -${MUTEX_TIMEOUT} -r1 ${lockf}
chmod u+w ${lockf}
echo $$ > ${lockf}
chmod u-w ${lockf}
lock ${lockf}
chmod u=r ${lockf}
else
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
sleep 1
@@ -797,6 +811,7 @@ mutex_on()
#
mutex_off()
{
[ -f ${CONFDIR}/rc.common ] && lock -u ${LOCKFILE:=${VARDIR}/lock}
rm -f ${LOCKFILE:=${VARDIR}/lock}
}

View File

@@ -19,3 +19,4 @@ SERVICEFILE= #Unused on OS X
SYSCONFDIR= #Unused on OS X
SPARSE=Yes #Only install $PRODUCT/$PRODUCT.conf in $CONFDIR.
VARLIB=/var/lib #Unused on OS X
DEFAULT_PAGER= #Pager to use if none specified in shorewall[6].conf

View File

@@ -20,3 +20,4 @@ SERVICEFILE= #Name of the file to install in $SYSTEMD.
SPARSE= #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
VARLIB=/var/lib #Directory where product variable data is stored.
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
DEFAULT_PAGER= #Pager to use if none specified in shorewall[6].conf

View File

@@ -19,3 +19,4 @@ SERVICEFILE= #Unused on Cygwin
SYSCONFDIR= #Unused on Cygwin
SPARSE=Yes #Only install $PRODUCT/$PRODUCT.conf in $CONFDIR.
VARLIB=/var/lib #Unused on Cygwin
DEFAULT_PAGER= #Pager to use if none specified in shorewall[6].conf

View File

@@ -21,3 +21,4 @@ SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (s
SPARSE=Yes #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
VARLIB=/var/lib #Directory where product variable data is stored.
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
DEFAULT_PAGER=/usr/bin/less #Pager to use if none specified in shorewall[6].conf

View File

@@ -21,3 +21,4 @@ SERVICEDIR= #Directory where .service files are installed (systems running sy
SPARSE=Yes #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
VARLIB=/var/lib #Directory where product variable data is stored.
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
DEFAULT_PAGER=/usr/bin/less #Pager to use if none specified in shorewall[6].conf

View File

@@ -21,3 +21,4 @@ SYSCONFDIR= #Directory where SysV init parameter fil
SPARSE= #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
VARLIB=/var/lib #Directory where product variable data is stored.
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
DEFAULT_PAGER= #Pager to use if none specified in shorewall[6].conf

View File

@@ -21,3 +21,4 @@ SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.se
SPARSE= #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
VARLIB=/lib #Directory where product variable data is stored.
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
DEFAULT_PAGER= #Pager to use if none specified in shorewall[6].conf

View File

@@ -21,3 +21,4 @@ SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter fil
SPARSE= #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
VARLIB=/var/lib #Directory where product variable data is stored.
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
DEFAULT_PAGER= #Pager to use if none specified in shorewall[6].conf

View File

@@ -22,3 +22,4 @@ SYSCONFDIR= #Name of the directory where SysV ini
ANNOTATED= #If non-empty, install annotated configuration files
VARLIB=/var/lib #Directory where product variable data is stored.
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
DEFAULT_PAGER= #Pager to use if none specified in shorewall[6].conf

View File

@@ -7,17 +7,18 @@ PREFIX=/usr #Top-level directory for s
CONFDIR=/etc #Directory where subsystem configurations are installed
SHAREDIR=${PREFIX}/share #Directory for arch-neutral files.
LIBEXECDIR=${PREFIX}/lib #Directory for executable scripts.
PERLLIBDIR=${PREFIX}/lib/perl5/vendor_perl/5.14.2 #Directory to install Shorewall Perl module directory
PERLLIBDIR=${PREFIX}/lib/perl5/site-perl #Directory to install Shorewall Perl module directory
SBINDIR=/usr/sbin #Directory where system administration programs are installed
MANDIR=${SHAREDIR}/man/ #Directory where manpages are installed.
INITDIR=/etc/init.d #Directory where SysV init scripts are installed.
INITFILE=$PRODUCT #Name of the product's SysV init script
INITFILE= #Name of the product's SysV init script
INITSOURCE=init.suse.sh #Name of the distributed file to be installed as the SysV init script
ANNOTATED= #If non-zero, annotated configuration files are installed
SERVICEDIR= #Directory where .service files are installed (systems running systemd only)
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
SERVICEDIR=/usr/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
SERVICEFILE=$PRODUCT.service #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
SYSCONFFILE=sysconfig #Name of the distributed file to be installed in $SYSCONFDIR
SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter files are installed
SPARSE= #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
VARLIB=/var/lib #Directory where persistent product data is stored.
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
DEFAULT_PAGER= #Pager to use if none specified in shorewall[6].conf

View File

@@ -117,6 +117,7 @@ fi
echo "Uninstalling Shorewall Core $VERSION"
rm -rf ${SHAREDIR}/shorewall
rm -f ~/.shorewallrc
echo "Shorewall Core Uninstalled"

View File

@@ -30,7 +30,7 @@
# Required-Stop: $local_fs
# X-Stop-After: $network
# Default-Start: S
# Default-Stop: 0 6
# Default-Stop: 0 1 6
# Short-Description: Initialize the firewall at boot time
# Description: Place the firewall in a safe state at boot time prior to
# bringing up the network

View File

@@ -412,7 +412,7 @@ if [ $HOST = debian ]; then
if [ ! -f ${DESTDIR}${CONFDIR}/default/shorewall-init ]; then
if [ -n "${DESTDIR}" ]; then
mkdir ${DESTDIR}${ETC}/default
mkdir -p ${DESTDIR}${ETC}/default
fi
[ $configure -eq 1 ] || mkdir -p ${DESTDIR}${CONFDIR}/default
@@ -572,9 +572,9 @@ if [ -z "$DESTDIR" ]; then
cant_autostart
fi
elif [ $HOST = openwrt -a -f ${CONFDIR}/rc.common ]; then
/etc/init.d/shorewall-inir enable
/etc/init.d/$PRODUCT enable
if /etc/init.d/shorewall-init enabled; then
echo "Shorrewall Init will start automatically at boot"
echo "$Product will start automatically at boot"
else
cant_autostart
fi
@@ -585,7 +585,7 @@ if [ -z "$DESTDIR" ]; then
fi
else
if [ $configure -eq 1 -a -n "$first_install" ]; then
if [ $HOST = debian ]; then
if [ $HOST = debian -a -z "$SERVICEDIR" ]; then
if [ -n "${DESTDIR}" ]; then
mkdir -p ${DESTDIR}/etc/rcS.d
fi

View File

@@ -5,7 +5,7 @@
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: S
# Default-Stop: 0 6
# Default-Stop: 0 1 6
# Short-Description: Configure the firewall at boot time
# Description: Configure the firewall according to the rules specified in
# /etc/shorewall-lite
@@ -92,10 +92,11 @@ shorewall_start () {
# stop the firewall
shorewall_stop () {
echo -n "Stopping \"Shorewall firewall\": "
if [ "$SAFESTOP" = 1 ]; then
echo -n "Stopping \"Shorewall Lite firewall\": "
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
else
echo -n "Clearing all \"Shorewall Lite firewall\" rules: "
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
fi
return 0

View File

@@ -495,7 +495,7 @@ done
# Install the Man Pages
#
if [ -d manpages ]; then
if [ -d manpages -a -n "$MANDIR" ]; then
cd manpages
mkdir -p ${DESTDIR}${MANDIR}/man5/ ${DESTDIR}${MANDIR}/man8/
@@ -550,7 +550,7 @@ if [ -n "$SYSCONFFILE" -a -f "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PR
fi
install_file ${SYSCONFFILE} ${DESTDIR}${SYSCONFDIR}/${PRODUCT} 0640
echo "$SYSCONFFILE installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
echo "$SYSCONFFILE file installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
fi
if [ ${SHAREDIR} != /usr/share ]; then

View File

@@ -47,6 +47,19 @@
<arg choice="plain"><replaceable>address</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>shorewall-lite</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>blacklist</option></arg>
<arg choice="plain"><replaceable>address</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>shorewall-lite</command>
@@ -689,7 +702,45 @@
blacklisted by a <emphasis role="bold">drop</emphasis>, <emphasis
role="bold">logdrop</emphasis>, <emphasis
role="bold">reject</emphasis>, or <emphasis
role="bold">logreject</emphasis> command.</para>
role="bold">logreject</emphasis> command. Beginning with Shorewall
5.0.10, this command can also re-enable addresses blacklisted using
the <command>blacklist</command> command.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">blacklist</emphasis>
<replaceable>address</replaceable> [ <replaceable>option</replaceable>
... ]</term>
<listitem>
<para>Added in Shorewall 5.0.8 and requires
DYNAMIC_BLACKLIST=ipset.. in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5).
Causes packets from the given host or network
<replaceable>address</replaceable> to be dropped, based on the
setting of BLACKLIST in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5). The
<replaceable>address</replaceable> along with any
<replaceable>option</replaceable>s are passed to the <command>ipset
add</command> command.</para>
<para>If the <option>disconnect</option> option is specified in the
DYNAMIC_BLACKLISTING setting, then the effective VERBOSITY
determines the amount of information displayed:</para>
<itemizedlist>
<listitem>
<para>If the effective verbosity is &gt; 0, then a message
giving the number of conntrack flows deleted by the command is
displayed.</para>
</listitem>
<listitem>
<para>If the effective verbosity is &gt; 1, then the conntrack
table entries deleted by the command are also displayed.</para>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
@@ -1553,6 +1604,34 @@
started.</para>
</refsect1>
<refsect1>
<title>ENVIRONMENT</title>
<para>Two environmental variables are recognized by Shorewall-lite:</para>
<variablelist>
<varlistentry>
<term>SHOREWALL_INIT_SCRIPT</term>
<listitem>
<para>When set to 1, causes Std out to be redirected to the file
specified in the STARTUP_LOG option in <ulink
url="shorewall.conf.html">shorewall.conf(5)</ulink>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>SW_LOGGERTAG</term>
<listitem>
<para>Added in Shorewall 5.0.8. When set to a non-empty value, that
value is passed to the logger utility in its -t (--tag)
option.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>FILES</title>

View File

@@ -0,0 +1,9 @@
#
# Shorewall -- /usr/share/shorewall/macro.RedisCluster
#
# This macro handles Redis Cluster traffic.
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - tcp 16379

View File

@@ -0,0 +1,9 @@
#
# Shorewall -- /usr/share/shorewall/macro.RedisSentinel
#
# This macro handles Redis Sentinel traffic.
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - tcp 26379

View File

@@ -244,7 +244,7 @@ sub create_arptables_load( $ ) {
emit "exec 3>\${VARDIR}/.arptables-input";
my $date = localtime;
my $date = compiletime;
unless ( $test ) {
emit_unindented '#';
@@ -294,7 +294,7 @@ sub create_arptables_load( $ ) {
#
sub preview_arptables_load() {
my $date = localtime;
my $date = compiletime;
print "#\n# Generated by Shorewall $globals{VERSION} - $date\n#\n";

View File

@@ -279,6 +279,7 @@ our %EXPORT_TAGS = (
save_docker_rules
load_ipsets
create_save_ipsets
create_load_ipsets
validate_nfobject
create_nfobjects
create_netfilter_load
@@ -286,6 +287,7 @@ our %EXPORT_TAGS = (
create_chainlist_reload
create_stop_load
initialize_switches
terminating
%targets
%builtin_target
%dscpmap
@@ -335,7 +337,7 @@ our $VERSION = 'MODULEVERSION';
# digest => SHA1 digest of the string representation of the chain's rules for use in optimization
# level 8.
# complete => The last rule in the chain is a -g or a simple -j to a terminating target
# Suppresses adding additional rules to the chain end of the chain
# Suppresses adding additional rules to the end of the chain
# sections => { <section> = 1, ... } - Records sections that have been completed.
# chainnumber => Numeric enumeration of the builtin chains (mangle table only).
# allowedchains
@@ -808,14 +810,13 @@ sub initialize( $$$ ) {
NETMAP => 1,
NFQUEUE => 1,
NOTRACK => 1,
REDIRECT => 1,
RAWDNAT => 1,
REDIRECT => 1,
RAWSNAT => 1,
REJECT => 1,
SAME => 1,
SNAT => 1,
TPROXY => 1,
reject => 1,
);
#
# The chain table is initialized via a call to initialize_chain_table() after the configuration and capabilities have been determined.
@@ -842,6 +843,24 @@ sub make_terminating( $ ) {
$terminating{$_[0]} = 1;
}
#
# Determine if a chain is terminating
#
sub terminating( $ ) {
my ( $chainref ) = @_;
return $chainref->{complete} && ! ( $chainref->{optflags} & RETURNS );
}
sub is_terminating( $$ ) {
my ( $table, $target ) = @_;
if ( my $chainref = $chain_table{$table}{$target} ) {
terminating( $chainref );
} else {
$terminating{$target};
}
}
#
# Transform the passed iptables rule into an internal-form hash reference.
# Most of the compiler has been converted to use the new form natively.
@@ -1309,6 +1328,8 @@ sub push_rule( $$ ) {
my $complete = 0;
my $ruleref = transform_rule( $_[1], $complete );
fatal_error "Chain $chainref->{name} jumps to itself" if ( $ruleref->{target} || '' ) eq $chainref->{name};
set_irule_comment( $chainref, $ruleref );
$ruleref->{mode} = CMD_MODE if $ruleref->{cmdlevel} = $chainref->{cmdlevel};
@@ -1316,7 +1337,14 @@ sub push_rule( $$ ) {
push @{$chainref->{rules}}, $ruleref;
$chainref->{referenced} = 1;
$chainref->{optflags} |= RETURNS_DONT_MOVE if ( $ruleref->{target} || '' ) eq 'RETURN';
trace( $chainref, 'A', @{$chainref->{rules}}, "-A $chainref->{name} $_[1] $ruleref->{comment}" ) if $debug;
if ( $debug ) {
if ( $ruleref->{comment} ) {
trace( $chainref, 'A', @{$chainref->{rules}}, "-A $chainref->{name} $_[1] -m comment --comment \"$ruleref->{comment}\"" );
} else {
trace( $chainref, 'A', @{$chainref->{rules}}, "-A $chainref->{name} $_[1]" );
}
}
$chainref->{complete} = 1 if $complete;
@@ -1539,6 +1567,7 @@ sub create_irule( $$$;@ ) {
$ruleref->{jump} = $jump;
$ruleref->{target} = $target;
$chainref->{optflags} |= RETURNS_DONT_MOVE if $target eq 'RETURN';
$chainref->{complete} ||= ( ! @matches && ( $jump eq 'g' || is_terminating( $chainref->{table}, $target ) ) );
$ruleref->{targetopts} = $targetopts if $targetopts;
} else {
$ruleref->{target} = '';
@@ -2485,7 +2514,7 @@ sub add_ijump_internal( $$$$$;@ ) {
}
if ( $ruleref->{simple} ) {
$fromref->{complete} = 1 if $jump eq 'g' || $terminating{$to};
$fromref->{complete} = 1 if $jump eq 'g' || ( $toref ? terminating( $toref ) : $terminating{$to} );
}
$ruleref->{origin} = $origin if $origin;
@@ -2906,13 +2935,13 @@ sub initialize_chain_table($) {
# As new targets (Actions, Macros and Manual Chains) are discovered, they are added to the table
#
%targets = ('ACCEPT' => STANDARD,
'ACCEPT+' => STANDARD + NONAT,
'ACCEPT+' => STANDARD + NONAT,
'ACCEPT!' => STANDARD,
'ADD' => STANDARD + SET,
'AUDIT' => STANDARD + AUDIT + OPTIONS,
'A_ACCEPT' => STANDARD + AUDIT,
'A_ACCEPT+' => STANDARD + NONAT + AUDIT,
'A_ACCEPT!' => STANDARD + AUDIT,
'AUDIT' => STANDARD + AUDIT + OPTIONS,
'A_ACCEPT' => STANDARD + AUDIT,
'A_ACCEPT+' => STANDARD + NONAT + AUDIT,
'A_ACCEPT!' => STANDARD + AUDIT,
'A_DROP' => STANDARD + AUDIT,
'A_DROP!' => STANDARD + AUDIT,
'NONAT' => STANDARD + NONAT + NATONLY,
@@ -2972,13 +3001,13 @@ sub initialize_chain_table($) {
# As new targets (Actions, Macros and Manual Chains) are discovered, they are added to the table
#
%targets = ('ACCEPT' => STANDARD,
'ACCEPT+' => STANDARD + NONAT,
'ACCEPT+' => STANDARD + NONAT,
'ACCEPT!' => STANDARD,
'A_ACCEPT+' => STANDARD + NONAT + AUDIT,
'A_ACCEPT!' => STANDARD + AUDIT,
'AUDIT' => STANDARD + AUDIT + OPTIONS,
'A_ACCEPT' => STANDARD + AUDIT,
'NONAT' => STANDARD + NONAT + NATONLY,
'A_ACCEPT+' => STANDARD + NONAT + AUDIT,
'A_ACCEPT!' => STANDARD + AUDIT,
'AUDIT' => STANDARD + AUDIT + OPTIONS,
'A_ACCEPT' => STANDARD + AUDIT,
'NONAT' => STANDARD + NONAT + NATONLY,
'DROP' => STANDARD,
'DROP!' => STANDARD,
'A_DROP' => STANDARD + AUDIT,
@@ -3157,17 +3186,17 @@ sub delete_references( $ ) {
#
sub calculate_digest( $ ) {
my $chainref = shift;
my $digest = '';
my $rules = '';
for ( @{$chainref->{rules}} ) {
if ( $digest ) {
$digest .= ' |' . format_rule( $chainref, $_, 1 );
if ( $rules ) {
$rules .= ' |' . format_rule( $chainref, $_, 1 );
} else {
$digest = format_rule( $chainref, $_, 1 );
$rules = format_rule( $chainref, $_, 1 );
}
}
$chainref->{digest} = sha1_hex $digest;
$chainref->{digest} = sha1_hex $rules;
}
#
@@ -3456,7 +3485,7 @@ sub optimize_level4( $$ ) {
$progress = 1;
} elsif ( $chainref->{builtin} || ! $globals{KLUDGEFREE} || $firstrule->{policy} ) {
#
# This case requires a new rule merging algorithm. Ignore this chain for
# This case requires a new rule merging algorithm. Ignore this chain from
# now on.
#
$chainref->{optflags} |= DONT_OPTIMIZE;
@@ -3464,7 +3493,7 @@ sub optimize_level4( $$ ) {
#
# Replace references to this chain with the target and add the matches
#
$progress = 1 if replace_references1 $chainref, $firstrule;
$progress = 1 if replace_references1( $chainref, $firstrule );
}
}
} else {
@@ -3510,7 +3539,7 @@ sub optimize_level4( $$ ) {
#empty builtin chain -- change it's policy
#
$chainref->{policy} = $target;
trace( $chainref, 'P', undef, 'ACCEPT' ) if $debug;
trace( $chainref, 'P', undef, $target ) if $debug;
$count++;
}
@@ -3664,7 +3693,12 @@ sub optimize_level8( $$$ ) {
if ( $chainref->{digest} eq $chainref1->{digest} ) {
progress_message " Chain $chainref1->{name} combined with $chainref->{name}";
$progress = 1;
replace_references $chainref1, $chainref->{name}, undef, '', '', 1;
replace_references( $chainref1,
$chainref->{name},
undef, # Target Opts
'', # Comment
'', # Origin
1 ); # Recalculate digests of modified chains
unless ( $chainref->{name} =~ /^~/ || $chainref1->{name} =~ /^%/ ) {
#
@@ -3990,7 +4024,7 @@ sub delete_duplicates {
my $docheck;
my $duplicate = 0;
if ( $baseref->{mode} == CAT_MODE ) {
if ( $baseref->{mode} == CAT_MODE && $baseref->{target} ) {
my $ports1;
my @keys1 = sort( grep ! $skip{$_}, keys( %$baseref ) );
my $rulenum = @_;
@@ -5156,7 +5190,7 @@ sub do_time( $ ) {
$result .= "--monthday $days ";
} elsif ( $element =~ /^(datestart|datestop)=(\d{4}(-\d{2}(-\d{2}(T\d{1,2}(:\d{1,2}){0,2})?)?)?)$/ ) {
$result .= "--$1 $2 ";
} elsif ( $element =~ /^(utc|localtz|kerneltz)$/ ) {
} elsif ( $element =~ /^(utc|localtz|kerneltz|contiguous)$/ ) {
$result .= "--$1 ";
} else {
fatal_error "Invalid time element ($element)";
@@ -5198,6 +5232,8 @@ sub do_user( $ ) {
if ( supplied $2 ) {
$user = $2;
$user =~ s/:$//;
if ( $user =~ /^(\d+)(-(\d+))?$/ ) {
if ( supplied $2 ) {
fatal_error "Invalid User Range ($user)" unless $3 >= $1;
@@ -7744,7 +7780,10 @@ sub expand_rule( $$$$$$$$$$$$;$ )
# No logging or user-specified logging -- add the target rule with matches to the rule chain
#
if ( $targetref ) {
add_expanded_jump( $chainref, $targetref , 0, $prerule . $matches );
add_expanded_jump( $chainref ,
$targetref ,
terminating( $targetref ) ,
$prerule . $matches );
} else {
add_rule( $chainref, $prerule . $matches . $jump , 1 );
}
@@ -8224,26 +8263,67 @@ EOF
emit( '' ), save_docker_rules( $tool ), emit( '' ) if $config{DOCKER};
}
sub ensure_ipset( $ ) {
my $set = shift;
sub ensure_ipsets( @ ) {
my $set;
my $counters = have_capability( 'IPSET_MATCH_COUNTERS' ) ? ' counters' : '';
if ( $family == F_IPV4 ) {
if ( have_capability 'IPSET_V5' ) {
emit ( qq( if ! qt \$IPSET -L $set -n; then) ,
qq( error_message "WARNING: ipset $set does not exist; creating it as an hash:ip set") ,
qq( \$IPSET -N $set hash:ip family inet) ,
qq( fi) );
if ( $globals{DBL_TIMEOUT} ne '' && $_[0] eq $globals{DBL_IPSET} ) {
shift;
emit( qq( if ! qt \$IPSET list $globals{DBL_IPSET}; then));
push_indent;
if ( $family == F_IPV4 ) {
emit( q( #),
q( # Set the timeout for the dynamic blacklisting ipset),
q( #),
qq( \$IPSET -exist create $globals{DBL_IPSET} hash:net family inet timeout $globals{DBL_TIMEOUT}${counters}) );
} else {
emit ( qq( if ! qt \$IPSET -L $set -n; then) ,
qq( error_message "WARNING: ipset $set does not exist; creating it as an iphash set") ,
qq( \$IPSET -N $set iphash) ,
emit( q( #),
q( # Set the timeout for the dynamic blacklisting ipset),
q( #),
qq( \$IPSET -exist create $globals{DBL_IPSET} hash:net family inet6 timeout $globals{DBL_TIMEOUT}${counters}) );
}
pop_indent;
emit( qq( fi\n) );
}
if ( @_ ) {
if ( @_ > 1 ) {
push_indent;
emit( "for set in @_; do" );
$set = '$set';
} else {
$set = $_[0];
}
if ( $family == F_IPV4 ) {
if ( have_capability 'IPSET_V5' ) {
emit ( qq( if ! qt \$IPSET list $set -n; then) ,
qq( error_message "WARNING: ipset $set does not exist; creating it as an hash:net set") ,
qq( \$IPSET create $set hash:net family inet timeout 0${counters}) ,
qq( fi) );
} else {
emit ( qq( if ! qt \$IPSET -L $set -n; then) ,
qq( error_message "WARNING: ipset $set does not exist; creating it as an iphash set") ,
qq( \$IPSET -N $set iphash) ,
qq( fi) );
}
} else {
emit ( qq( if ! qt \$IPSET list $set -n; then) ,
qq( error_message "WARNING: ipset $set does not exist; creating it as an hash:net set") ,
qq( \$IPSET create $set hash:net family inet6 timeout 0${counters}) ,
qq( fi) );
}
} else {
emit ( qq( if ! qt \$IPSET -L $set -n; then) ,
qq( error_message "WARNING: ipset $set does not exist; creating it as an hash:ip set") ,
qq( \$IPSET -N $set hash:ip family inet6) ,
qq( fi) );
if ( @_ > 1 ) {
emit 'done';
pop_indent;
}
}
}
@@ -8253,22 +8333,26 @@ sub ensure_ipset( $ ) {
sub create_save_ipsets() {
my @ipsets = all_ipsets;
emit( "#\n#Save the ipsets specified by the SAVE_IPSETS setting and by dynamic zones\n#",
emit( "#\n#Save the ipsets specified by the SAVE_IPSETS setting and by dynamic zones and blacklisting\n#",
'save_ipsets() {' );
if ( @ipsets || @{$globals{SAVED_IPSETS}} || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) {
emit( ' local file' ,
' local set' ,
'',
' file=${1:-${VARDIR}/save.ipsets}'
);
if ( @ipsets ) {
emit '';
ensure_ipset( $_ ) for @ipsets;
ensure_ipsets( @ipsets );
}
if ( $config{SAVE_IPSETS} ) {
if ( $family == F_IPV6 || $config{SAVE_IPSETS} eq 'ipv4' ) {
#
# Requires V5 or later
#
my $select = $family == F_IPV4 ? '^create.*family inet ' : 'create.*family inet6 ';
emit( '' ,
@@ -8277,11 +8361,6 @@ sub create_save_ipsets() {
' local set' ,
);
if ( @ipsets ) {
emit '';
emit( " \$IPSET -S $_ >> \$file" ) for @ipsets;
}
emit( '',
" for set in \$(\$IPSET save | grep '$select' | cut -d' ' -f2); do" ,
" \$IPSET save \$set >> \$file" ,
@@ -8289,6 +8368,9 @@ sub create_save_ipsets() {
'',
);
} else {
#
# Saving all ipsets (IPv4 and IPv6, if any )
#
emit (
'',
' if eval $IPSET -S > ${VARDIR}/ipsets.tmp; then' ,
@@ -8297,28 +8379,48 @@ sub create_save_ipsets() {
}
emit( " return 0",
'',
"}\n" );
} elsif ( @ipsets || $globals{SAVED_IPSETS} ) {
#
# Requires V5 or later
#
my %ipsets;
#
# Requires V
#
$ipsets{$_} = 1 for ( @ipsets, @{$globals{SAVED_IPSETS}} );
my @sets = sort keys %ipsets;
emit( '' ,
' rm -f $file' ,
' touch $file' ,
' rm -f ${VARDIR}/ipsets.tmp' ,
' touch ${VARDIR}/ipsets.tmp' ,
);
if ( @ipsets ) {
emit '';
emit( " \$IPSET -S $_ >> \${VARDIR}/ipsets.tmp" ) for @ipsets;
if ( @sets > 1 ) {
emit( '' ,
" for set in @sets; do" ,
' if qt $IPSET list $set; then' ,
' $IPSET save $set >> ${VARDIR}/ipsets.tmp' ,
' else' ,
' error_message "ipset $set not saved (not found)"' ,
' fi' ,
' done' );
} else {
my $set = $sets[0];
emit( '' ,
" if qt \$IPSET list $set; then" ,
" \$IPSET save $set >> \${VARDIR}/ipsets.tmp" ,
' else' ,
" error_message 'ipset $set not saved (not found)'" ,
' fi' );
}
emit( '' ,
" if qt \$IPSET list $_; then" ,
" \$IPSET save $_ >> \${VARDIR}/ipsets.tmp" ,
' else' ,
" error_message 'ipset $_ not saved (not found)'" ,
" fi\n" ) for @{$globals{SAVED_IPSETS}};
emit( '' ,
" grep -qE -- \"(-N|^create )\" \${VARDIR}/ipsets.tmp && cat \${VARDIR}/ipsets.tmp >> \$file\n" ,
" grep -q -- \"^create \" \${VARDIR}/ipsets.tmp && mv -f \${VARDIR}/ipsets.tmp \$file\n" ,
'' ,
' return 0',
'' ,
@@ -8334,13 +8436,58 @@ sub create_save_ipsets() {
}
}
sub load_ipsets() {
sub create_load_ipsets() {
my @ipsets = all_ipsets;
my @ipsets = all_ipsets; #Dynamic Zone IPSETS
if ( @ipsets || @{$globals{SAVED_IPSETS}} || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) {
emit ( '', );
emit ( '',
my $setting = $config{SAVE_IPSETS};
my $havesets = @ipsets || @{$globals{SAVED_IPSETS}} || ( $setting && have_ipset_rules );
#
# Generate a function that flushes and destroys sets prior to restoring them
#
if ( $havesets ) {
my $select = $family == F_IPV4 ? '^create.*family inet ' : 'create.*family inet6 ';
emit ( "#\n#Flush and Destroy the sets that we will subsequently attempt to restore\n#",
'zap_ipsets() {',
' local set',
'' );
if ( $family == F_IPV6 || $setting !~ /yes/i ) {
#
# Requires V5 or later
#
emit( '' ,
" for set in \$(\$IPSET save | grep '$select' | cut -d' ' -f2); do" ,
' $IPSET flush $set' ,
' $IPSET destroy $set' ,
" done" ,
'',
);
} else {
#
# Restoring all ipsets (IPv4 and IPv6, if any)
#
emit ( ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
' $IPSET -F' ,
' $IPSET -X' ,
' fi' );
};
emit( '}' );
}
#
# Now generate load_ipsets()
emit ( "#\n#Flush and Destroy the sets then load fresh copy from a saved ipset file\n#",
'load_ipsets() {' );
push_indent;
if ( $havesets ) {
emit( '',
'case $IPSET in',
' */*)',
' [ -x "$IPSET" ] || startup_error "IPSET=$IPSET does not exist or is not executable"',
@@ -8351,86 +8498,67 @@ sub load_ipsets() {
' ;;',
'esac' ,
'' ,
'if [ "$COMMAND" = start ]; then' );
'if [ "$COMMAND" = start ]; then' ); ##################### Start Command ##################
if ( $config{SAVE_IPSETS} ) {
emit ( ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
' $IPSET -F' ,
' $IPSET -X' ,
' $IPSET -R < ${VARDIR}/ipsets.save' ,
' fi' );
if ( $config{SAVE_IPSETS} || @{$globals{SAVED_IPSETS}} ) {
emit( ' if [ -f ${VARDIR}/ipsets.save ]; then' );
if ( @ipsets ) {
emit ( '' );
ensure_ipset( $_ ) for @ipsets;
emit ( '' );
emit ( ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
' $IPSET flush' ,
' $IPSET destroy' ,
' $IPSET restore < ${VARDIR}/ipsets.save' ,
" fi\n" ) for @{$globals{SAVED_IPSETS}};
}
} else {
ensure_ipset( $_ ) for @ipsets;
if ( @{$globals{SAVED_IPSETS}} ) {
emit ( '' );
emit ( ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
' $IPSET flush' ,
' $IPSET destroy' ,
' $IPSET restore < ${VARDIR}/ipsets.save' ,
" fi\n" ) for @{$globals{SAVED_IPSETS}};
if ( my $set = $globals{DBL_IPSET} ) {
emit( ' #',
' # Update the dynamic blacklisting ipset timeout value',
' #',
qq( awk '/create $set/ { sub( /timeout [0-9]+/, "timeout $globals{DBL_TIMEOUT}" ) }; {print};' \${VARDIR}/ipsets.save > \${VARDIR}/ipsets.temp),
' zap_ipsets',
' $IPSET restore < ${VARDIR}/ipsets.temp',
' fi' );
} else {
emit( ' zap_ipsets',
' $IPSET -R < ${VARDIR}/ipsets.save',
' fi' );
}
}
emit ( 'elif [ "$COMMAND" = restore -a -z "$g_recovering" ]; then' );
if ( @ipsets ) {
emit ( '' );
ensure_ipsets( @ipsets );
}
if ( $config{SAVE_IPSETS} ) {
emit ( 'elif [ "$COMMAND" = restore -a -z "$g_recovering" ]; then' ); ### Restore Command #################
if ( $config{SAVE_IPSETS} || @{$globals{SAVED_IPSETS}} ) {
emit( ' if [ -f $(my_pathname)-ipsets ]; then' ,
' if chain_exists shorewall; then' ,
' startup_error "Cannot restore $(my_pathname)-ipsets with Shorewall running"' ,
' else' ,
' $IPSET -F' ,
' $IPSET -X' ,
' zap_ipsets' ,
' $IPSET -R < $(my_pathname)-ipsets' ,
' fi' ,
' fi' ,
);
if ( @ipsets ) {
emit ( '' );
ensure_ipset( $_ ) for @ipsets;
emit ( '' );
}
} else {
ensure_ipset( $_ ) for @ipsets;
emit ( ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
' $IPSET flush' ,
' $IPSET destroy' ,
' $IPSET restore < ${VARDIR}/ipsets.save' ,
" fi\n" ) for @{$globals{SAVED_IPSETS}};
}
if ( @ipsets ) {
emit ( 'elif [ "$COMMAND" = reload ]; then' );
ensure_ipset( $_ ) for @ipsets;
}
emit ( '' );
ensure_ipsets( @ipsets );
emit( 'elif [ "$COMMAND" = stop ]; then' ,
' save_ipsets'
);
emit ( 'elif [ "$COMMAND" = reload ]; then' ); ################### Reload Command ####################
ensure_ipsets( @ipsets );
if ( @ipsets ) {
emit( 'elif [ "$COMMAND" = refresh ]; then' );
ensure_ipset( $_ ) for @ipsets;
emit( 'elif [ "$COMMAND" = refresh ]; then' ); ################### Refresh Command ###################
emit ( '' );
ensure_ipsets( @ipsets );
emit ( '' );
};
emit ( 'fi' ,
'' );
} else {
emit 'true';
}
pop_indent;
emit '}';
}
#
@@ -8500,7 +8628,7 @@ sub create_netfilter_load( $ ) {
enter_cat_mode;
my $date = localtime;
my $date = compiletime;
unless ( $test ) {
emit_unindented '#';
@@ -8608,7 +8736,7 @@ sub preview_netfilter_load() {
enter_cat_mode1;
my $date = localtime;
my $date = compiletime;
print "#\n# Generated by Shorewall $globals{VERSION} - $date\n#\n";
@@ -8844,7 +8972,7 @@ sub create_stop_load( $ ) {
enter_cat_mode;
unless ( $test ) {
my $date = localtime;
my $date = compiletime;
emit_unindented '#';
emit_unindented "# Generated by Shorewall $globals{VERSION} - $date";
emit_unindented '#';

View File

@@ -76,7 +76,7 @@ sub initialize_package_globals( $$$ ) {
#
# First stage of script generation.
#
# Copy lib.core and lib.common to the generated script.
# Copy lib.runtime and lib.common to the generated script.
# Generate the various user-exit jacket functions.
#
# Note: This function is not called when $command eq 'check'. So it must have no side effects other
@@ -90,12 +90,12 @@ sub generate_script_1( $ ) {
if ( $test ) {
emit "#!$config{SHOREWALL_SHELL}\n#\n# Compiled firewall script generated by Shorewall-perl\n#";
} else {
my $date = localtime;
my $date = compiletime;
emit "#!$config{SHOREWALL_SHELL}\n#\n# Compiled firewall script generated by Shorewall $globals{VERSION} - $date\n#";
copy $globals{SHAREDIRPL} . '/lib.core', 0;
copy2 $globals{SHAREDIRPL} . '/lib.common', $debug;
copy $globals{SHAREDIRPL} . '/lib.runtime', 0;
copy2 $globals{SHAREDIRPL} . '/lib.common' , $debug;
}
}
@@ -368,6 +368,7 @@ sub generate_script_3($) {
create_arptables_load( $test ) if $have_arptables;
create_chainlist_reload( $_[0] );
create_save_ipsets;
create_load_ipsets;
emit "#\n# Start/Reload the Firewall\n#";
@@ -406,7 +407,9 @@ sub generate_script_3($) {
'fi',
'' );
load_ipsets;
emit( 'load_ipsets' ,
'' );
create_nfobjects;
verify_address_variables;
save_dynamic_chains;
@@ -573,16 +576,16 @@ date > ${VARDIR}/restarted
case $COMMAND in
start)
logger -p kern.info "$g_product started"
mylogger kern.info "$g_product started"
;;
reloaded)
logger -p kern.info "$g_product reloaded"
reload)
mylogger kern.info "$g_product reloaded"
;;
refresh)
logger -p kern.info "$g_product refreshed"
mylogger kern.info "$g_product refreshed"
;;
restore)
logger -p kern.info "$g_product restored"
mylogger kern.info "$g_product restored"
;;
esac
EOF
@@ -593,6 +596,21 @@ EOF
}
#
# Generate info_command()
#
sub compile_info_command() {
my $date = compiletime;
emit( "\n",
"#",
"# Echo the date and time when this script was compiled along with the Shorewall version",
"#",
"info_command() {" ,
qq( echo "compiled $date by Shorewall version $globals{VERSION}") ,
"}\n" );
}
#
# The Compiler.
#
@@ -867,10 +885,6 @@ sub compiler {
#
complete_policy_chains;
#
# Reject Action
#
process_reject_action if $config{REJECT_ACTION};
#
# Accounting.
#
setup_accounting if $config{ACCOUNTING};
@@ -923,6 +937,10 @@ sub compiler {
#
compile_updown;
#
# Echo the compilation time and date
#
compile_info_command unless $test;
#
# Copy the footer to the script
#
copy $globals{SHAREDIRPL} . 'prog.footer' unless $test;

View File

@@ -84,6 +84,8 @@ our @EXPORT = qw(
require_capability
report_used_capabilities
kernel_version
compiletime
);
our @EXPORT_OK = qw( $shorewall_dir initialize shorewall);
@@ -161,6 +163,9 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
set_section_function
clear_section_function
directive_callback
add_ipset
all_ipsets
transfer_permissions
$product
$Product
@@ -344,7 +349,7 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
=> 'Ipset Match nomatch',
IPSET_MATCH_COUNTERS
=> 'Ipset Match counters',
IPSET_V5 => 'Version 5 ipsets',
IPSET_V5 => 'Version 5 or later ipset',
CONNMARK => 'CONNMARK Target',
XCONNMARK => 'Extended CONNMARK Target',
CONNMARK_MATCH => 'Connmark Match',
@@ -572,6 +577,7 @@ our $max_format; # Max format value
our $comment; # Current COMMENT
our $comments_allowed; # True if [?]COMMENT is allowed in the current file
our $nocomment; # When true, ignore [?]COMMENT in the current file
our $sr_comment; # When true, $comment should only be applied to the current rule
our $warningcount; # Used to suppress duplicate warnings about missing COMMENT support
our $checkinline; # The -i option to check/compile/etc.
our $directive_callback; # Function to call in compiler_directive
@@ -673,11 +679,14 @@ our $section_function; #Function Reference for handling ?section
our $evals = 0; # Number of times eval() called out of evaluate_expression() or embedded_perl().
our %ipsets; # All required IPsets
#
# Files located via find_file()
#
our %filecache;
our $compiletime;
sub process_shorewallrc($$);
sub add_variables( \% );
#
@@ -723,6 +732,7 @@ sub initialize( $;$$) {
# Contents of last COMMENT line.
#
$comment = '';
$sr_comment = '';
$warningcount = 0;
#
# Misc Globals
@@ -734,7 +744,7 @@ sub initialize( $;$$) {
TC_SCRIPT => '',
EXPORT => 0,
KLUDGEFREE => '',
VERSION => "5.0.1",
VERSION => "5.0.9-Beta2",
CAPVERSION => 50004 ,
BLACKLIST_LOG_TAG => '',
RELATED_LOG_TAG => '',
@@ -744,6 +754,8 @@ sub initialize( $;$$) {
RPFILTER_LOG_TAG => '',
INVALID_LOG_TAG => '',
UNTRACKED_LOG_TAG => '',
DBL_IPSET => '',
DBL_TIMEOUT => 0,
POSTROUTING => 'POSTROUTING',
);
#
@@ -886,6 +898,9 @@ sub initialize( $;$$) {
DOCKER => undef ,
PAGER => undef ,
MINIUPNPD => undef ,
VERBOSE_MESSAGES => undef ,
ZERO_MARKS => undef ,
FIREWALL => undef ,
#
# Packet Disposition
#
@@ -1073,6 +1088,7 @@ sub initialize( $;$$) {
%actparams = ( 0 => 0, loglevel => '', logtag => '', chain => '', disposition => '', caller => '' );
$parmsmodified = 0;
$usedcaller = 0;
%ipsets = ();
%helpers_enabled = (
amanda => 1,
@@ -1167,10 +1183,28 @@ sub initialize( $;$$) {
%shorewallrc1 = %shorewallrc unless $shorewallrc1;
add_variables %shorewallrc1;
$compiletime = `date`;
chomp $compiletime;
$compiletime =~ s/ +/ /g;
}
my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
sub add_ipset( $ ) {
$ipsets{$_[0]} = 1;
}
sub all_ipsets() {
sort keys %ipsets;
}
sub compiletime() {
$compiletime;
}
#
# Create 'currentlineinfo'
#
@@ -1244,6 +1278,34 @@ sub shortlineinfo( $ ) {
sub handle_first_entry();
#
# Issue a Information Message
#
sub info_message
{
my $currentlineinfo = currentlineinfo;
our @localtime;
handle_first_entry if $first_entry;
$| = 1; #Reset output buffering (flush any partially filled buffers).
if ( $log ) {
@localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
}
if ( $confess ) {
print STDERR longmess( " INFO: @_$currentlineinfo" );
print $log longmess( " INFO: @_$currentlineinfo\n" ) if $log;
} else {
print STDERR " INFO: @_$currentlineinfo\n";
print $log " INFO: @_$currentlineinfo\n" if $log;
}
$| = 0; #Re-allow output buffering
}
#
# Issue a Warning Message
#
@@ -1673,7 +1735,7 @@ sub progress_message {
@localtime = localtime unless $havelocaltime;
printf $log '%s %2d %2d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
print $log "${leading}${line}\n";
}
}
@@ -1692,7 +1754,7 @@ sub progress_message_nocompress {
@localtime = localtime unless $havelocaltime;
printf $log '%s %2d %2d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
print $log "@_\n";
}
}
@@ -1713,7 +1775,7 @@ sub progress_message2 {
@localtime = localtime unless $havelocaltime;
printf $log '%s %2d %2d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
print $log "@_\n";
}
}
@@ -1734,7 +1796,7 @@ sub progress_message3 {
@localtime = localtime unless $havelocaltime;
printf $log '%s %2d %2d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
print $log "@_\n";
}
}
@@ -2100,6 +2162,47 @@ sub split_list3( $$ ) {
@list2;
}
#
# This version spits a list on white-space with optional leading comma. It prevents double-quoted
# strings from being split.
#
sub split_list4( $ ) {
my ($list ) = @_;
my @list1 = split( /,?\s+/, $list );
my @list2;
my $element = '';
my $opencount = 0;
return @list1 unless $list =~ /"/;
@list1 = split( /(,?\s+)/, $list );
for ( my $i = 0; $i < @list1; $i += 2 ) {
my $e = $list1[$i];
if ( $e =~ /[^\\]"/ ) {
if ( $e =~ /[^\\]".*[^\\]"/ ) {
fatal_error 'Unescaped embedded quote (' . join( $list1[$i - 1], $element, $e ) . ')' if $element ne '';
push @list2, $e;
} elsif ( $element ne '' ) {
fatal_error 'Quoting Error (' . join( $list1[$i - 1], $element, $e ) . ')' unless $e =~ /"$/;
push @list2, join( $list1[$i - 1], $element, $e );
$element = '';
} else {
$element = $e;
}
} elsif ( $element ne '' ) {
$element = join( $list1[$i - 1], $element, $e );
} else {
push @list2, $e;
}
}
fatal_error "Mismatched_quotes ($list)" if $element ne '';
@list2;
}
#
# Splits the columns of a config file record
#
@@ -2169,6 +2272,8 @@ sub passed( $ ) {
defined $val && $val ne '' && $val ne '-';
}
sub clear_comment();
#
# Pre-process a line from a configuration file.
@@ -2192,6 +2297,8 @@ sub split_line2( $$;$$$ ) {
}
$inline_matches = '';
clear_comment if $sr_comment;
#
# First, see if there are double semicolons on the line; what follows will be raw iptables input
#
@@ -2298,18 +2405,37 @@ sub split_line2( $$;$$$ ) {
$pairs =~ s/^\s*//;
$pairs =~ s/\s*$//;
my @pairs = split( /,?\s+/, $pairs );
my @pairs = split_list4( $pairs );
for ( @pairs ) {
fatal_error "Invalid column/value pair ($_)" unless /^(\w+)(?:=>?|:)(.+)$/;
my ( $column, $value ) = ( lc( $1 ), $2 );
fatal_error "Unknown column ($1)" unless exists $columnsref->{$column};
$column = $columnsref->{$column};
fatal_error "Non-ASCII gunk in file" if $columns =~ /[^\s[:print:]]/;
$value = $1 if $value =~ /^"([^"]+)"$/;
fatal_error "Column values may not contain embedded double quotes, single back quotes or backslashes" if $columns =~ /["`\\]/;
fatal_error "Non-ASCII gunk in the value of the $column column" if $columns =~ /[^\s[:print:]]/;
$line[$column] = $value;
if ( $value =~ /"$/ ) {
fatal_error "Invalid value ( $value )" unless $value =~ /^"(.*)"$/;
$value = $1;
}
if ( $column eq 'comment' ) {
if ( $comments_allowed ) {
if ( have_capability( 'COMMENTS' ) ) {
$comment = $value;
$sr_comment = 1;
} else {
warning_message '"comment" ignored -- requires comment support in iptables/Netfilter' unless $warningcount++;
}
} else {
fatal_error '"comment" is not allowed in this file';
}
} else {
fatal_error "Unknown column ($1)" unless exists $columnsref->{$column};
$column = $columnsref->{$column};
fatal_error "Non-ASCII gunk in file" if $columns =~ /[^\s[:print:]]/;
$value = $1 if $value =~ /^"([^"]+)"$/;
$value =~ s/\\"/"/g;
fatal_error "Non-ASCII gunk in the value of the $column column" if $columns =~ /[^\s[:print:]]/;
$line[$column] = $value;
}
}
}
@@ -2339,6 +2465,7 @@ sub no_comment() {
sub clear_comment() {
$comment = '';
$nocomment = 0;
$sr_comment = '';
}
#
@@ -2434,7 +2561,8 @@ sub push_include() {
$max_format,
$comment,
$nocomment,
$section_function ];
$section_function,
$sr_comment ];
}
#
@@ -2458,7 +2586,8 @@ sub pop_include() {
$max_format,
$comment,
$nocomment,
$section_function ) = @$arrayref;
$section_function,
$sr_comment ) = @$arrayref;
} else {
$currentfile = undef;
$currentlinenumber = 'EOF';
@@ -2503,11 +2632,54 @@ sub directive_error( $$$ ) {
fatal_error $_[0];
}
sub directive_warning( $$$ ) {
my ( $savefilename, $savelineno ) = ( $currentfilename, $currentlinenumber );
( my $warning, $currentfilename, $currentlinenumber ) = @_;
warning_message $warning;
( $currentfilename, $currentlinenumber ) = ( $savefilename, $savelineno );
sub directive_warning( $$$$ ) {
if ( shift ) {
my ( $savefilename, $savelineno ) = ( $currentfilename, $currentlinenumber );
( my $warning, $currentfilename, $currentlinenumber ) = @_;
warning_message $warning;
( $currentfilename, $currentlinenumber ) = ( $savefilename, $savelineno );
} else {
our @localtime;
handle_first_entry if $first_entry;
$| = 1; #Reset output buffering (flush any partially filled buffers).
if ( $log ) {
@localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
print $log " WARNING: $_[0]\n";
}
print STDERR " WARNING: $_[0]\n";
$| = 0; #Re-allow output buffering
}
}
sub directive_info( $$$$ ) {
if ( shift ) {
my ( $savefilename, $savelineno ) = ( $currentfilename, $currentlinenumber );
( my $info, $currentfilename, $currentlinenumber ) = @_;
info_message $info;
( $currentfilename, $currentlinenumber ) = ( $savefilename, $savelineno );
} else {
our @localtime;
handle_first_entry if $first_entry;
$| = 1; #Reset output buffering (flush any partially filled buffers).
if ( $log ) {
@localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
print $log " INFO: $_[0]\n";
}
print STDERR " INFO: $_[0]\n";
$| = 0; #Re-allow output buffering
}
}
#
@@ -2656,7 +2828,7 @@ sub process_compiler_directive( $$$$ ) {
print "CD===> $line\n" if $debug;
directive_error( "Invalid compiler directive ($line)" , $filename, $linenumber ) unless $line =~ /^\s*\?(IF\s+|ELSE|ELSIF\s+|ENDIF|SET\s+|RESET\s+|FORMAT\s+|COMMENT\s*|ERROR\s+)(.*)$/i;
directive_error( "Invalid compiler directive ($line)" , $filename, $linenumber ) unless $line =~ /^\s*\?(IF\s+|ELSE|ELSIF\s+|ENDIF|SET\s+|RESET\s+|FORMAT\s+|COMMENT\s*|ERROR\s+|WARNING\s+|INFO\s+|WARNING!\s+|INFO!\s+)(.*)$/i;
my ($keyword, $expression) = ( uc $1, $2 );
@@ -2764,14 +2936,14 @@ sub process_compiler_directive( $$$$ ) {
delete $actparams{$var}
}
} else {
directive_warning( "Shorewall variable $2 does not exist", $filename, $linenumber );
directive_warning( 'Yes', "Shorewall variable $2 does not exist", $filename, $linenumber );
}
} else {
if ( exists $variables{$2} ) {
delete $variables{$2};
} else {
directive_warning( "Shell variable $2 does not exist", $filename, $linenumber );
directive_warning( 'Yes', "Shell variable $2 does not exist", $filename, $linenumber );
}
}
}
@@ -2784,8 +2956,9 @@ sub process_compiler_directive( $$$$ ) {
if ( have_capability( 'COMMENTS' ) ) {
( $comment = $line ) =~ s/^\s*\?COMMENT\s*//;
$comment =~ s/\s*$//;
$sr_comment = '';
} else {
directive_warning( "COMMENTs ignored -- require comment support in iptables/Netfilter" , $filename, $linenumber ) unless $warningcount++;
directive_warning( 'Yes', "COMMENTs ignored -- require comment support in iptables/Netfilter" , $filename, $linenumber ) unless $warningcount++;
}
}
} else {
@@ -2801,7 +2974,48 @@ sub process_compiler_directive( $$$$ ) {
1 ) ,
$filename ,
$linenumber ) unless $omitting;
}
} ,
WARNING => sub() {
directive_warning( $config{VERBOSE_MESSAGES} ,
evaluate_expression( $expression ,
$filename ,
$linenumber ,
1 ),
$filename ,
$linenumber ) unless $omitting;
} ,
INFO => sub() {
directive_info( $config{VERBOSE_MESSAGES} ,
evaluate_expression( $expression ,
$filename ,
$linenumber ,
1 ),
$filename ,
$linenumber ) unless $omitting;
} ,
'WARNING!' => sub() {
directive_warning( ! $config{VERBOSE_MESSAGES} ,
evaluate_expression( $expression ,
$filename ,
$linenumber ,
1 ),
$filename ,
$linenumber ) unless $omitting;
} ,
'INFO!' => sub() {
directive_info( ! $config{VERBOSE_MESSAGES} ,
evaluate_expression( $expression ,
$filename ,
$linenumber ,
1 ),
$filename ,
$linenumber ) unless $omitting;
} ,
);
if ( my $function = $directives{$keyword} ) {
@@ -3096,6 +3310,7 @@ sub push_open( $;$$$$ ) {
push @openstack, \@a;
@includestack = ();
$currentfile = undef;
$sr_comment = '';
open_file( $file , $max, $comments_allowed || $ca, $nc , $cf );
}
@@ -3189,7 +3404,7 @@ sub embedded_shell( $ ) {
sub embedded_perl( $ ) {
my $multiline = shift;
my ( $command , $linenumber ) = ( qq(package Shorewall::User;\nno strict;\n# line $currentlinenumber "$currentfilename"\n$currentline), $currentlinenumber );
my ( $command , $linenumber ) = ( qq(package Shorewall::User;\nno strict;\nuse Shorewall::Config (qw/shorewall/);\n# line $currentlinenumber "$currentfilename"\n$currentline), $currentlinenumber );
$directive_callback->( 'PERL', $currentline ) if $directive_callback;
@@ -3514,7 +3729,7 @@ sub read_a_line($) {
#
# Handle directives
#
if ( /^\s*\?(?:IF|ELSE|ELSIF|ENDIF|SET|RESET|FORMAT|COMMENT|ERROR)/i ) {
if ( /^\s*\?(?:IF|ELSE|ELSIF|ENDIF|SET|RESET|FORMAT|COMMENT|ERROR|WARNING|INFO)/i ) {
$omitting = process_compiler_directive( $omitting, $_, $currentfilename, $. );
next;
}
@@ -3642,8 +3857,10 @@ sub process_shorewallrc( $$ ) {
$shorewallrc{VARDIR} = "$shorewallrc{VARLIB}/$product";
}
} elsif ( supplied $shorewallrc{VARLIB} ) {
$shorewallrc{VARDIR} = "$shorewallrc{VARLIB}/$product" unless supplied $shorewallrc{VARDIR};
$shorewallrc{VARDIR} = "$shorewallrc{VARLIB}/$product";
}
$shorewallrc{DEFAULT_PAGER} = '' unless supplied $shorewallrc{DEFAULT_PAGER};
}
#
@@ -3755,9 +3972,10 @@ my %logoptions = ( tcp_sequence => '--log-tcp-sequence',
sub validate_level( $;$ ) {
my ( $rawlevel, $option ) = @_;
my $level = uc $rawlevel;
my $level;
if ( supplied ( $level ) ) {
if ( supplied ( $rawlevel ) ) {
$level = uc $rawlevel;
$level =~ s/!$//;
my $value = $level;
my $qualifier;
@@ -4326,11 +4544,11 @@ sub IPSet_Match() {
}
sub IPSet_Match_Nomatch() {
have_capability 'IPSET_MATCH' && $capabilities{IPSET_MATCH_NOMATCH};
have_capability( 'IPSET_MATCH' ) && $capabilities{IPSET_MATCH_NOMATCH};
}
sub IPSet_Match_Counters() {
have_capability 'IPSET_MATCH' && $capabilities{IPSET_MATCH_COUNTERS};
have_capability( 'IPSET_MATCH' ) && $capabilities{IPSET_MATCH_COUNTERS};
}
sub IPSET_V5() {
@@ -4894,8 +5112,16 @@ sub ensure_config_path() {
@config_path = split /:/, $config{CONFIG_PATH};
#
# To accomodate Cygwin-based compilation, we have separate directories for files whose names
# clash on a case-insensitive filesystem.
#
push @config_path, $globals{SHAREDIR} . "/deprecated";
push @config_path, $shorewallrc{SHAREDIR}. '/shorewall/deprecated' unless $globals{PRODUCT} eq 'shorewall';
for ( @config_path ) {
$_ .= '/' unless m|/$|;
s|//|/|g;
}
if ( $shorewall_dir ) {
@@ -4941,6 +5167,19 @@ sub update_default($$) {
$config{$var} = $val unless defined $config{$var};
}
#
# Transfer the permissions from an old .bak file to a newly-created file
#
sub transfer_permissions( $$ ) {
my ( $old, $new ) = @_;
my @stat = stat $old;
if ( @stat ) {
fatal_error "Can't transfer permissions from $old to $new" unless chmod( $stat[2] & 0777, $new );
}
}
sub update_config_file( $ ) {
my ( $annotate ) = @_;
@@ -4995,7 +5234,7 @@ sub update_config_file( $ ) {
update_default( 'USE_DEFAULT_RT', 'No' );
update_default( 'EXPORTMODULES', 'No' );
update_default( 'RESTART', 'reload' );
update_default( 'PAGER', '' );
update_default( 'PAGER', $shorewallrc1{DEFAULT_PAGER} );
my $fn;
@@ -5090,6 +5329,7 @@ EOF
if ( system( "diff -q $configfile $configfile.bak > /dev/null" ) ) {
progress_message3 "Configuration file $configfile updated - old file renamed $configfile.bak";
transfer_permissions( "$configfile.bak", $configfile );
} else {
if ( rename "$configfile.bak", $configfile ) {
progress_message3 "No update required to configuration file $configfile; $configfile.bak not saved";
@@ -5411,7 +5651,7 @@ sub get_params( $ ) {
#
delete $params{$_};
} else {
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' ) {
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' || $_ eq 'SW_LOGGERTAG' ) {
fatal_error "The variable name $_ is reserved and may not be set in the params file"
if /^SW_/ || /^SHOREWALL_/ || ( exists $config{$_} && ! exists $ENV{$_} ) || exists $reserved{$_};
}
@@ -5604,6 +5844,24 @@ sub get_configuration( $$$$ ) {
$ENV{PATH} = $default_path;
}
fatal_error "Shorewall-core does not appear to be installed" unless open_file "$globals{SHAREDIRPL}coreversion";
fatal_error "$globals{SHAREDIRPL}coreversion is empty" unless read_a_line( PLAIN_READ );
close_file;
warning_message "Version Mismatch: Shorewall-core is version $currentline, while the Shorewall version is $globals{VERSION}" unless $currentline eq $globals{VERSION};
if ( $family == F_IPV6 ) {
open_file( "$globals{SHAREDIR}/version" ) || fatal_error "Unable to open $globals{SHAREDIR}/version";
fatal_error "$globals{SHAREDIR}/version is empty" unless read_a_line( PLAIN_READ );
close_file;
warning_message "Version Mismatch: Shorewall6 is version $currentline, while the Shorewall version is $globals{VERSION}" unless $currentline eq $globals{VERSION};
}
my $have_capabilities;
if ( $export || $> != 0 ) {
@@ -5851,16 +6109,21 @@ sub get_configuration( $$$$ ) {
unsupported_yes_no 'BRIDGING';
unsupported_yes_no_warning 'RFC1918_STRICT';
$val = $config{SAVE_IPSETS};
unless (default_yes_no 'SAVE_IPSETS', '', '*' ) {
$val = $config{SAVE_IPSETS};
unless ( $val eq 'ipv4' ) {
if ( $val eq 'ipv4' ) {
fatal_error 'SAVE_IPSETS=ipv4 is invalid in shorewall6.conf' if $family == F_IPV6;
} else {
my @sets = split_list( $val , 'ipset' );
$globals{SAVED_IPSETS} = \@sets;
require_capability 'IPSET_V5', 'A saved ipset list', 's';
$config{SAVE_IPSETS} = '';
}
require_capability( 'IPSET_V5', "SAVE_IPSETS=$val", 's' ) if $config{SAVE_IPSETS};
}
default_yes_no 'SAVE_ARPTABLES' , '';
default_yes_no 'STARTUP_ENABLED' , 'Yes';
default_yes_no 'DELAYBLACKLISTLOAD' , '';
@@ -5991,7 +6254,53 @@ sub get_configuration( $$$$ ) {
$config{ACCOUNTING_TABLE} = 'filter';
}
default_yes_no 'DYNAMIC_BLACKLIST' , 'Yes';
if ( supplied( $val = $config{DYNAMIC_BLACKLIST} ) ) {
if ( $val =~ /^ipset/ ) {
my %simple_options = ( 'src-dst' => 1, 'disconnect' => 1 );
my ( $key, $set, $level, $tag, $rest ) = split( ':', $val , 5 );
( $key , my @options ) = split_list( $key, 'option' );
my $options = '';
for ( @options ) {
if ( $simple_options{$_} ) {
$options = join( ',' , $options, $_ );
} elsif ( $_ =~ s/^timeout=(\d+)$// ) {
$globals{DBL_TIMEOUT} = $1;
} else {
fatal_error "Invalid ipset option ($_)";
}
}
$globals{DBL_OPTIONS} = $options;
fatal_error "Invalid DYNAMIC_BLACKLIST setting ( $val )" if $key !~ /^ipset(?:-only)?$/ || defined $rest;
if ( supplied( $set ) ) {
fatal_error "Invalid DYNAMIC_BLACKLIST ipset name" unless $set =~ /^[A-Za-z][\w-]*/;
} else {
$set = 'SW_DBL' . $family;
}
add_ipset( $globals{DBL_IPSET} = $set );
$level = validate_level( $level );
$tag = '' unless defined $tag;
$config{DYNAMIC_BLACKLIST} = join( ':', $key, $set, $level, $tag );
require_capability( 'IPSET_V5', 'DYNAMIC_BLACKLIST=ipset...', 's' );
} else {
default_yes_no( 'DYNAMIC_BLACKLIST', 'Yes' );
}
} else {
default_yes_no( 'DYNAMIC_BLACKLIST', 'Yes' );
}
default_yes_no 'REQUIRE_INTERFACE' , '';
default_yes_no 'FORWARD_CLEAR_MARK' , have_capability( 'MARK' ) ? 'Yes' : '';
default_yes_no 'COMPLETE' , '';
@@ -6004,6 +6313,8 @@ sub get_configuration( $$$$ ) {
default_yes_no 'WARNOLDCAPVERSION' , 'Yes';
default_yes_no 'DEFER_DNS_RESOLUTION' , 'Yes';
default_yes_no 'MINIUPNPD' , '';
default_yes_no 'VERBOSE_MESSAGES' , 'Yes';
default_yes_no 'ZERO_MARKS' , '';
$config{IPSET} = '' if supplied $config{IPSET} && $config{IPSET} eq 'ipset';
@@ -6503,7 +6814,7 @@ sub generate_aux_config() {
emit "#\n# Shorewall auxiliary configuration file created by Shorewall version $globals{VERSION} - $date\n#";
for my $option ( qw(VERBOSITY LOGFILE LOGFORMAT ARPTABLES IPTABLES IP6TABLES IP TC IPSET PATH SHOREWALL_SHELL SUBSYSLOCK LOCKFILE RESTOREFILE WORKAROUNDS RESTART) ) {
for my $option ( qw(VERBOSITY LOGFILE LOGFORMAT ARPTABLES IPTABLES IP6TABLES IP TC IPSET PATH SHOREWALL_SHELL SUBSYSLOCK LOCKFILE RESTOREFILE WORKAROUNDS RESTART DYNAMIC_BLACKLIST) ) {
conditionally_add_option $option;
}

View File

@@ -432,13 +432,18 @@ sub validate_port( $$ ) {
sub validate_portpair( $$ ) {
my ($proto, $portpair) = @_;
my $what;
my $pair = $portpair;
#
# Accept '-' as a port-range separator
#
$pair =~ tr/-/:/ if $pair =~ /^[-0-9]+$/;
fatal_error "Invalid port range ($portpair)" if $portpair =~ tr/:/:/ > 1;
fatal_error "Invalid port range ($portpair)" if $pair =~ tr/:/:/ > 1;
$portpair = "0$portpair" if substr( $portpair, 0, 1 ) eq ':';
$portpair = "${portpair}65535" if substr( $portpair, -1, 1 ) eq ':';
$pair = "0$pair" if substr( $pair, 0, 1 ) eq ':';
$pair = "${pair}65535" if substr( $pair, -1, 1 ) eq ':';
my @ports = split /:/, $portpair, 2;
my @ports = split /:/, $pair, 2;
my $protonum = resolve_proto( $proto ) || 0;
@@ -497,7 +502,7 @@ sub validate_port_list( $$ ) {
my ( $proto, $list ) = @_;
my @list = split_list( $list, 'port' );
if ( @list > 1 && $list =~ /:/ ) {
if ( @list > 1 && $list =~ /[:-]/ ) {
require_capability( 'XMULTIPORT' , 'Port ranges in a port list', '' );
}

View File

@@ -200,6 +200,7 @@ sub remove_blacklist( $ ) {
if ( $changed ) {
rename $fn, "$fn.bak" or fatal_error "Unable to rename $fn to $fn.bak: $!";
rename "$fn.new", $fn or fatal_error "Unable to rename $fn.new to $fn: $!";
transfer_permissions( "$fn.bak", $fn );
progress_message2 "\u$file file $fn saved in $fn.bak"
}
}
@@ -302,12 +303,13 @@ sub convert_blacklist() {
if ( @rules ) {
my $fn1 = find_writable_file( 'blrules' );
my $blrules;
my $date = localtime;
my $date = compiletime;
if ( -f $fn1 ) {
open $blrules, '>>', $fn1 or fatal_error "Unable to open $fn1: $!";
} else {
open $blrules, '>', $fn1 or fatal_error "Unable to open $fn1: $!";
transfer_permissions( $fn, $fn1 );
print $blrules <<'EOF';
#
# Shorewall version 5.0 - Blacklist Rules File
@@ -393,7 +395,7 @@ sub convert_routestopped() {
my ( @allhosts, %source, %dest , %notrack, @rule );
my $seq = 0;
my $date = localtime;
my $date = compiletime;
my ( $stoppedrules, $fn1 );
@@ -401,6 +403,7 @@ sub convert_routestopped() {
open $stoppedrules, '>>', $fn1 or fatal_error "Unable to open $fn1: $!";
} else {
open $stoppedrules, '>', $fn1 or fatal_error "Unable to open $fn1: $!";
transfer_permissions( $fn, $fn1 );
print $stoppedrules <<'EOF';
#
# Shorewall version 5 - Stopped Rules File
@@ -421,7 +424,7 @@ EOF
first_entry(
sub {
my $date = localtime;
my $date = compiletime;
progress_message2 "$doing $fn...";
print( $stoppedrules
"#\n" ,
@@ -646,11 +649,18 @@ sub create_docker_rules() {
add_commands( $chainref, 'if [ -n "$g_docker" ]; then' );
incr_cmd_level( $chainref );
add_ijump( $chainref, j => 'DOCKER', o => 'docker0' );
add_ijump( $chainref, j => 'ACCEPT', o => 'docker0', state_imatch 'ESTABLISHED,RELATED' );
add_ijump( $chainref, j => 'ACCEPT', i => 'docker0', o => '! docker0' );
add_ijump( $chainref, j => 'ACCEPT', i => 'docker0', o => 'docker0' ) if $dockerref->{options}{routeback};
add_ijump( $filter_table->{OUTPUT}, j => 'DOCKER' );
decr_cmd_level( $chainref );
add_commands( $chainref, 'fi' );
my $outputref;
add_commands( $outputref = $filter_table->{OUTPUT}, 'if [ -n "$g_docker" ]; then' );
incr_cmd_level( $outputref );
add_ijump( $outputref, j => 'DOCKER' );
decr_cmd_level( $outputref );
add_commands( $outputref, 'fi' );
}
add_commands( $chainref, '[ -f ${VARDIR}/.filter_FORWARD ] && cat $VARDIR/.filter_FORWARD >&3', );
@@ -674,16 +684,123 @@ sub add_common_rules ( $ ) {
my $level = $config{BLACKLIST_LOG_LEVEL};
my $tag = $globals{BLACKLIST_LOG_TAG};
my $rejectref = $filter_table->{reject};
my $dbl_type;
my $dbl_ipset;
my $dbl_level;
my $dbl_tag;
my $dbl_src_target;
my $dbl_dst_target;
if ( $config{REJECT_ACTION} ) {
process_reject_action;
fatal_eror( "The REJECT_ACTION ($config{REJECT_ACTION}) is not terminating" ) unless terminating( $rejectref );
} else {
if ( have_capability( 'ADDRTYPE' ) ) {
add_ijump $rejectref , j => 'DROP' , addrtype => '--src-type BROADCAST';
} else {
if ( $family == F_IPV4 ) {
add_commands $rejectref, 'for address in $ALL_BCASTS; do';
} else {
add_commands $rejectref, 'for address in $ALL_ACASTS; do';
}
incr_cmd_level $rejectref;
add_ijump $rejectref, j => 'DROP', d => '$address';
decr_cmd_level $rejectref;
add_commands $rejectref, 'done';
}
if ( $family == F_IPV4 ) {
add_ijump $rejectref , j => 'DROP', s => '224.0.0.0/4';
} else {
add_ijump $rejectref , j => 'DROP', s => IPv6_MULTICAST;
}
add_ijump $rejectref , j => 'DROP', p => 2;
add_ijump $rejectref , j => 'REJECT', targetopts => '--reject-with tcp-reset', p => 6;
if ( have_capability( 'ENHANCED_REJECT' ) ) {
add_ijump $rejectref , j => 'REJECT', p => 17;
if ( $family == F_IPV4 ) {
add_ijump $rejectref, j => 'REJECT --reject-with icmp-host-unreachable', p => 1;
add_ijump $rejectref, j => 'REJECT --reject-with icmp-host-prohibited';
} else {
add_ijump $rejectref, j => 'REJECT --reject-with icmp6-addr-unreachable', p => 58;
add_ijump $rejectref, j => 'REJECT --reject-with icmp6-adm-prohibited';
}
} else {
add_ijump $rejectref , j => 'REJECT';
}
}
#
# Insure that Docker jumps are early in the builtin chains
#
create_docker_rules if $config{DOCKER};
if ( $config{DYNAMIC_BLACKLIST} ) {
add_rule_pair( set_optflags( new_standard_chain( 'logdrop' ) , DONT_OPTIMIZE | DONT_DELETE ), '' , 'DROP' , $level , $tag);
add_rule_pair( set_optflags( new_standard_chain( 'logreject' ), DONT_OPTIMIZE | DONT_DELETE ), '' , 'reject' , $level , $tag);
$dynamicref = set_optflags( new_standard_chain( 'dynamic' ) , DONT_OPTIMIZE );
add_commands( $dynamicref, '[ -f ${VARDIR}/.dynamic ] && cat ${VARDIR}/.dynamic >&3' );
if ( my $val = $config{DYNAMIC_BLACKLIST} ) {
( $dbl_type, $dbl_ipset, $dbl_level, $dbl_tag ) = split( ':', $val );
unless ( $dbl_type =~ /^ipset-only/ ) {
add_rule_pair( set_optflags( new_standard_chain( 'logdrop' ) , DONT_OPTIMIZE | DONT_DELETE ), '' , 'DROP' , $level , $tag);
add_rule_pair( set_optflags( new_standard_chain( 'logreject' ), DONT_OPTIMIZE | DONT_DELETE ), '' , 'reject' , $level , $tag);
$dynamicref = set_optflags( new_standard_chain( 'dynamic' ) , DONT_OPTIMIZE );
add_commands( $dynamicref, '[ -f ${VARDIR}/.dynamic ] && cat ${VARDIR}/.dynamic >&3' );
}
if ( $dbl_ipset ) {
if ( $val = $globals{DBL_TIMEOUT} ) {
$dbl_src_target = $globals{DBL_OPTIONS} =~ /src-dst/ ? 'dbl_src' : 'dbl_log';
my $chainref = set_optflags( new_standard_chain( $dbl_src_target ) , DONT_OPTIMIZE | DONT_DELETE );
log_rule_limit( $dbl_level,
$chainref,
'dbl_log',
'DROP',
$globals{LOGLIMIT},
$dbl_tag,
'add',
'',
$origin{DYNAMIC_BLACKLIST} ) if $dbl_level;
add_ijump_extended( $chainref, j => "SET --add-set $dbl_ipset src --exist --timeout $val", $origin{DYNAMIC_BLACKLIST} );
add_ijump_extended( $chainref, j => 'DROP', $origin{DYNAMIC_BLACKLIST} );
if ( $dbl_src_target eq 'dbl_src' ) {
$chainref = set_optflags( new_standard_chain( $dbl_dst_target = 'dbl_dst' ) , DONT_OPTIMIZE | DONT_DELETE );
log_rule_limit( $dbl_level,
$chainref,
'dbl_log',
'DROP',
$globals{LOGLIMIT},
$dbl_tag,
'add',
'',
$origin{DYNAMIC_BLACKLIST} ) if $dbl_level;
add_ijump_extended( $chainref, j => "SET --add-set $dbl_ipset dst --exist --timeout $val", $origin{DYNAMIC_BLACKLIST} );
add_ijump_extended( $chainref, j => 'DROP', $origin{DYNAMIC_BLACKLIST} );
} else {
$dbl_dst_target = $dbl_src_target;
}
} elsif ( $dbl_level ) {
my $chainref = set_optflags( new_standard_chain( $dbl_src_target = 'dbl_log' ) , DONT_OPTIMIZE | DONT_DELETE );
log_rule_limit( $dbl_level,
$chainref,
'dbl_log',
'DROP',
$globals{LOGLIMIT},
$dbl_tag,
'add',
'',
$origin{DYNAMIC_BLACKLIST} );
add_ijump_extended( $chainref, j => 'DROP', $origin{DYNAMIC_BLACKLIST} );
} else {
$dbl_src_target = $dbl_dst_target = 'DROP';
}
}
}
setup_mss;
@@ -787,8 +904,30 @@ sub add_common_rules ( $ ) {
}
}
if ( $dbl_ipset && ( ( my $setting = get_interface_option( $interface, 'dbl' ) ) ne '0:0' ) ) {
my ( $in, $out ) = split /:/, $setting;
if ( $in == 1 ) {
#
# src
#
add_ijump_extended( $filter_table->{input_option_chain($interface)}, j => $dbl_src_target, $origin{DYNAMIC_BLACKLIST}, @state, set => "--match-set $dbl_ipset src" );
add_ijump_extended( $filter_table->{forward_option_chain($interface)}, j => $dbl_src_target, $origin{DYNAMIC_BLACKLIST}, @state, set => "--match-set $dbl_ipset src" );
} elsif ( $in == 2 ) {
add_ijump_extended( $filter_table->{forward_option_chain($interface)}, j => $dbl_dst_target, $origin{DYNAMIC_BLACKLIST}, @state, set => "--match-set $dbl_ipset dst" );
}
if ( $out == 2 ) {
#
# dst
#
add_ijump_extended( $filter_table->{output_option_chain($interface)}, j => $dbl_dst_target, $origin{DYNAMIC_BLACKLIST}, @state, set => "--match-set $dbl_ipset dst" );
}
}
for ( option_chains( $interface ) ) {
add_ijump_extended( $filter_table->{$_}, j => $dynamicref, $origin{DYNAMIC_BLACKLIST}, @state ) if $dynamicref;
add_ijump_extended( $filter_table->{$_}, j => $dynamicref, $origin{DYNAMIC_BLACKLIST}, @state ) if $dynamicref && ( get_interface_option( $interface, 'dbl' ) ne '0:0' );
add_ijump_extended( $filter_table->{$_}, j => 'ACCEPT', $origin{FASTACCEPT}, state_imatch $faststate )->{comment} = '' if $config{FASTACCEPT};
}
}
@@ -947,46 +1086,6 @@ sub add_common_rules ( $ ) {
}
}
unless ( $config{REJECT_ACTION} ) {
if ( have_capability( 'ADDRTYPE' ) ) {
add_ijump $rejectref , j => 'DROP' , addrtype => '--src-type BROADCAST';
} else {
if ( $family == F_IPV4 ) {
add_commands $rejectref, 'for address in $ALL_BCASTS; do';
} else {
add_commands $rejectref, 'for address in $ALL_ACASTS; do';
}
incr_cmd_level $rejectref;
add_ijump $rejectref, j => 'DROP', d => '$address';
decr_cmd_level $rejectref;
add_commands $rejectref, 'done';
}
if ( $family == F_IPV4 ) {
add_ijump $rejectref , j => 'DROP', s => '224.0.0.0/4';
} else {
add_ijump $rejectref , j => 'DROP', s => IPv6_MULTICAST;
}
add_ijump $rejectref , j => 'DROP', p => 2;
add_ijump $rejectref , j => 'REJECT', targetopts => '--reject-with tcp-reset', p => 6;
if ( have_capability( 'ENHANCED_REJECT' ) ) {
add_ijump $rejectref , j => 'REJECT', p => 17;
if ( $family == F_IPV4 ) {
add_ijump $rejectref, j => 'REJECT --reject-with icmp-host-unreachable', p => 1;
add_ijump $rejectref, j => 'REJECT --reject-with icmp-host-prohibited';
} else {
add_ijump $rejectref, j => 'REJECT --reject-with icmp6-addr-unreachable', p => 58;
add_ijump $rejectref, j => 'REJECT --reject-with icmp6-adm-prohibited';
}
} else {
add_ijump $rejectref , j => 'REJECT';
}
}
$list = find_interfaces_by_option 'dhcp';
if ( @$list ) {
@@ -1112,8 +1211,8 @@ sub add_common_rules ( $ ) {
$announced = 1;
for $interface ( @$list ) {
add_ijump_extended $nat_table->{PREROUTING} , j => 'UPnP', get_interface_origin($interface), imatch_source_dev ( $interface );
add_ijump_extended $nat_table->{POSTROUTING} , j => 'MINIUPNPD-POSTROUTING' , $origin{MINIUPNPD} , imatch_dest_dev ( $interface ) if $chainref1;
add_ijump_extended $nat_table->{PREROUTING} , j => 'UPnP', get_interface_origin($interface), imatch_source_dev ( $interface );
add_ijump_extended $nat_table->{$globals{POSTROUTING}} , j => 'MINIUPNPD-POSTROUTING' , $origin{MINIUPNPD} , imatch_dest_dev ( $interface ) if $chainref1;
}
}
@@ -1801,12 +1900,14 @@ sub add_output_jumps( $$$$$$$$ ) {
my $use_output = 0;
my @dest = imatch_dest_net $net;
my @ipsec_out_match = match_ipsec_out $zone , $hostref;
my @zone_interfaces = keys %{zone_interfaces( $zone )};
if ( @vservers || use_output_chain( $interface, $interfacechainref ) || ( @{$interfacechainref->{rules}} && ! $chain1ref ) ) {
if ( @vservers || use_output_chain( $interface, $interfacechainref ) || ( @{$interfacechainref->{rules}} && ! $chain1ref ) || @zone_interfaces > 1 ) {
#
# - 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
# - The zone has multiple interfaces
#
# In any of these cases use the inteface output chain
#
@@ -1823,7 +1924,7 @@ sub add_output_jumps( $$$$$$$$ ) {
unless $output_jump_added{$interface}++;
} else {
#
# Not a bridge -- match the input interface
# Not a bridge -- match the output interface
#
add_ijump_extended $filter_table->{OUTPUT}, j => $outputref, $origin, imatch_dest_dev( $interface ) unless $output_jump_added{$interface}++;
}
@@ -2433,16 +2534,16 @@ EOF
emit <<'EOF';
case $COMMAND in
start)
logger -p kern.err "ERROR:$g_product start failed"
mylogger kern.err "ERROR:$g_product start failed"
;;
reload)
logger -p kern.err "ERROR:$g_product reload failed"
mylogger kern.err "ERROR:$g_product reload failed"
;;
refresh)
logger -p kern.err "ERROR:$g_product refresh failed"
mylogger kern.err "ERROR:$g_product refresh failed"
;;
enable)
logger -p kern.err "ERROR:$g_product 'enable $g_interface' failed"
mylogger kern.err "ERROR:$g_product 'enable $g_interface' failed"
;;
esac
@@ -2651,7 +2752,7 @@ EOF
emit '
set_state "Stopped"
logger -p kern.info "$g_product Stopped"
mylogger kern.info "$g_product Stopped"
case $COMMAND in
stop|clear)

View File

@@ -125,6 +125,13 @@ sub setup_route_marking() {
my $exmask = have_capability( 'EXMARK' ) ? "/$mask" : '';
require_capability( $_ , q(The provider 'track' option) , 's' ) for qw/CONNMARK_MATCH CONNMARK/;
#
# Clear the mark -- we have seen cases where the mark is non-zero even in the raw table chains!
#
if ( $config{ZERO_MARKS} ) {
add_ijump( $mangle_table->{$_}, j => 'MARK', targetopts => '--set-mark 0' ) for qw/PREROUTING OUTPUT/;
}
if ( $config{RESTORE_ROUTEMARKS} ) {
add_ijump $mangle_table->{$_} , j => 'CONNMARK', targetopts => "--restore-mark --mask $mask" for qw/PREROUTING OUTPUT/;
@@ -302,27 +309,14 @@ sub balance_default_route( $$$$ ) {
emit '';
if ( $first_default_route ) {
if ( $family == F_IPV4 ) {
if ( $gateway ) {
emit "DEFAULT_ROUTE=\"nexthop via $gateway dev $interface weight $weight $realm\"";
} else {
emit "DEFAULT_ROUTE=\"nexthop dev $interface weight $weight $realm\"";
}
if ( $gateway ) {
emit "DEFAULT_ROUTE=\"nexthop via $gateway dev $interface weight $weight $realm\"";
} else {
#
# IPv6 doesn't support multi-hop routes
#
if ( $gateway ) {
emit "DEFAULT_ROUTE=\"via $gateway dev $interface $realm\"";
} else {
emit "DEFAULT_ROUTE=\"dev $interface $realm\"";
}
emit "DEFAULT_ROUTE=\"nexthop dev $interface weight $weight $realm\"";
}
$first_default_route = 0;
} else {
fatal_error "Only one 'balance' provider is allowed with IPv6" if $family == F_IPV6;
if ( $gateway ) {
emit "DEFAULT_ROUTE=\"\$DEFAULT_ROUTE nexthop via $gateway dev $interface weight $weight $realm\"";
} else {
@@ -339,27 +333,14 @@ sub balance_fallback_route( $$$$ ) {
emit '';
if ( $first_fallback_route ) {
if ( $family == F_IPV4 ) {
if ( $gateway ) {
emit "FALLBACK_ROUTE=\"nexthop via $gateway dev $interface weight $weight $realm\"";
} else {
emit "FALLBACK_ROUTE=\"nexthop dev $interface weight $weight $realm\"";
}
if ( $gateway ) {
emit "FALLBACK_ROUTE=\"nexthop via $gateway dev $interface weight $weight $realm\"";
} else {
#
# IPv6 doesn't support multi-hop routes
#
if ( $gateway ) {
emit "FALLBACK_ROUTE=\"via $gateway dev $interface $realm\"";
} else {
emit "FALLBACK_ROUTE=\"dev $interface $realm\"";
}
emit "FALLBACK_ROUTE=\"nexthop dev $interface weight $weight $realm\"";
}
$first_fallback_route = 0;
} else {
fatal_error "Only one 'fallback' provider is allowed with IPv6" if $family == F_IPV6;
if ( $gateway ) {
emit "FALLBACK_ROUTE=\"\$FALLBACK_ROUTE nexthop via $gateway dev $interface weight $weight $realm\"";
} else {
@@ -392,7 +373,7 @@ sub start_provider( $$$$$ ) {
}
#
# Look up a provider and return it's number. If unknown provider, 0 is returned
# Look up a provider and return a reference to its table entry. If unknown provider, undef is returned
#
sub lookup_provider( $ ) {
my $provider = $_[0];
@@ -408,7 +389,7 @@ sub lookup_provider( $ ) {
}
}
$providerref ? $providerref->{number} : 0;
$providerref;
}
#
@@ -535,7 +516,6 @@ sub process_a_provider( $ ) {
$track = 0;
} elsif ( $option =~ /^balance=(\d+)$/ ) {
fatal_error q('balance' may not be spacified when GATEWAY is 'none') if $gatewaycase eq 'none';
fatal_error q('balance=<weight>' is not available in IPv6) if $family == F_IPV6;
fatal_error 'The balance setting must be non-zero' unless $1;
$balance = $1;
} elsif ( $option eq 'balance' || $option eq 'primary') {
@@ -558,7 +538,6 @@ sub process_a_provider( $ ) {
$mtu = "mtu $1 ";
} elsif ( $option =~ /^fallback=(\d+)$/ ) {
fatal_error q('fallback' may not be spacified when GATEWAY is 'none') if $gatewaycase eq 'none';
fatal_error q('fallback=<weight>' is not available in IPv6) if $family == F_IPV6;
$default = $1;
$default_balance = 0;
fatal_error 'fallback must be non-zero' unless $default;
@@ -666,7 +645,9 @@ sub process_a_provider( $ ) {
if ( $duplicate ne '-' ) {
fatal_error "The DUPLICATE column must be empty when USE_DEFAULT_RT=Yes" if $config{USE_DEFAULT_RT};
my $p = lookup_provider( $duplicate );
warning_message "Unknown routing table ($duplicate)" unless $p && ( $p == MAIN_TABLE || $p < BALANCE_TABLE );
my $n = $p ? $p->{number} : 0;
warning_message "Unknown routing table ($duplicate)" unless $n && ( $n == MAIN_TABLE || $n < BALANCE_TABLE );
warning_message "An optional provider ($duplicate) is listed in the DUPLICATE column - enable and disable will not work correctly on that provider" if $p && $p->{optional};
} elsif ( $copy ne '-' ) {
fatal_error "The COPY column must be empty when USE_DEFAULT_RT=Yes" if $config{USE_DEFAULT_RT};
fatal_error 'A non-empty COPY column requires that a routing table be specified in the DUPLICATE column' unless $copy eq 'none';
@@ -684,6 +665,7 @@ sub process_a_provider( $ ) {
interface => $interface ,
physical => $physical ,
optional => $optional ,
wildcard => $interfaceref->{wildcard} || 0,
gateway => $gateway ,
gatewaycase => $gatewaycase ,
shared => $shared ,
@@ -799,6 +781,10 @@ sub add_a_provider( $$ ) {
push_indent;
emit( "if interface_is_up $physical; then" );
push_indent;
if ( $gatewaycase eq 'omitted' ) {
if ( $tproxy ) {
emit 'run_ip route add local ' . ALLIP . " dev $physical table $id";
@@ -813,17 +799,14 @@ sub add_a_provider( $$ ) {
emit( qq([ -z "$address" ] && return\n) );
if ( $hostroute ) {
if ( $family == F_IPV4 ) {
emit qq(run_ip route replace $gateway src $address dev $physical ${mtu});
emit qq(run_ip route replace $gateway src $address dev $physical ${mtu}table $id $realm);
} else {
emit qq(qt \$IP -6 route add $gateway src $address dev $physical ${mtu});
emit qq(qt \$IP -6 route del $gateway src $address dev $physical ${mtu}table $id $realm);
emit qq(run_ip route add $gateway src $address dev $physical ${mtu}table $id $realm);
}
emit qq(run_ip route replace $gateway src $address dev $physical ${mtu});
emit qq(run_ip route replace $gateway src $address dev $physical ${mtu}table $id $realm);
emit qq(echo "\$IP route del $gateway src $address dev $physical ${mtu} > /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing);
emit qq(echo "\$IP route del $gateway src $address dev $physical ${mtu}table $id $realm > /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing);
}
emit "run_ip route add default via $gateway src $address dev $physical ${mtu}table $id $realm";
emit( "run_ip route add default via $gateway src $address dev $physical ${mtu}table $id $realm" );
emit( qq( echo "\$IP route del default via $gateway src $address dev $physical ${mtu}table $id $realm > /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing) );
}
if ( ! $noautosrc ) {
@@ -852,8 +835,10 @@ sub add_a_provider( $$ ) {
}
}
emit( qq(\n),
qq(rm -f \${VARDIR}/${physical}_enabled) );
pop_indent;
emit( qq(fi\n),
qq(echo 1 > \${VARDIR}/${physical}_disabled) );
pop_indent;
@@ -938,14 +923,8 @@ CEOF
$address = get_interface_address $interface unless $address;
if ( $hostroute ) {
if ( $family == F_IPV4 ) {
emit qq(run_ip route replace $gateway src $address dev $physical ${mtu});
emit qq(run_ip route replace $gateway src $address dev $physical ${mtu}table $id $realm);
} else {
emit qq(qt \$IP -6 route add $gateway src $address dev $physical ${mtu});
emit qq(qt \$IP -6 route del $gateway src $address dev $physical ${mtu}table $id $realm);
emit qq(run_ip route add $gateway src $address dev $physical ${mtu}table $id $realm);
}
emit qq(run_ip route replace $gateway src $address dev $physical ${mtu});
emit qq(run_ip route replace $gateway src $address dev $physical ${mtu}table $id $realm);
}
emit "run_ip route add default via $gateway src $address dev $physical ${mtu}table $id $realm";
@@ -959,13 +938,8 @@ CEOF
my $id = $providers{default}->{id};
emit '';
if ( $gateway ) {
if ( $family == F_IPV4 ) {
emit qq(run_ip route replace $gateway/32 dev $physical table $id) if $hostroute;
emit qq(run_ip route add default via $gateway src $address dev $physical table $id metric $number);
} else {
emit qq(qt \$IP -6 route del default via $gateway src $address dev $physical table $id metric $number);
emit qq(run_ip route add default via $gateway src $address dev $physical table $id metric $number);
}
emit qq(run_ip route replace $gateway/32 dev $physical table $id) if $hostroute;
emit qq(run_ip route add default via $gateway src $address dev $physical table $id metric $number);
emit qq(echo "\$IP -$family route del default via $gateway table $id > /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing);
emit qq(echo "\$IP -4 route del $gateway/32 dev $physical table $id > /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing) if $family == F_IPV4;
} else {
@@ -1041,23 +1015,12 @@ CEOF
$tbl = $providers{$default ? 'default' : $config{USE_DEFAULT_RT} ? 'balance' : 'main'}->{id};
$weight = $balance ? $balance : $default;
if ( $family == F_IPV4 ) {
if ( $gateway ) {
emit qq(add_gateway "nexthop via $gateway dev $physical weight $weight $realm" ) . $tbl;
} else {
emit qq(add_gateway "nexthop dev $physical weight $weight $realm" ) . $tbl;
}
if ( $gateway ) {
emit qq(add_gateway "nexthop via $gateway dev $physical weight $weight $realm" ) . $tbl;
} else {
#
# IPv6 doesn't support multi-hop routes
#
if ( $gateway ) {
emit qq(add_gateway "via $gateway dev $physical $realm" ) . $tbl;
} else {
emit qq(add_gateway "dev $physical $realm" ) . $tbl;
}
emit qq(add_gateway "nexthop dev $physical weight $weight $realm" ) . $tbl;
}
} else {
} else {
$weight = 1;
}
@@ -1067,7 +1030,7 @@ CEOF
emit( "setup_${dev}_tc" ) if $tcdevices->{$interface};
}
emit( qq( echo 1 > \${VARDIR}/${physical}_enabled) ) if $persistent;
emit( qq(rm -f \${VARDIR}/${physical}_disabled) );
emit_started_message( '', 2, $pseudo, $table, $number );
pop_indent;
@@ -1075,7 +1038,7 @@ CEOF
unless ( $pseudo ) {
emit( 'else' );
emit( qq( echo $weight > \${VARDIR}/${physical}_weight) );
emit( qq( echo 1 > \${VARDIR}/${physical}_enabled) ) if $persistent;
emit( qq( rm -f \${VARDIR}/${physical}_disabled) ) if $persistent;
emit_started_message( ' ', '', $pseudo, $table, $number );
}
@@ -1094,7 +1057,7 @@ CEOF
if ( $optional ) {
if ( $persistent ) {
emit( "persistent_${what}_${table}\n" );
emit( "do_persistent_${what}_${table}\n" );
}
if ( $shared ) {
@@ -1147,7 +1110,7 @@ CEOF
$via = "dev $physical";
}
$via .= " weight $weight" unless $weight < 0 or $family == F_IPV6; # IPv6 doesn't support route weights
$via .= " weight $weight" unless $weight < 0;
$via .= " $realm" if $realm;
emit( qq(delete_gateway "$via" $tbl $physical) );
@@ -1169,7 +1132,7 @@ CEOF
'if [ $COMMAND = disable ]; then',
" do_persistent_${what}_${table}",
"else",
" rm -f \${VARDIR}/${physical}_enabled\n",
" echo 1 > \${VARDIR}/${physical}_disabled\n",
"fi\n",
);
}
@@ -1496,12 +1459,7 @@ sub finish_providers() {
if ( $balancing ) {
emit ( 'if [ -n "$DEFAULT_ROUTE" ]; then' );
if ( $family == F_IPV4 ) {
emit ( " run_ip route replace default scope global table $table \$DEFAULT_ROUTE" );
} else {
emit ( " qt \$IP -6 route del default scope global table $table \$DEFAULT_ROUTE" );
emit ( " run_ip route add default scope global table $table \$DEFAULT_ROUTE" );
}
emit ( " run_ip route replace default scope global table $table \$DEFAULT_ROUTE" );
if ( $config{USE_DEFAULT_RT} ) {
emit ( " while qt \$IP -$family route del default table $main; do",
@@ -1554,12 +1512,7 @@ sub finish_providers() {
if ( $fallback ) {
emit ( 'if [ -n "$FALLBACK_ROUTE" ]; then' );
if ( $family == F_IPV4 ) {
emit( " run_ip route replace default scope global table $default \$FALLBACK_ROUTE" );
} else {
emit( " qt \$IP -6 route del default scope global table $default \$FALLBACK_ROUTE" );
emit( " run_ip route add default scope global table $default \$FALLBACK_ROUTE" );
}
emit( " run_ip route replace default scope global table $default \$FALLBACK_ROUTE" );
emit( " progress_message \"Fallback route '\$(echo \$FALLBACK_ROUTE | sed 's/\$\\s*//')' Added\"",
'else',
@@ -1674,7 +1627,7 @@ EOF
emit ( " if [ ! -f \${VARDIR}/undo_${provider}_routing ]; then",
" start_interface_$provider" );
} elsif ( $providerref->{persistent} ) {
emit ( " if [ ! -f \${VARDIR}/$providerref->{physical}_enabled ]; then",
emit ( " if [ -f \${VARDIR}/$providerref->{physical}_disabled ]; then",
" start_provider_$provider" );
} else {
emit ( " if [ -z \"`\$IP -$family route ls table $providerref->{number}`\" ]; then",
@@ -1725,7 +1678,7 @@ EOF
if ( $providerref->{pseudo} ) {
emit( " if [ -f \${VARDIR}/undo_${provider}_routing ]; then" );
} elsif ( $providerref->{persistent} ) {
emit( " if [ -f \${VARDIR}/$providerref->{physical}_enabled ]; then" );
emit( " if [ ! -f \${VARDIR}/$providerref->{physical}_disabled ]; then" );
} else {
emit( " if [ -n \"`\$IP -$family route ls table $providerref->{number}`\" ]; then" );
}
@@ -2111,9 +2064,31 @@ sub provider_realm( $ ) {
#
sub handle_optional_interfaces( $ ) {
my ( $interfaces, $wildcards ) = find_interfaces_by_option1 'optional';
my @interfaces;
my $wildcards;
if ( @$interfaces ) {
#
# First do the provider interfacess. Those that are real providers will never have wildcard physical
# names but they might derive from wildcard interface entries. Optional interfaces which do not have
# wildcard physical names are also included in the providers table.
#
for my $providerref ( grep $_->{optional} , sort { $a->{number} <=> $b->{number} } values %providers ) {
push @interfaces, $providerref->{interface};
$wildcards ||= $providerref->{wildcard};
}
#
# Now do the optional wild interfaces
#
for my $interface ( grep interface_is_optional($_) && ! $provider_interfaces{$_}, all_real_interfaces ) {
push@interfaces, $interface;
unless ( $wildcards ) {
my $interfaceref = find_interface($interface);
$wildcards = 1 if $interfaceref->{wildcard};
}
}
if ( @interfaces ) {
my $require = $config{REQUIRE_INTERFACE};
my $gencase = shift;
@@ -2124,7 +2099,7 @@ sub handle_optional_interfaces( $ ) {
#
# Clear the '_IS_USABLE' variables
#
emit( join( '_', 'SW', uc var_base( get_physical( $_ ) ) , 'IS_USABLE=' ) ) for @$interfaces;
emit( join( '_', 'SW', uc var_base( get_physical( $_ ) ) , 'IS_USABLE=' ) ) for @interfaces;
if ( $wildcards ) {
#
@@ -2141,74 +2116,76 @@ sub handle_optional_interfaces( $ ) {
emit '';
}
for my $interface ( grep $provider_interfaces{$_}, @$interfaces ) {
my $provider = $provider_interfaces{$interface};
my $physical = get_physical $interface;
my $base = uc var_base( $physical );
my $providerref = $providers{$provider};
for my $interface ( @interfaces ) {
if ( my $provider = $provider_interfaces{ $interface } ) {
my $physical = get_physical $interface;
my $base = uc var_base( $physical );
my $providerref = $providers{$provider};
my $interfaceref = known_interface( $interface );
my $wildbase = uc $interfaceref->{base};
emit( "$physical)" ), push_indent if $wildcards;
emit( "$physical)" ), push_indent if $wildcards;
if ( $provider eq $physical ) {
#
# Just an optional interface, or provider and interface are the same
#
emit qq(if [ -z "\$interface" -o "\$interface" = "$physical" ]; then);
} else {
#
# Provider
#
emit qq(if [ -z "\$interface" -o "\$interface" = "$physical" ]; then);
}
if ( $provider eq $physical ) {
#
# Just an optional interface, or provider and interface are the same
#
emit qq(if [ -z "\$interface" -o "\$interface" = "$physical" ]; then);
} else {
#
# Provider
#
emit qq(if [ -z "\$interface" -o "\$interface" = "$physical" ]; then);
}
push_indent;
if ( $providerref->{gatewaycase} eq 'detect' ) {
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
} else {
emit qq(if interface_is_usable $physical; then);
}
emit( ' HAVE_INTERFACE=Yes' ) if $require;
emit( " SW_${base}_IS_USABLE=Yes" ,
'fi' );
pop_indent;
emit( "fi\n" );
emit( ';;' ), pop_indent if $wildcards;
}
for my $interface ( grep ! $provider_interfaces{$_}, @$interfaces ) {
my $physical = get_physical $interface;
my $base = uc var_base( $physical );
my $case = $physical;
my $wild = $case =~ s/\+$/*/;
if ( $wildcards ) {
emit( "$case)" );
push_indent;
if ( $providerref->{gatewaycase} eq 'detect' ) {
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
} else {
emit qq(if interface_is_usable $physical; then);
}
if ( $wild ) {
emit( qq(if [ -z "\$SW_${base}_IS_USABLE" ]; then) );
emit( ' HAVE_INTERFACE=Yes' ) if $require;
emit( " SW_${base}_IS_USABLE=Yes" );
emit( " SW_${wildbase}_IS_USABLE=Yes" ) if $interfaceref->{wildcard};
emit( 'fi' );
pop_indent;
emit( "fi\n" );
emit( ';;' ), pop_indent if $wildcards;
} else {
my $physical = get_physical $interface;
my $base = uc var_base( $physical );
my $case = $physical;
my $wild = $case =~ s/\+$/*/;
if ( $wildcards ) {
emit( "$case)" );
push_indent;
emit ( 'if interface_is_usable $interface; then' );
if ( $wild ) {
emit( qq(if [ -z "\$SW_${base}_IS_USABLE" ]; then) );
push_indent;
emit ( 'if interface_is_usable $interface; then' );
} else {
emit ( "if interface_is_usable $physical; then" );
}
} else {
emit ( "if interface_is_usable $physical; then" );
}
} else {
emit ( "if interface_is_usable $physical; then" );
}
emit ( ' HAVE_INTERFACE=Yes' ) if $require;
emit ( " SW_${base}_IS_USABLE=Yes" ,
'fi' );
emit ( ' HAVE_INTERFACE=Yes' ) if $require;
emit ( " SW_${base}_IS_USABLE=Yes" ,
'fi' );
if ( $wildcards ) {
pop_indent, emit( 'fi' ) if $wild;
emit( ';;' );
pop_indent;
if ( $wildcards ) {
pop_indent, emit( 'fi' ) if $wild;
emit( ';;' );
pop_indent;
}
}
}

View File

@@ -368,12 +368,19 @@ sub setup_conntrack($) {
if ( $convert ) {
my $conntrack;
my $empty = 1;
my $date = localtime;
my $date = compiletime;
my $fn1 = find_writable_file 'conntrack';
if ( $fn ) {
open $conntrack, '>>', $fn or fatal_error "Unable to open $fn for notrack conversion: $!";
$fn = open_file( 'notrack' , 3, 1 ) || fatal_error "Unable to open the notrack file for conversion: $!";
if ( -f $fn1 ) {
open $conntrack, '>>', $fn1 or fatal_error "Unable to open $fn for notrack conversion: $!";
} else {
open $conntrack, '>', $fn = find_file 'conntrack' or fatal_error "Unable to open $fn for notrack conversion: $!";
open $conntrack, '>' , $fn1 or fatal_error "Unable to open $fn for notrack conversion: $!";
#
# Transfer permissions from the existing notrack file
#
transfer_permissions( $fn, $fn1 );
print $conntrack <<'EOF';
#
@@ -396,8 +403,6 @@ EOF
"# Rules generated from notrack file $fn by Shorewall $globals{VERSION} - $date\n" ,
"#\n" );
$fn = open_file( 'notrack' , 3, 1 ) || fatal_error "Unable to open the notrack file for conversion: $!";
while ( read_a_line( PLAIN_READ ) ) {
#
# Don't copy the header comments from the old notrack file

View File

@@ -295,7 +295,7 @@ our %validstates = ( NEW => 0,
# known until the compiler has started.
#
# 2. The compiler can run multiple times in the same process so it has to be
# able to re-initialize its dependent modules' state.
# able to re-initialize the state of its dependent modules.
#
sub initialize( $ ) {
$family = shift;
@@ -345,11 +345,11 @@ sub initialize( $ ) {
#
$macro_nest_level = 0;
#
# All builtin actions plus those mentioned in /etc/shorewall[6]/actions and /usr/share/shorewall[6]/actions
# All builtin actions plus those mentioned in /etc/shorewall[6]/actions and /usr/share/shorewall[6]/actions.std
#
%actions = ();
#
# Action variants actually used. Key is <action>:<loglevel>:<tag>:<params>; value is corresponding chain name
# Action variants actually used. Key is <action>:<loglevel>:<tag>:<caller>:<params>; value is corresponding chain name
#
%usedactions = ();
@@ -628,29 +628,20 @@ sub handle_nfqueue( $$ ) {
#
# Process an entry in the policy file.
#
sub process_a_policy() {
sub process_a_policy1($$$$$$$) {
our %validpolicies;
our @zonelist;
my ( $client, $server, $originalpolicy, $loglevel, $synparams, $connlimit ) =
split_line 'policy file', { source => 0, dest => 1, policy => 2, loglevel => 3, limit => 4, connlimit => 5 } ;
$loglevel = '' if $loglevel eq '-';
$synparams = '' if $synparams eq '-';
$connlimit = '' if $connlimit eq '-';
fatal_error 'SOURCE must be specified' if $client eq '-';
fatal_error 'DEST must be specified' if $server eq '-';
fatal_error 'POLICY must be specified' if $originalpolicy eq '-';
my ( $client, $server, $originalpolicy, $loglevel, $synparams, $connlimit, $intrazone ) = @_;
my $clientwild = ( "\L$client" =~ /^all(\+)?$/ );
my $intrazone = $clientwild && $1;
$intrazone = $clientwild && $1;
fatal_error "Undefined zone ($client)" unless $clientwild || defined_zone( $client );
my $serverwild = ( "\L$server" =~ /^all(\+)?/ );
$intrazone ||= $serverwild && $1;
$intrazone ||= ( $serverwild && $1 );
fatal_error "Undefined zone ($server)" unless $serverwild || defined_zone( $server );
@@ -758,6 +749,40 @@ sub process_a_policy() {
}
}
sub process_a_policy() {
our %validpolicies;
our @zonelist;
my ( $clients, $servers, $policy, $loglevel, $synparams, $connlimit ) =
split_line 'policy file', { source => 0, dest => 1, policy => 2, loglevel => 3, limit => 4, connlimit => 5 } ;
$loglevel = '' if $loglevel eq '-';
$synparams = '' if $synparams eq '-';
$connlimit = '' if $connlimit eq '-';
my $intrazone;
if ( $intrazone = $clients =~ /.*,.*\+$/) {
$clients =~ s/\+$//;
}
if ( $servers =~ /.*,.*\+$/ ) {
$servers =~ s/\+$//;
$intrazone = 1;
}
fatal_error 'SOURCE must be specified' if $clients eq '-';
fatal_error 'DEST must be specified' if $servers eq '-';
fatal_error 'POLICY must be specified' if $policy eq '-';
for my $client ( split_list( $clients, 'zone' ) ) {
for my $server ( split_list( $servers, 'zone' ) ) {
process_a_policy1( $client, $server, $policy, $loglevel, $synparams, $connlimit, $intrazone );
}
}
}
#
# Generate contents of the /var/lib/shorewall[6]/.policies file as 'here documents' in the generated script
#
@@ -1352,7 +1377,7 @@ sub new_action( $$$$$ ) {
# Create and record a log action chain -- Log action chains have names
# that are formed from the action name by prepending a "%" and appending
# a 1- or 2-digit sequence number. In the functions that follow,
# the $chain, $level and $tag variable serves as arguments to the user's
# the $chain, $level and $tag variables serve as arguments to the user's
# exit. We call the exit corresponding to the name of the action but we
# set $chain to the name of the iptables chain where rules are to be added.
# Similarly, $level and $tag contain the log level and log tag respectively.
@@ -1533,7 +1558,7 @@ sub find_macro( $ )
{
my $macro = $_[0];
$macro =~ s/^macro.//;
$macro =~ s/^macro\.//;
my $macrofile = find_file "macro.$macro";
@@ -2193,10 +2218,16 @@ sub use_policy_action( $$ ) {
sub process_reject_action() {
my $rejectref = $filter_table->{reject};
my $action = $config{REJECT_ACTION};
#
# This gets called very early in the compilation process so we fake the section
#
$section = DEFAULTACTION_SECTION;
if ( ( $targets{$action} || 0 ) == ACTION ) {
add_ijump $rejectref, j => use_policy_action( $action, $rejectref->{name} );
} else {
progress_message2 "$doing $actions{$action}->{file} for chain reject...";
process_inline( $action, #Inline
$rejectref, #Chain
'', #Matches
@@ -2221,6 +2252,8 @@ sub process_reject_action() {
0, #Wildcard
);
}
$section = '';
}
################################################################################
@@ -2384,7 +2417,7 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$$$) {
setup_audit_action( $inline ) if $options & AUDIT_OPT;
progress_message "..Expanding inline action $inlinefile...";
progress_message "..Expanding inline action $inlinefile..." unless $inline eq $config{REJECT_ACTION};
push_open $inlinefile, 2, 1, undef , 2;
@@ -2858,7 +2891,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
fatal_error "A timeout may only be supplied in an ADD rule" unless $basictarget eq 'ADD';
fatal_error "Invalid Timeout ($timeout)" unless $timeout && $timeout =~ /^\d+$/;
$action .= " --timeout $timeout";
$action .= " --timeout $timeout --exist";
}
}
}
@@ -2949,65 +2982,63 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
# And we need the dest zone for local/loopback/off-firewall/destonly checks
#
$destref = find_zone( $chainref->{destzone} ) if $chainref->{destzone};
} else {
unless ( $actiontype & NATONLY ) {
#
# Check for illegal bridge port rule
#
if ( $destref->{type} & BPORT ) {
unless ( $sourceref->{bridge} eq $destref->{bridge} || single_interface( $sourcezone ) eq $destref->{bridge} ) {
return 0 if $wildcard;
fatal_error "Rules with a DESTINATION Bridge Port zone must have a SOURCE zone on the same bridge";
}
}
$chain = rules_chain( ${sourcezone}, ${destzone} );
#
# Ensure that the chain exists but don't mark it as referenced until after optimization is checked
#
( $chainref = ensure_chain( 'filter', $chain ) )->{sourcezone} = $sourcezone;
$chainref->{destzone} = $destzone;
my $policy = $chainref->{policy};
if ( $policy eq 'NONE' ) {
} elsif ( ! ( $actiontype & NATONLY ) ) {
#
# Check for illegal bridge port rule
#
if ( $destref->{type} & BPORT ) {
unless ( $sourceref->{bridge} eq $destref->{bridge} || single_interface( $sourcezone ) eq $destref->{bridge} ) {
return 0 if $wildcard;
fatal_error "Rules may not override a NONE policy";
fatal_error "Rules with a DESTINATION Bridge Port zone must have a SOURCE zone on the same bridge";
}
#
# Handle Optimization level 1 when specified alone
#
if ( $optimize == 1 && $section == NEW_SECTION ) {
my $loglevel = $filter_table->{$chainref->{policychain}}{loglevel};
if ( $loglevel ne '' ) {
return 0 if $target eq "${policy}:${loglevel}";
} else {
return 0 if $basictarget eq $policy;
}
}
$chain = rules_chain( ${sourcezone}, ${destzone} );
#
# Ensure that the chain exists but don't mark it as referenced until after optimization is checked
#
( $chainref = ensure_chain( 'filter', $chain ) )->{sourcezone} = $sourcezone;
$chainref->{destzone} = $destzone;
my $policy = $chainref->{policy};
if ( $policy eq 'NONE' ) {
return 0 if $wildcard;
fatal_error "Rules may not override a NONE policy";
}
#
# Handle Optimization level 1 when specified alone
#
if ( $optimize == 1 && $section == NEW_SECTION ) {
my $loglevel = $filter_table->{$chainref->{policychain}}{loglevel};
if ( $loglevel ne '' ) {
return 0 if $target eq "${policy}:${loglevel}";
} else {
return 0 if $basictarget eq $policy;
}
#
# Mark the chain as referenced and add appropriate rules from earlier sections.
#
$chainref = ensure_rules_chain $chain;
#
# Handle rules in the BLACKLIST, ESTABLISHED, RELATED, INVALID and UNTRACKED sections
#
if ( $section & ( BLACKLIST_SECTION | ESTABLISHED_SECTION | RELATED_SECTION | INVALID_SECTION | UNTRACKED_SECTION ) ) {
my $auxchain = $section_functions{$section}->( $sourcezone, $destzone );
my $auxref = $filter_table->{$auxchain};
}
#
# Mark the chain as referenced and add appropriate rules from earlier sections.
#
$chainref = ensure_rules_chain $chain;
#
# Handle rules in the BLACKLIST, ESTABLISHED, RELATED, INVALID and UNTRACKED sections
#
if ( $section & ( BLACKLIST_SECTION | ESTABLISHED_SECTION | RELATED_SECTION | INVALID_SECTION | UNTRACKED_SECTION ) ) {
my $auxchain = $section_functions{$section}->( $sourcezone, $destzone );
my $auxref = $filter_table->{$auxchain};
unless ( $auxref ) {
my $save_comment = push_comment;
$auxref = new_chain 'filter', $auxchain;
$auxref->{blacklistsection} = 1 if $blacklist;
unless ( $auxref ) {
my $save_comment = push_comment;
$auxref = new_chain 'filter', $auxchain;
$auxref->{blacklistsection} = 1 if $blacklist;
add_ijump( $chainref, j => $auxref, state_imatch( $section_states{$section} ) );
pop_comment( $save_comment );
}
$chain = $auxchain;
$chainref = $auxref;
add_ijump( $chainref, j => $auxref, state_imatch( $section_states{$section} ) );
pop_comment( $save_comment );
}
$chain = $auxchain;
$chainref = $auxref;
}
}
#
@@ -3025,7 +3056,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
#
# Handle actions
#
my $actionchain; #Name of the action chain
my $actionchain; # Name of the action chain
if ( $actiontype & ACTION ) {
#
@@ -3554,7 +3585,7 @@ sub perl_action_tcp_helper($$) {
sub process_section ($) {
my $sect = shift;
#
# split_line1 has already verified that there are exactly two tokens on the line
# split_line2 has already verified that there are exactly two tokens on the line
#
fatal_error "Invalid SECTION ($sect)" unless defined $sections{$sect};
fatal_error "Duplicate or out of order SECTION $sect" if $sections{$sect};
@@ -3698,7 +3729,7 @@ sub process_raw_rule ( ) {
fatal_error "Invalid or missing ACTION ($target)" unless defined $action;
if ( @protos > 1 ) {
fatal_error "Inversion not allowed in a PROTO list" if $protos =~ tr/!/!/;
fatal_error "Inversion not allowed in a PROTO list" if $protos =~ /!/;
}
for $source ( @source ) {
@@ -3769,7 +3800,7 @@ sub process_rules() {
UNTRACKED_SECTION, 'UNTRACKED' );
#
# If A_REJECT was specified in shorewall[6].conf, the A_REJECT chain will already exist.
# If A_REJECT was specified in shorewall[6].conf, the A_REJECT chain may already exist.
#
$usedactions{normalize_action_name( 'A_REJECT' )} = $filter_table->{A_REJECT} if $filter_table->{A_REJECT};
#
@@ -3927,14 +3958,14 @@ sub process_mangle_inline( $$$$$$$$$$$$$$$$$$$ ) {
}
$msource = $source if $msource eq '-';
$mdest = $dest if $msource eq '-';
$mdest = $dest if $mdest eq '-';
$mprotos = $protos if $mprotos eq '-';
for my $proto (split_list( $mprotos, 'Protocol' ) ) {
process_mangle_rule1( $chainref,
$moriginalmark,
$msource,
$dest,
$mdest,
$proto,
merge_macro_column( $mports, $ports ),
merge_macro_column( $msports, $sports ),
@@ -4165,8 +4196,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
},
CHECKSUM => {
defaultchain => 0,
allowedchains => ALLCHAINS,
defaultchain => POSTROUTING,
allowedchains => POSTROUTING | FORWARD | OUTPUT,
minparams => 0,
maxparams => 0 ,
function => sub() {
@@ -4291,7 +4322,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
},
DSCP => {
defaultchain => 0,
defaultchain => POSTROUTING,
allowedchains => PREROUTING | FORWARD | OUTPUT | POSTROUTING,
minparams => 1,
maxparams => 1,
@@ -4456,6 +4487,16 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
},
},
NFLOG => {
defaultchain => 0,
allowedchains => ALLCHAINS,
minparams => 0,
maxparams => 3,
function => sub () {
$target = validate_level( "NFLOG($params)" );
}
},
RESTORE => {
defaultchain => 0,
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING,
@@ -4731,10 +4772,6 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
}
}
unless ( ( $chain || $default_chain ) == OUTPUT ) {
fatal_error 'A USER/GROUP may only be specified when the SOURCE is $FW' unless $user eq '-';
}
if ( $dest ne '-' ) {
if ( $dest eq $fw ) {
fatal_error 'Rules with DEST $FW must use the INPUT chain' if $designator && $designator ne INPUT;
@@ -4777,6 +4814,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
fatal_error "Duplicate STATE ($_)" if $state{$_}++;
}
}
#
# Call the command's processing function
#
@@ -4787,12 +4825,23 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
if ( $chain == ACTIONCHAIN ) {
fatal_error "$cmd rules are not allowed in the $chainlabels{$chain} chain" unless $commandref->{allowedchains} & $chainref->{allowedchains};
$chainref->{allowedchains} &= $commandref->{allowedchains};
$chainref->{allowedchains} &= (OUTPUT | POSTROUTING ) if $user ne '-';
} else {
#
# Inline within one of the standard chains
#
fatal_error "$cmd rules are not allowed in the $chainlabels{$chain} chain" unless $commandref->{allowedchains} & $chain;
unless ( $chain == OUTPUT || $chain == POSTROUTING ) {
fatal_error 'A USER/GROUP may only be specified when the SOURCE is $FW' unless $user eq '-';
}
}
} else {
$resolve_chain->();
fatal_error "$cmd rules are not allowed in the $chainlabels{$chain} chain" unless $commandref->{allowedchains} & $chain;
unless ( $chain == OUTPUT || $chain == POSTROUTING ) {
fatal_error 'A USER/GROUP may only be specified when the SOURCE is $FW' unless $user eq '-';
}
$chainref = ensure_chain( 'mangle', $chainnames{$chain} );
}
@@ -4958,6 +5007,13 @@ sub process_tc_rule1( $$$$$$$$$$$$$$$$ ) {
$mark = $rest;
} elsif ( supplied $2 ) {
$mark = $2;
if ( supplied $mark && $command eq 'IPMARK' ) {
my @params = split ',', $mark;
$params[1] = '0xff' unless supplied $params[1];
$params[2] = '0x00' unless supplied $params[2];
$params[3] = '0' unless supplied $params[3];
$mark = join ',', @params;
}
} else {
$mark = '';
}
@@ -4968,7 +5024,7 @@ sub process_tc_rule1( $$$$$$$$$$$$$$$$ ) {
}
}
$command = ( $command ? "$command($mark)" : $mark ) . $designator;
$command = ( $command ? supplied $mark ? "$command($mark)" : $command : $mark ) . $designator;
my $line = ( $family == F_IPV6 ?
"$command\t$source\t$dest\t$proto\t$ports\t$sports\t$user\t$testval\t$length\t$tos\t$connbytes\t$helper\t$headers\t$probability\t$dscp\t$state" :
"$command\t$source\t$dest\t$proto\t$ports\t$sports\t$user\t$testval\t$length\t$tos\t$connbytes\t$helper\t$probability\t$dscp\t$state" );

View File

@@ -350,9 +350,10 @@ sub process_simple_device() {
for ( my $i = 1; $i <= 3; $i++ ) {
my $prio = 16 | $i;
my $j = $i + 3;
emit "run_tc qdisc add dev $physical parent $number:$i handle ${number}${i}: sfq quantum 1875 limit 127 perturb 10";
emit "run_tc filter add dev $physical protocol all prio $prio parent $number: handle $i fw classid $number:$i";
emit "run_tc filter add dev $physical protocol all prio 1 parent ${number}$i: handle ${number}${i} flow hash keys $type divisor 1024" if $type ne '-' && have_capability 'FLOW_FILTER';
emit "run_tc filter add dev $physical protocol all prio 1 parent ${number}$i: handle $j flow hash keys $type divisor 1024" if $type ne '-' && have_capability 'FLOW_FILTER';
emit '';
}
@@ -674,7 +675,8 @@ sub validate_tc_class( ) {
$markval = numeric_value( $mark );
fatal_error "Invalid MARK ($markval)" unless defined $markval;
fatal_error "Invalid Mark ($mark)" unless $markval <= $globals{TC_MAX};
fatal_error "MARK value too large" unless $markval <= $globals{TC_MAX};
fatal_error "MARK value must be non-zero" unless $markval;
if ( $classnumber ) {
fatal_error "Duplicate Class NUMBER ($classnumber)" if $tcref->{$classnumber};
@@ -2165,7 +2167,7 @@ sub convert_tos($$) {
if ( my $fn = open_file 'tos' ) {
first_entry(
sub {
my $date = localtime;
my $date = compiletime;
progress_message2 "Converting $fn...";
print( $mangle
"#\n" ,
@@ -2233,13 +2235,19 @@ sub convert_tos($$) {
}
}
sub open_mangle_for_output() {
sub open_mangle_for_output( $ ) {
my ($fn ) = @_;
my ( $mangle, $fn1 );
if ( -f ( $fn1 = find_writable_file( 'mangle' ) ) ) {
open( $mangle , '>>', $fn1 ) || fatal_error "Unable to open $fn1:$!";
} else {
open( $mangle , '>', $fn1 ) || fatal_error "Unable to open $fn1:$!";
#
# Transfer permissions from the existing tcrules file to the new mangle file
#
transfer_permissions( $fn, $fn1 );
print $mangle <<'EOF';
#
# Shorewall version 4 - Mangle File
@@ -2325,13 +2333,13 @@ sub setup_tc( $ ) {
#
# We are going to convert this tcrules file to the equivalent mangle file
#
( $mangle, $fn1 ) = open_mangle_for_output;
( $mangle, $fn1 ) = open_mangle_for_output( $fn );
directive_callback( sub () { print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT'; 0; } );
first_entry(
sub {
my $date = localtime;
my $date = compiletime;
progress_message2 "Converting $fn...";
print( $mangle
"#\n" ,
@@ -2375,7 +2383,7 @@ sub setup_tc( $ ) {
#
# We are going to convert this tosfile to the equivalent mangle file
#
( $mangle, $fn1 ) = open_mangle_for_output;
( $mangle, $fn1 ) = open_mangle_for_output( $fn );
convert_tos( $mangle, $fn1 );
close $mangle;
}

View File

@@ -103,7 +103,6 @@ our @EXPORT = ( qw( NOTHING
find_hosts_by_option
find_zone_hosts_by_option
find_zones_by_option
all_ipsets
have_ipsec
),
);
@@ -210,7 +209,6 @@ our @interfaces;
our %interfaces;
our %roots;
our @bport_zones;
our %ipsets;
our %basemap;
our %basemap1;
our %mapbase;
@@ -326,7 +324,6 @@ sub initialize( $$ ) {
%roots = ();
%interfaces = ();
@bport_zones = ();
%ipsets = ();
%basemap = ();
%basemap1 = ();
%mapbase = ();
@@ -340,6 +337,7 @@ sub initialize( $$ ) {
arp_ignore => ENUM_IF_OPTION,
blacklist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
bridge => SIMPLE_IF_OPTION,
dbl => ENUM_IF_OPTION,
destonly => SIMPLE_IF_OPTION + IF_OPTION_HOST,
detectnets => OBSOLETE_IF_OPTION,
dhcp => SIMPLE_IF_OPTION,
@@ -348,6 +346,7 @@ sub initialize( $$ ) {
logmartians => BINARY_IF_OPTION,
loopback => BINARY_IF_OPTION,
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER,
nodbl => SIMPLE_IF_OPTION,
norfc1918 => OBSOLETE_IF_OPTION,
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
optional => SIMPLE_IF_OPTION,
@@ -389,12 +388,14 @@ sub initialize( $$ ) {
%validinterfaceoptions = ( accept_ra => NUMERIC_IF_OPTION,
blacklist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
bridge => SIMPLE_IF_OPTION,
dbl => ENUM_IF_OPTION,
destonly => SIMPLE_IF_OPTION + IF_OPTION_HOST,
dhcp => SIMPLE_IF_OPTION,
ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
loopback => BINARY_IF_OPTION,
maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER,
nodbl => SIMPLE_IF_OPTION,
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
optional => SIMPLE_IF_OPTION,
optional => SIMPLE_IF_OPTION,
@@ -1118,6 +1119,8 @@ sub process_interface( $$ ) {
my ($interface, $port, $extra) = split /:/ , $originalinterface, 3;
fatal_error "Invalid interface name ($interface)" if $interface =~ /[()\[\]\*\?%]/;
fatal_error "Invalid INTERFACE ($originalinterface)" if ! $interface || defined $extra;
if ( supplied $port ) {
@@ -1192,6 +1195,7 @@ sub process_interface( $$ ) {
my %options;
$options{port} = 1 if $port;
$options{dbl} = $config{DYNAMIC_BLACKLIST} =~ /^ipset(-only)?.*,src-dst/ ? '1:2' : $config{DYNAMIC_BLACKLIST} ? '1:0' : '0:0';
my $hostoptionsref = {};
@@ -1235,6 +1239,8 @@ sub process_interface( $$ ) {
} else {
warning_message "The 'blacklist' option is ignored on multi-zone interfaces";
}
} elsif ( $option eq 'nodbl' ) {
$options{dbl} = '0:0';
} else {
$options{$option} = 1;
$hostoptions{$option} = 1 if $hostopt;
@@ -1257,6 +1263,11 @@ sub process_interface( $$ ) {
} else {
$options{arp_ignore} = 1;
}
} elsif ( $option eq 'dbl' ) {
my %values = ( none => '0:0', src => '1:0', dst => '2:0', 'src-dst' => '1:2' );
fatal_error q(The 'dbl' option requires a value) unless defined $value;
fatal_error qq(Invalid setting ($value) for 'dbl') unless defined ( $options{dbl} = $values{$value} );
} else {
assert( 0 );
}
@@ -1280,7 +1291,7 @@ sub process_interface( $$ ) {
fatal_error q("nets=" may not be specified for a multi-zone interface) unless $zone;
fatal_error "Duplicate $option option" if $netsref;
if ( $value eq 'dynamic' ) {
require_capability( 'IPSET_MATCH', 'Dynamic nets', '');
require_capability( 'IPSET_V5', 'Dynamic nets', '');
$hostoptions{dynamic} = 1;
#
# Defer remaining processing until we have the final physical interface name
@@ -1307,7 +1318,7 @@ sub process_interface( $$ ) {
fatal_error "The '$option' option requires a value" unless defined $value;
if ( $option eq 'physical' ) {
fatal_error "Invalid Physical interface name ($value)" unless $value && $value !~ /%/;
fatal_error "Invalid interface name ($interface)" if $interface =~ /[()\[\]\*\?%]/;
fatal_error "Virtual interfaces ($value) are not supported" if $value =~ /:\d+$/;
fatal_error "Duplicate physical interface name ($value)" if ( $interfaces{$value} && ! $port );
@@ -1344,7 +1355,7 @@ sub process_interface( $$ ) {
my $ipset = $family == F_IPV4 ? "${zone}" : "6_${zone}";
$ipset = join( '_', $ipset, var_base1( $physical ) ) unless $zoneref->{options}{in_out}{dynamic_shared};
$netsref = [ "+$ipset" ];
$ipsets{$ipset} = 1;
add_ipset($ipset);
}
if ( $options{bridge} ) {
@@ -1578,7 +1589,7 @@ sub known_interface($)
name => $i ,
number => $interfaceref->{number} ,
physical => $physical ,
base => var_base( $physical ) ,
base => $interfaceref->{base} ,
wildcard => $interfaceref->{wildcard} ,
zones => $interfaceref->{zones} ,
};
@@ -1907,7 +1918,7 @@ sub verify_required_interfaces( $ ) {
my $returnvalue = 0;
my $interfaces = find_interfaces_by_option 'wait';
my $interfaces = find_interfaces_by_option( 'wait');
if ( @$interfaces ) {
my $first = 1;
@@ -1973,7 +1984,7 @@ sub verify_required_interfaces( $ ) {
}
$interfaces = find_interfaces_by_option 'required';
$interfaces = find_interfaces_by_option( 'required' );
if ( @$interfaces ) {
@@ -2153,7 +2164,7 @@ sub process_host( ) {
$hosts = "+$set";
$optionsref->{dynamic} = 1;
$ipsets{$set} = 1;
add_ipset($set);
}
#
@@ -2161,7 +2172,7 @@ sub process_host( ) {
#
$interface = '%vserver%' if $type & VSERVER;
add_group_to_zone( $zone, $type , $interface, [ split_list( $hosts, 'host' ) ] , $optionsref, 1 );
add_group_to_zone( $zone, $type , $interface, [ split_list( $hosts, 'host' ) ] , $optionsref, 0 );
progress_message " Host \"$currentline\" validated";
@@ -2273,8 +2284,4 @@ sub find_zones_by_option( $$ ) {
\@zns;
}
sub all_ipsets() {
sort keys %ipsets;
}
1;

View File

@@ -41,10 +41,7 @@
# --shorewallrc1=<path> # Path to export shorewallrc file.
# --config_path=<path-list> # Search path for config files
# --inline # Update alternative column specifications
# --update # Update configuration to this release
# --tcrules # Create mangle from tcrules
# --routestopped # Create stoppedrules from routestopped
# --notrack # Create conntrack from notrack
# --update # Update configuration to current release
#
use strict;
use FindBin;

View File

@@ -49,7 +49,7 @@
# generated this program
#
################################################################################
# Functions imported from /usr/share/shorewall/lib.core
# Functions imported from /usr/share/shorewall/lib.runtime
################################################################################
# Address family-neutral Functions
################################################################################
@@ -599,7 +599,15 @@ debug_restore_input() {
}
interface_enabled() {
return $(cat ${VARDIR}/$1.status)
status=0
if [ -f ${VARDIR}/${1}_disabled ]; then
status=1
elif [ -f ${VARDIR}/${1}.status ]; then
status=$(cat ${VARDIR}/${1}.status)
fi
return $status
}
distribute_load() {
@@ -678,8 +686,10 @@ interface_is_usable() # $1 = interface
if ! loopback_interface $1; 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=$?
if [ "$COMMAND" != enable ]; then
[ ! -f ${VARDIR}/${1}_disabled ] && run_isusable_exit $1
status=$?
fi
else
status=1
fi
@@ -996,9 +1006,16 @@ delete_gateway() # $! = Description of the Gateway $2 = table number $3 = device
if [ -n "$route" ]; then
if echo $route | grep -qF ' nexthop '; then
gateway="nexthop $gateway"
eval route=\`echo $route \| sed \'s/$gateway/ /\'\`
run_ip route replace table $2 $route
if interface_is_up $3; then
gateway="nexthop $gateway"
else
gateway="nexthop $gateway dead"
fi
if eval echo $route \| fgrep -q \'$gateway\'; then
eval route=\`echo $route \| sed \'s/$gateway/ /\'\`
run_ip route replace table $2 $route
fi
else
dev=$(find_device $route)
[ "$dev" = "$3" ] && run_ip route delete default table $2
@@ -1095,8 +1112,10 @@ interface_is_usable() # $1 = interface
if [ "$1" != lo ]; then
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != :: ]; then
[ "$COMMAND" = enable ] || run_isusable_exit $1
status=$?
if [ "$COMMAND" != enable ]; then
[ ! -f ${VARDIR}/${1}_disabled ] && run_isusable_exit $1
status=$?
fi
else
status=1
fi
@@ -1110,7 +1129,7 @@ interface_is_usable() # $1 = interface
#
find_interface_addresses() # $1 = interface
{
$IP -f inet6 addr show $1 2> /dev/null | grep 'inet6 2' | sed 's/\s*inet6 //;s/\/.*//;s/ peer.*//'
$IP -f inet6 addr show $1 2> /dev/null | grep 'inet6 2' | sed 's/\s*inet6 //;s/\/.*//;s/ peer [0-9a-f:]*//'
}
#
@@ -1119,7 +1138,7 @@ find_interface_addresses() # $1 = interface
find_interface_full_addresses() # $1 = interface
{
$IP -f inet6 addr show $1 2> /dev/null | grep 'inet6 ' | sed 's/\s*inet6 //;s/ scope.*//;s/ peer.*//'
$IP -f inet6 addr show $1 2> /dev/null | grep 'inet6 ' | sed 's/\s*inet6 //;s/ scope.*//;s/ peer [0-9a-f:]*//'
}
#

View File

@@ -25,6 +25,7 @@ usage() {
echo " savesets <file>"
echo " call <function> [ <parameter> ... ]"
echo " version"
echo " info"
echo
echo "Options are:"
echo
@@ -469,6 +470,10 @@ case "$COMMAND" in
echo $SHOREWALL_VERSION
status=0
;;
info)
[ $# -ne 1 ] && usage 2
info_command
;;
help)
[ $# -ne 1 ] && usage 2
usage 0

View File

@@ -23,6 +23,12 @@ VERBOSITY=1
PAGER=
###############################################################################
# F I R E W A L L
###############################################################################
FIREWALL=
###############################################################################
# L O G G I N G
###############################################################################
@@ -128,15 +134,13 @@ ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes
BASIC_FILTERS=No
IGNOREUNKNOWNVARIABLES=No
AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No
AUTOMAKE=Yes
BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED"
@@ -172,6 +176,8 @@ FORWARD_CLEAR_MARK=
HELPERS=
IGNOREUNKNOWNVARIABLES=No
IMPLICIT_CONTINUE=No
INLINE_MATCHES=Yes
@@ -242,10 +248,14 @@ USE_PHYSICAL_NAMES=No
USE_RT_NAMES=No
VERBOSE_MESSAGES=Yes
WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZERO_MARKS=No
ZONE2ZONE=-
###############################################################################

View File

@@ -34,6 +34,12 @@ VERBOSITY=1
PAGER=
###############################################################################
# F I R E W A L L
###############################################################################
FIREWALL=
###############################################################################
# L O G G I N G
###############################################################################
@@ -139,15 +145,13 @@ ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes
BASIC_FILTERS=No
IGNOREUNKNOWNVARIABLES=No
AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No
AUTOMAKE=Yes
BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED"
@@ -183,6 +187,8 @@ FORWARD_CLEAR_MARK=
HELPERS=
IGNOREUNKNOWNVARIABLES=No
IMPLICIT_CONTINUE=No
INLINE_MATCHES=Yes
@@ -253,10 +259,14 @@ USE_PHYSICAL_NAMES=No
USE_RT_NAMES=No
VERBOSE_MESSAGES=Yes
WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZERO_MARKS=No
ZONE2ZONE=-
###############################################################################

View File

@@ -31,6 +31,12 @@ VERBOSITY=1
PAGER=
###############################################################################
# F I R E W A L L
###############################################################################
FIREWALL=
###############################################################################
# L O G G I N G
###############################################################################
@@ -136,15 +142,13 @@ ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes
BASIC_FILTERS=No
IGNOREUNKNOWNVARIABLES=No
AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No
AUTOMAKE=Yes
BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED"
@@ -180,6 +184,8 @@ FORWARD_CLEAR_MARK=
HELPERS=
IGNOREUNKNOWNVARIABLES=No
IMPLICIT_CONTINUE=No
INLINE_MATCHES=Yes
@@ -250,10 +256,14 @@ USE_PHYSICAL_NAMES=No
USE_RT_NAMES=No
VERBOSE_MESSAGES=Yes
WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZERO_MARKS=No
ZONE2ZONE=-
###############################################################################

View File

@@ -34,6 +34,12 @@ VERBOSITY=1
PAGER=
###############################################################################
# F I R E W A L L
###############################################################################
FIREWALL=
###############################################################################
# L O G G I N G
###############################################################################
@@ -139,15 +145,13 @@ ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes
BASIC_FILTERS=No
IGNOREUNKNOWNVARIABLES=No
AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No
AUTOMAKE=Yes
BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED"
@@ -183,6 +187,8 @@ FORWARD_CLEAR_MARK=
HELPERS=
IGNOREUNKNOWNVARIABLES=No
IMPLICIT_CONTINUE=No
INLINE_MATCHES=Yes
@@ -253,10 +259,14 @@ USE_PHYSICAL_NAMES=No
USE_RT_NAMES=No
VERBOSE_MESSAGES=Yes
WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZERO_MARKS=No
ZONE2ZONE=-
###############################################################################

View File

@@ -23,14 +23,17 @@ COUNT
#
Auth(A_DROP)
#
# ACCEPT critical ICMP types
#
# For IPv6 connectivity ipv6-icmp broadcasting is required so
# AllowICMPs must be before broadcast Drop.
#
A_AllowICMPs - - icmp
#
# Don't log broadcasts
#
dropBcast(audit)
#
# ACCEPT critical ICMP types
#
A_AllowICMPs - - icmp
#
# Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log.
#

View File

@@ -18,15 +18,18 @@
#
COUNT
#
# ACCEPT critical ICMP types
#
# For IPv6 connectivity ipv6-icmp broadcasting is required so
# AllowICMPs must be before broadcast Drop.
#
A_AllowICMPs - - icmp
#
# Drop Broadcasts so they don't clutter up the log
# (broadcasts must *not* be rejected).
#
dropBcast(audit)
#
# ACCEPT critical ICMP types
#
A_AllowICMPs - - icmp
#
# Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log (these ICMPs cannot be
# rejected).

View File

@@ -10,7 +10,7 @@
# b) Ensure that certain ICMP packets that are necessary for successful
# internet operation are always ACCEPTed.
#
# The action accepts five optional parameters:
# The action accepts six optional parameters:
#
# 1 - 'audit' or '-'. Default is '-' which means don't audit in builtin
# actions.
@@ -22,6 +22,8 @@
# A_ACCEPT depending on the first parameter.
# 5 - Action to take with late UDP replies (UDP source port 53). Default
# is DROP or A_DROP depending on the first parameter.
# 6 - Action to take with UPnP packets. Default is DROP or A_DROP
# depending on the first parameter.
#
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
#
@@ -29,12 +31,12 @@
?if passed(@1)
?if @1 eq 'audit'
DEFAULTS -,-,A_DROP,A_ACCEPT,A_DROP
DEFAULTS -,-,A_DROP,A_ACCEPT,A_DROP,A_DROP
?else
?error The first parameter to Drop must be 'audit' or '-'
?endif
?else
DEFAULTS -,-,DROP,ACCEPT,DROP
DEFAULTS -,-,DROP,ACCEPT,DROP,DROP
?endif
#ACTION SOURCE DEST PROTO DPORT SPORT
@@ -49,14 +51,17 @@ COUNT
Auth(@2)
?endif
#
# ACCEPT critical ICMP types
#
# For IPv6 connectivity ipv6-icmp broadcasting is required so
# AllowICMPs must be before silent broadcast Drop.
#
AllowICMPs(@4) - - icmp
#
# Don't log broadcasts
#
Broadcast(DROP,@1)
#
# ACCEPT critical ICMP types
#
AllowICMPs(@4) - - icmp
#
# Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log.
#
@@ -65,7 +70,7 @@ Invalid(DROP,@1)
# Drop Microsoft noise so that it doesn't clutter up the log.
#
SMB(@3)
DropUPnP
DropUPnP(@6)
#
# Drop 'newnotsyn' traffic so that it doesn't get logged.
#

View File

@@ -10,7 +10,7 @@
# b) Ensure that certain ICMP packets that are necessary for successful
# internet operation are always ACCEPTed.
#
# The action accepts five optional parameters:
# The action accepts six optional parameters:
#
# 1 - 'audit' or '-'. Default is '-' which means don't audit in builtin
# actions.
@@ -22,18 +22,20 @@
# A_ACCEPT depending on the first parameter.
# 5 - Action to take with late UDP replies (UDP source port 53). Default
# is DROP or A_DROP depending on the first parameter.
# 6 - Action to take with UPnP packets. Default is DROP or A_DROP
# depending on the first parameter.
#
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
###############################################################################
?if passed(@1)
?if @1 eq 'audit'
DEFAULTS -,-,A_REJECT,A_ACCEPT,A_DROP
DEFAULTS -,-,A_REJECT,A_ACCEPT,A_DROP,A_DROP
?else
?error The first parameter to Reject must be 'audit' or '-'
?endif
?else
DEFAULTS -,-,REJECT,ACCEPT,DROP
DEFAULTS -,-,REJECT,ACCEPT,DROP,DROP
?endif
#ACTION SOURCE DEST PROTO
@@ -48,15 +50,18 @@ COUNT
Auth(@2)
?endif
#
# ACCEPT critical ICMP types
#
# For IPv6 connectivity ipv6-icmp broadcasting is required so
# AllowICMPs must be before silent broadcast Drop.
#
AllowICMPs(@4) - - icmp
#
# Drop Broadcasts so they don't clutter up the log
# (broadcasts must *not* be rejected).
#
Broadcast(DROP,@1)
#
# ACCEPT critical ICMP types
#
AllowICMPs(@4) - - icmp
#
# Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log (these ICMPs cannot be
# rejected).
@@ -66,7 +71,7 @@ Invalid(DROP,@1)
# Reject Microsoft noise so that it doesn't clutter up the log.
#
SMB(@3)
DropUPnP(@5)
DropUPnP(@6)
#
# Drop 'newnotsyn' traffic so that it doesn't get logged.
#

View File

@@ -23,6 +23,12 @@ VERBOSITY=1
PAGER=
###############################################################################
# F I R E W A L L
###############################################################################
FIREWALL=
###############################################################################
# L O G G I N G
###############################################################################
@@ -128,16 +134,14 @@ ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes
BASIC_FILTERS=No
IGNOREUNKNOWNVARIABLES=No
AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No
BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED"
CHAIN_SCRIPTS=Yes
@@ -172,6 +176,8 @@ FORWARD_CLEAR_MARK=
HELPERS=
IGNOREUNKNOWNVARIABLES=No
IMPLICIT_CONTINUE=No
INLINE_MATCHES=No
@@ -242,10 +248,14 @@ USE_PHYSICAL_NAMES=No
USE_RT_NAMES=No
VERBOSE_MESSAGES=Yes
WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZERO_MARKS=No
ZONE2ZONE=-
###############################################################################

View File

@@ -4,7 +4,7 @@
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: S
# Default-Stop: 0 6
# Default-Stop: 0 1 6
# Short-Description: Configure the firewall at boot time
# Description: Configure the firewall according to the rules specified in
# /etc/shorewall
@@ -97,10 +97,11 @@ shorewall_start () {
# stop the firewall
shorewall_stop () {
echo -n "Stopping \"Shorewall firewall\": "
if [ "$SAFESTOP" = 1 ]; then
echo -n "Stopping \"Shorewall firewall\": "
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
else
echo -n "Clearing all \"Shorewall firewall\" rules: "
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
fi
return 0
@@ -145,7 +146,7 @@ case "$1" in
restart)
shorewall_restart
;;
force0reload|reload)
force-reload|reload)
shorewall_reload
;;
status)

View File

@@ -419,11 +419,13 @@ mkdir -p ${DESTDIR}${CONFDIR}/$PRODUCT
mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT
mkdir -p ${DESTDIR}${PERLLIBDIR}/Shorewall
mkdir -p ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles
mkdir -p ${DESTDIR}${SHAREDIR}/$PRODUCT/deprecated
mkdir -p ${DESTDIR}${VARDIR}
chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT
chmod 755 ${DESTDIR}${SHAREDIR}/$PRODUCT
chmod 755 ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles
chmod 755 ${DESTDIR}${SHAREDIR}/$PRODUCT/deprecated
if [ -n "$DESTDIR" ]; then
mkdir -p ${DESTDIR}${CONFDIR}/logrotate.d
@@ -512,7 +514,7 @@ echo "Default config path file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/confi
# 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"
echo "Standard actions file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/actions.std"
cd configfiles
@@ -1060,15 +1062,31 @@ fi
# Install the Action files
#
for f in action.* ; do
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644
echo "Action ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
case $f in
*.deprecated)
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/deprecated/${f%.*} 0644
echo "Action ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/deprecated/${f%.*}"
;;
*)
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644
echo "Action ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
;;
esac
done
cd Macros
for f in macro.* ; do
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644
echo "Macro ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
case $f in
*.deprecated)
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/deprecated/${f%.*} 0644
echo "Macro ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/deprecated/${f%.*}"
;;
*)
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644
echo "Macro ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
;;
esac
done
cd ..
@@ -1159,6 +1177,8 @@ fi
# Install the Man Pages
#
if [ -n "$MANDIR" ]; then
cd manpages
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}${MANDIR}/man5/ ${DESTDIR}${MANDIR}/man8/
@@ -1178,6 +1198,7 @@ done
cd ..
echo "Man Pages Installed"
fi
if [ -d ${DESTDIR}${CONFDIR}/logrotate.d ]; then
run_install $OWNERSHIP -m 0644 logrotate ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT
@@ -1194,7 +1215,7 @@ if [ -n "$SYSCONFFILE" -a -f "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PR
fi
run_install $OWNERSHIP -m 0644 ${SYSCONFFILE} ${DESTDIR}${SYSCONFDIR}/$PRODUCT
echo "$SYSCONFFILE installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
echo "$SYSCONFFILE file installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
fi
if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then

View File

@@ -316,6 +316,8 @@ get_config() {
g_loopback=$(find_loopback_interfaces)
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
if [ -n "$PAGER" -a -t 1 ]; then
case $PAGER in
/*)
@@ -323,7 +325,7 @@ get_config() {
[ -f "$g_pager" ] || fatal_error "PAGER $PAGER does not exist"
;;
*)
g_pager=$(mywhich pager 2> /dev/null)
g_pager=$(mywhich $PAGER 2> /dev/null)
[ -n "$g_pager" ] || fatal_error "PAGER $PAGER not found"
;;
esac
@@ -333,6 +335,10 @@ get_config() {
g_pager="| $g_pager"
fi
if [ -n "$DYNAMIC_BLACKLIST" ]; then
setup_dbl
fi
lib=$(find_file lib.cli-user)
[ -f $lib ] && . $lib
@@ -403,7 +409,7 @@ compiler() {
get_config Yes
case $COMMAND in
*start|try|refresh)
*start|try|refresh|reload|restart|safe-*)
;;
*)
STARTUP_LOG=
@@ -461,13 +467,13 @@ compiler() {
case "$g_doing" in
Compiling|Checking)
progress_message3 "$g_doing using $g_product $SHOREWALL_VERSION..."
progress_message3 "$g_doing using Shorewall $SHOREWALL_VERSION..."
;;
Updating)
progress_message3 "Updating $g_product configuration to $SHOREWALL_VERSION..."
;;
*)
[ -n "$g_doing" ] && progress_message3 "$g_doing using $g_product $SHOREWALL_VERSION..."
[ -n "$g_doing" ] && progress_message3 "$g_doing using Shorewall $SHOREWALL_VERSION..."
;;
esac
#
@@ -498,7 +504,6 @@ compiler() {
start_command() {
local finished
finished=0
local object
local rc
rc=0
@@ -517,7 +522,7 @@ start_command() {
[ -n "$nolock" ] || mutex_off
else
rc=$?
logger -p kern.err "ERROR:$g_product start failed"
mylogger kern.err "ERROR:$g_product start failed"
fi
fi
@@ -573,7 +578,7 @@ start_command() {
option=${option#C}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -589,7 +594,8 @@ start_command() {
0)
;;
1)
[ -n "$g_shorewalldir" -o -n "$g_fast" ] && usage 2
[ -n "$g_shorewalldir" ] && fatal_error "A directory has already been specified: $1"
[ -n "$g_fast" ] && fatal_error "Directory may not be specified with the -f option"
if [ ! -d $1 ]; then
if [ -e $1 ]; then
@@ -603,12 +609,12 @@ start_command() {
AUTOMAKE=
;;
*)
usage 1
too_many_arguments $2
;;
esac
if [ -n "${g_fast}${AUTOMAKE}" ]; then
if ! uptodate ${VARDIR}/$object; then
if ! uptodate ${VARDIR}/firewall; then
g_fast=
AUTOMAKE=
fi
@@ -632,8 +638,6 @@ compile_command() {
shift
option=${option#-}
[ -z "$option" ] && usage 1
while [ -n "$option" ]; do
case $option in
e*)
@@ -670,7 +674,7 @@ compile_command() {
option=
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -692,7 +696,7 @@ compile_command() {
[ -d "$g_file" ] && fatal_error "$g_file is a directory"
;;
2)
[ -n "$g_shorewalldir" -a -z "$g_export" ] && usage 2
[ -n "$g_shorewalldir" -a -z "$g_export" ] && fatal_error "A directory has already been specified: $1"
if [ ! -d $1 ]; then
if [ -e $1 ]; then
@@ -706,7 +710,7 @@ compile_command() {
g_file=$2
;;
*)
usage 1
too_many_arguments $3
;;
esac
@@ -760,7 +764,7 @@ check_command() {
option=${option#i}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -776,7 +780,7 @@ check_command() {
0)
;;
1)
[ -n "$g_shorewalldir" -a -z "$g_export" ] && usage 2
[ -n "$g_shorewalldir" -a -z "$g_export" ] && fatal_error "A directory has already been specified: $1"
if [ ! -d $1 ]; then
if [ -e $1 ]; then
@@ -789,7 +793,7 @@ check_command() {
g_shorewalldir=$(resolve_file $1)
;;
*)
usage 1
too_many_arguments $2
;;
esac
@@ -852,7 +856,7 @@ update_command() {
option=${option#A}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -868,7 +872,7 @@ update_command() {
0)
;;
1)
[ -n "$g_shorewalldir" ] && usage 2
[ -n "$g_shorewalldir" ] && fatal_error "A directory has already been specified: $1"
if [ ! -d $1 ]; then
if [ -e $1 ]; then
@@ -881,7 +885,7 @@ update_command() {
g_shorewalldir=$(resolve_file $1)
;;
*)
usage 1
too_many_arguments $2
;;
esac
@@ -946,7 +950,7 @@ restart_command() {
option=${option#C}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -962,7 +966,7 @@ restart_command() {
0)
;;
1)
[ -n "$g_shorewalldir" ] && usage 2
[ -n "$g_shorewalldir" ] && fatal_error "A directory has already been specified: $1"
if [ ! -d $1 ]; then
if [ -e $1 ]; then
@@ -977,7 +981,7 @@ restart_command() {
AUTOMAKE=
;;
*)
usage 1
too_many_arguments $2
;;
esac
@@ -997,7 +1001,7 @@ restart_command() {
[ -n "$nolock" ] || mutex_off
else
rc=$?
logger -p kern.err "ERROR:$g_product ${COMMAND} failed"
mylogger kern.err "ERROR:$g_product ${COMMAND} failed"
fi
else
[ -x ${VARDIR}/firewall ] || fatal_error "No ${VARDIR}/firewall file found"
@@ -1055,7 +1059,7 @@ refresh_command() {
fi
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -1138,7 +1142,7 @@ safe_commands() {
shift;
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -1154,7 +1158,7 @@ safe_commands() {
0)
;;
1)
[ -n "$g_shorewalldir" ] && usage 2
[ -n "$g_shorewalldir" ] && fatal_error "A directory has already been specified: $1"
if [ ! -d $1 ]; then
if [ -e $1 ]; then
@@ -1167,7 +1171,7 @@ safe_commands() {
g_shorewalldir=$(resolve_file $1)
;;
*)
usage 1
too_many_arguments $2
;;
esac
@@ -1255,7 +1259,7 @@ try_command() {
timeout=
handle_directory() {
[ -n "$g_shorewalldir" ] && usage 2
[ -n "$g_shorewalldir" ] && fatal_error "A directory has already been specified: $1"
if [ ! -d $1 ]; then
if [ -e $1 ]; then
@@ -1285,7 +1289,7 @@ try_command() {
option=${option#n}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -1299,7 +1303,7 @@ try_command() {
case $# in
0)
usage 1
missing_argument
;;
1)
handle_directory $1
@@ -1310,7 +1314,7 @@ try_command() {
timeout=$2
;;
*)
usage 1
too_many_arguments $3
;;
esac
@@ -1440,6 +1444,12 @@ remote_reload_command() # $* = original arguments less the command.
option=
shift
;;
D)
[ $# -gt 1 ] || fatal_error "Missing directory name"
g_shorewalldir=$2
option=
shift
;;
T*)
g_confess=Yes
option=${option#T}
@@ -1449,7 +1459,7 @@ remote_reload_command() # $* = original arguments less the command.
option=${option#i}
;;
*)
usage 1
option_error $option
;;
esac
done
@@ -1462,6 +1472,9 @@ remote_reload_command() # $* = original arguments less the command.
done
case $# in
0)
[ -n "$g_shorewalldir" ] || g_shorewalldir='.'
;;
1)
g_shorewalldir="."
system=$1
@@ -1471,7 +1484,7 @@ remote_reload_command() # $* = original arguments less the command.
system=$2
;;
*)
usage 1
too_many_arguments $3
;;
esac
@@ -1495,6 +1508,11 @@ remote_reload_command() # $* = original arguments less the command.
get_config No
g_haveconfig=Yes
if [ -z "$system" ]; then
system=$FIREWALL
[ -n "$system" ] || fatal_error "No system name given and the FIREWALL option is not set"
fi
else
fatal_error "$g_shorewalldir/$g_program.conf does not exist"
fi
@@ -1711,7 +1729,7 @@ compiler_command() {
safe_commands $@
;;
*)
usage 1
fatal_error "Invalid command: $COMMAND"
;;
esac

View File

@@ -130,6 +130,18 @@
</listitem>
</varlistentry>
<varlistentry>
<term><option>logjump</option></term>
<listitem>
<para>Added in Shorewall 5.0.8. Performs the same function as
<option>nolog</option> (below), with the addition that the
jump to the actions chain is logged if a log level is
specified on the action invocation. For inline actions, this
option is identical to <option>nolog</option>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>mangle</option></term>

View File

@@ -306,6 +306,72 @@ loc eth2 -</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">dbl={none|src|dst|src-dst}</emphasis></term>
<listitem>
<para>Added in Shorewall 5.0.10. This option defined whether
or not dynamic blacklisting is applied to packets entering the
firewall through this interface and whether the source address
and/or destination address is to be compared against the
ipset-based dynamic blacklist (DYNAMIC_BLACKLIST=ipset... in
<ulink
url="manpages/shorewall.conf.html">shorewall.conf(5)</ulink>).
The default is determine by the setting of
DYNAMIC_BLACKLIST:</para>
<variablelist>
<varlistentry>
<term>DYNAMIC_BLACKLIST=No</term>
<listitem>
<para>Default is <emphasis role="bold">none</emphasis>
(e.g., no dynamic blacklist checking).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>DYNAMIC_BLACKLIST=Yes</term>
<listitem>
<para>Default is <emphasis role="bold">src</emphasis>
(e.g., the source IP address is checked).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>DYNAMIC_BLACKLIST=ipset[-only]</term>
<listitem>
<para>Default is <emphasis
role="bold">src</emphasis>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>DYNAMIC_BLACKLIST=ipset[-only],src-dst...</term>
<listitem>
<para>Default is <emphasis
role="bold">src-dst</emphasis> (e.g., the source IP
addresses in checked against the ipset on input and the
destination IP address is checked against the ipset on
packets originating from the firewall and leaving
through this interface).</para>
</listitem>
</varlistentry>
</variablelist>
<para>The normal setting for this option will be <emphasis
role="bold">dst</emphasis> or <emphasis
role="bold">none</emphasis> for internal interfaces and
<emphasis role="bold">src</emphasis> or <emphasis
role="bold">src-dst</emphasis> for Internet-facing
interfaces.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">destonly</emphasis></term>
@@ -348,7 +414,7 @@ loc eth2 -</programlisting>
url="../bridge-Shorewall-perl.html">Shorewall-perl for
firewall/bridging</ulink>, then you need to include
DHCP-specific rules in <ulink
url="/manpages/shorewall-rules.html">shorewall-rules</ulink>(8).
url="/manpages/shorewall-rules.html">shorewall-rules</ulink>(5).
DHCP uses UDP ports 67 and 68.</para>
</note>
</listitem>
@@ -380,7 +446,7 @@ loc eth2 -</programlisting>
</varlistentry>
<varlistentry>
<term>loopback</term>
<term><emphasis role="bold">loopback</emphasis></term>
<listitem>
<para>Added in Shorewall 4.6.6. Designates the interface as
@@ -451,8 +517,8 @@ loc eth2 -</programlisting>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">mss</emphasis>=<emphasis>number</emphasis></term>
<term><emphasis role="bold"><emphasis
role="bold">mss</emphasis>=</emphasis><emphasis>number</emphasis></term>
<listitem>
<para>Added in Shorewall 4.0.3. Causes forwarded TCP SYN
@@ -488,6 +554,18 @@ loc eth2 -</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">nodbl</emphasis></term>
<listitem>
<para>Added in Shorewall 5.0.8. When specified, dynamic
blacklisting is disabled on the interface. Beginning with
Shorewall 5.0.10, <emphasis role="bold">nodbl</emphasis> is
equivalent to <emphasis
role="bold">dbl=none</emphasis>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">nosmurfs</emphasis></term>

View File

@@ -137,7 +137,7 @@
<replaceable>action</replaceable> must be an action declared
with the <option>mangle</option> option in <ulink
url="manpages/shorewall-actions.html">shorewall-actions(5)</ulink>.
If the action accepts paramaters, they are specified as a
If the action accepts parameters, they are specified as a
comma-separated list within parentheses following the
<replaceable>action</replaceable> name.</para>
</listitem>
@@ -355,7 +355,8 @@ DIVERTHA - - tcp</programlisting>
EF =&gt; 0x2e</programlisting>
<para>To indicate more than one class, add their hex values
together and specify the result.</para>
together and specify the result. By default, DSCP rules are
placed in the POSTROUTING chain.</para>
</listitem>
</varlistentry>
@@ -504,7 +505,7 @@ INLINE eth0 - ; -p tcp -j MARK --set
<member>0xc0a80403 LAND 0xFF = 0x03</member>
<member>0x03 LOR 0x0x10100 = 0x10103 or class ID
<member>0x03 LOR 0x10100 = 0x10103 or class ID
1:103</member>
</simplelist>
</blockquote>
@@ -598,6 +599,36 @@ INLINE eth0 - ; -p tcp -j MARK --set
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">NFLOG</emphasis>[(<emphasis>nflog-parameters</emphasis>)]</term>
<listitem>
<para>Added in Shorewall 5.0.9. Logs matching packets using
NFLOG. The <replaceable>nflog-parameters</replaceable> are a
comma-separated list of up to 3 numbers:</para>
<itemizedlist>
<listitem>
<para>The first number specifies the netlink group
(0-65535). If omitted (e.g., NFLOG(,0,10)) then a value of
0 is assumed.</para>
</listitem>
<listitem>
<para>The second number specifies the maximum number of
bytes to copy. If omitted, 0 (no limit) is assumed.</para>
</listitem>
<listitem>
<para>The third number specifies the number of log
messages that should be buffered in the kernel before they
are sent to user space. The default is 1.</para>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">RESTORE</emphasis>[(<emphasis>mask</emphasis>)]</term>
@@ -1224,6 +1255,17 @@ Normal-Service =&gt; 0x00</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>contiguous</term>
<listitem>
<para>Added in Shoreawll 5.0.12. When <emphasis
role="bold">timestop</emphasis> is smaller than <emphasis
role="bold">timestart</emphasis> value, match this as a single
time period instead of distinct intervals.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>utc</term>
@@ -1334,7 +1376,7 @@ Normal-Service =&gt; 0x00</programlisting>
round-robin fashion between addresses 1.1.1.1, 1.1.1.3, and 1.1.1.9
(Shorewall 4.5.9 and later).</para>
<programlisting>/etc/shorewall/tcrules:
<programlisting>/etc/shorewall/mangle:
#ACTION SOURCE DEST PROTO DPORT SPORT USER TEST
CONNMARK(1-3):F 192.168.1.0/24 eth0 ; state=NEW

View File

@@ -35,7 +35,7 @@
<para>This file determines what to do with a new connection request if
we don't get a match from the /etc/shorewall/rules file . For each
source/destination pair, the file is processed in order until a match is
found ("all" will match any client or server).</para>
found ("all" will match any source or destination).</para>
</important>
<important>
@@ -61,7 +61,7 @@
<variablelist>
<varlistentry>
<term><emphasis role="bold">SOURCE</emphasis> -
<emphasis>zone</emphasis>|<emphasis
<emphasis>zone</emphasis>[,...[+]]|<emphasis
role="bold">$FW</emphasis>|<emphasis
role="bold">all</emphasis>|<emphasis
role="bold">all+</emphasis></term>
@@ -74,12 +74,18 @@
<para>Support for "all+" was added in Shorewall 4.5.17. "all" does
not override the implicit intra-zone ACCEPT policy while "all+"
does.</para>
<para>Beginning with Shorewall 5.0.12, multiple zones may be listed
separated by commas. As above, if '+' is specified after two or more
zone names, then the policy overrides the implicit intra-zone ACCEPT
policy if the same <replaceable>zone</replaceable> appears in both
the SOURCE and DEST columns.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">DEST</emphasis> -
<emphasis>zone</emphasis>|<emphasis
<emphasis>zone</emphasis>[,...[+]]|<emphasis
role="bold">$FW</emphasis>|<emphasis
role="bold">all</emphasis>|<emphasis
role="bold">all+</emphasis></term>
@@ -95,6 +101,12 @@
<para>Support for "all+" was added in Shorewall 4.5.17. "all" does
not override the implicit intra-zone ACCEPT policy while "all+"
does.</para>
<para>Beginning with Shorewall 5.0.12, multiple zones may be listed
separated by commas. As above, if '+' is specified after two or more
zone names, then the policy overrides the implicit intra-zone ACCEPT
policy if the same <replaceable>zone</replaceable> appears in both
the SOURCE and DEST columns.</para>
</listitem>
</varlistentry>

View File

@@ -406,6 +406,16 @@
are present.</para>
</listitem>
</itemizedlist>
<note>
<para>The generated script will attempt to reenable a
disabled persistent provider during execution of the
<command>start</command>, <command>restart</command> and
<command>reload</command> commands. When
<option>persistent</option> is not specified, only the
<command>enable</command> and <command>reenable</command>
commands can reenable the provider.</para>
</note>
</listitem>
</varlistentry>
</variablelist>

View File

@@ -597,7 +597,29 @@
the next rule. See <ulink
url="/shorewall.logging.html">http://www.shorewall.net/shorewall_logging.html</ulink>.</para>
<para>Similar to<emphasis role="bold">
<para>The <replaceable>nflog-parameters</replaceable> are a
comma-separated list of up to 3 numbers:</para>
<itemizedlist>
<listitem>
<para>The first number specifies the netlink group
(0-65535). If omitted (e.g., NFLOG(,0,10)) then a value of
0 is assumed.</para>
</listitem>
<listitem>
<para>The second number specifies the maximum number of
bytes to copy. If omitted, 0 (no limit) is assumed.</para>
</listitem>
<listitem>
<para>The third number specifies the number of log
messages that should be buffered in the kernel before they
are sent to user space. The default is 1.</para>
</listitem>
</itemizedlist>
<para>NFLOG is similar to<emphasis role="bold">
LOG:NFLOG</emphasis>[(<replaceable>nflog-parameters</replaceable>)],
except that the log level is not changed when this ACTION is
used in an action or macro body and the invocation of that
@@ -631,12 +653,12 @@
<varlistentry>
<term><emphasis role="bold"><emphasis
role="bold">NFQUEUE</emphasis>[([<replaceable>queuenumber1</replaceable>[,<replaceable>queuenumber2</replaceable>][,bypass]]|bypass)]</emphasis></term>
role="bold">NFQUEUE!</emphasis>[([<replaceable>queuenumber1</replaceable>[,<replaceable>queuenumber2</replaceable>][,bypass]]|bypass)]</emphasis></term>
<listitem>
<para>like NFQUEUE but exempts the rule from being suppressed
by OPTIMIZE=1 in <ulink
url="/manpages6/shorewall6.conf.html">shorewall6.conf</ulink>(5).</para>
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5).</para>
</listitem>
</varlistentry>
@@ -1660,6 +1682,17 @@
</listitem>
</varlistentry>
<varlistentry>
<term>contiguous</term>
<listitem>
<para>Added in Shoreawll 5.0.12. When <emphasis
role="bold">timestop</emphasis> is smaller than <emphasis
role="bold">timestart</emphasis> value, match this as a single
time period instead of distinct intervals.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>utc</term>

View File

@@ -156,20 +156,23 @@
<varlistentry>
<term><emphasis role="bold">MARK</emphasis> -
{-|<emphasis>value</emphasis>}</term>
{-|<replaceable>value</replaceable>[:<replaceable>priority</replaceable>]}</term>
<listitem>
<para>The mark <emphasis>value</emphasis> which is an integer in the
range 1-255. You set mark values in the <ulink
url="/manpages/shorewall-mangle.html">shorewall-mangle</ulink>(5)
file, marking the traffic you want to fit in the classes defined in
here. Must be specified as '-' if the <emphasis
role="bold">classify</emphasis> option is given for the interface in
<ulink
url="/manpages/shorewall-tcdevices.html">shorewall-tcdevices</ulink>(5)
and you are running Shorewall 4.5.5 or earlier.</para>
here. You can use the same marks for different interfaces.</para>
<para>You can use the same marks for different interfaces.</para>
<para>The <replaceable>priority</replaceable>, if specified, is an
integer in the range 1-65535 and determines the relative order in
which the tc mark classification filter for this class is to be
applied to packets being sent on the
<replaceable>interface</replaceable>. Filters are applied in
ascending numerical order. If not supplied, the value is derived
from the class priority (PRIORITY column value below):
(<replaceable>class priority</replaceable> &lt;&lt; 8) | 20.</para>
</listitem>
</varlistentry>
@@ -293,7 +296,7 @@
<para>This is the default class for that interface where all
traffic should go, that is not classified otherwise.</para>
<para></para>
<para/>
<note>
<para>You must define <emphasis
@@ -320,7 +323,7 @@
priority determines the order in which filter rules are
processed during packet classification. If not specified, the
value (<replaceable>class priority</replaceable> &lt;&lt; 8) |
10) is used.</para>
15) is used.</para>
</listitem>
</varlistentry>
@@ -339,7 +342,7 @@
(":") and a <replaceable>priority</replaceable>. This priority
determines the order in which filter rules are processed
during packet classification. If not specified, the value
(<replaceable>class priority</replaceable> &lt;&lt; 8) | 10)
(<replaceable>class priority</replaceable> &lt;&lt; 8) | 15)
is used.</para>
<programlisting> <emphasis role="bold">tos-minimize-delay</emphasis> 0x10/0x10
@@ -372,7 +375,7 @@
(":") and a <replaceable>priority</replaceable>. This priority
determines the order in which filter rules are processed
during packet classification. If not specified, the value
(<replaceable>class priority</replaceable> &lt;&lt; 8) | 20)
(<replaceable>class priority</replaceable> &lt;&lt; 8) | 10)
is used.</para>
<note>

View File

@@ -307,6 +307,9 @@
that were active when Shorewall stopped continue to work and
all new connections from the firewall system itself are
allowed.</para>
<para>Note that the routestopped file is not supported in
Shorewall 5.0 and later versions.</para>
</listitem>
</varlistentry>
@@ -481,8 +484,8 @@
<para>ALL sends all packets through the blacklist chains.</para>
<para>Note: The ESTABLISHED state may not be specified if FASTACCEPT
is specified.</para>
<para>Note: The ESTABLISHED state may not be specified if
FASTACCEPT=Yes is specified.</para>
</listitem>
</varlistentry>
@@ -577,13 +580,14 @@
<listitem>
<para>If this option is set to <emphasis role="bold">No</emphasis>
then Shorewall won't clear the current traffic control rules during
[re]start. This setting is intended for use by people who prefer to
configure traffic shaping when the network interfaces come up rather
than when the firewall is started. If that is what you want to do,
set TC_ENABLED=Yes and CLEAR_TC=No and do not supply an
/etc/shorewall/tcstart file. That way, your traffic shaping rules
can still use the “fwmark” classifier based on packet marking
defined in <ulink
[<command>re</command>]<command>start</command> or
<command>reload</command>. This setting is intended for use by
people who prefer to configure traffic shaping when the network
interfaces come up rather than when the firewall is started. If that
is what you want to do, set TC_ENABLED=Yes and CLEAR_TC=No and do
not supply an /etc/shorewall/tcstart file. That way, your traffic
shaping rules can still use the “fwmark” classifier based on packet
marking defined in <ulink
url="/manpages/shorewall-tcrules.html">shorewall-tcrules</ulink>(5).
If not specified, CLEAR_TC=Yes is assumed.</para>
</listitem>
@@ -677,8 +681,8 @@
<listitem>
<para>If set to Yes (the default value), entries in the
/etc/shorewall/route_stopped files cause an 'ip rule del' command to
be generated in addition to an 'ip rule add' command. Setting this
/etc/shorewall/rtrules files cause an 'ip rule del' command to be
generated in addition to an 'ip rule add' command. Setting this
option to No, causes the 'ip rule del' command to be omitted.</para>
</listitem>
</varlistentry>
@@ -761,15 +765,87 @@
<varlistentry>
<term><emphasis role="bold">DYNAMIC_BLACKLIST=</emphasis>{<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>}</term>
role="bold">Yes</emphasis>|<emphasis
role="bold">No</emphasis>||<emphasis
role="bold">ipset</emphasis>[<emphasis
role="bold">-only</emphasis>][<replaceable>,option</replaceable>[,...]][:[<replaceable>setname</replaceable>][:<replaceable>log_level</replaceable>|:l<replaceable>og_tag</replaceable>]]]}</term>
<listitem>
<para>Added in Shorewall 4.4.7. When set to <emphasis
role="bold">No</emphasis> or <emphasis role="bold">no</emphasis>,
dynamic blacklisting using the <command>shorewall drop</command>,
<command>shorewall reject</command>, <command>shorewall
logdrop</command> and <command>shorewall logreject</command> is
disabled. Default is <emphasis role="bold">Yes</emphasis>.</para>
chain-based dynamic blacklisting using <command>shorewall
drop</command>, <command>shorewall reject</command>,
<command>shorewall logdrop</command> and <command>shorewall
logreject</command> is disabled. Default is <emphasis
role="bold">Yes</emphasis>. Beginning with Shorewall 5.0.8,
ipset-based dynamic blacklisting using the <command>shorewall
blacklist</command> command is also supported. The name of the set
(<replaceable>setname</replaceable>) and the level
(<replaceable>log_level</replaceable>), if any, at which blacklisted
traffic is to be logged may also be specified. The default set name
is SW_DBL4 and the default log level is <option>none</option> (no
logging). If <option>ipset-only</option> is given, then chain-based
dynamic blacklisting is disabled just as if DYNAMIC_BLACKLISTING=No
had been specified.</para>
<para>Possible <replaceable>option</replaceable>s are:</para>
<variablelist>
<varlistentry>
<term>src-dst</term>
<listitem>
<para>Normally, only packets whose source address matches an
entry in the ipset are dropped. If <option>src-dst</option> is
included, then packets whose destination address matches an
entry in the ipset are also dropped.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>disconnect</option></term>
<listitem>
<para>The <option>disconnect</option> option was added in
Shorewall 5.0.13 and requires that the conntrack utility be
installed on the firewall system. When an address is
blacklisted using the <command>blacklist</command> command,
all connections originating from that address are
disconnected. if the <option>src-dst</option> option was also
specified, then all connections to that address are also
disconnected.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>timeout</option>=<replaceable>seconds</replaceable></term>
<listitem>
<para>Added in Shorewall 5.0.13. Normally, Shorewall creates
the dynamic blacklisting ipset with timeout 0 which means that
entries are permanent. If you want entries in the set that are
not accessed for a period of time to be deleted from the set,
you may specify that period using this option. Note that the
<command>blacklist</command> command can override the ipset's
timeout setting.</para>
<important>
<para>Once the dynamic blacklisting ipset has been created,
changing this option setting requires a complete restart of
the firewall; <command>shorewall restart</command> if
RESTART=restart, otherwise <command>shorewall stop
&amp;&amp; shorewall start</command></para>
</important>
</listitem>
</varlistentry>
</variablelist>
<para>When ipset-based dynamic blacklisting is enabled, the contents
of the blacklist will be preserved over
<command>stop</command>/<command>reboot</command>/<command>start</command>
sequences if SAVE_IPSETS=Yes, SAVE_IPSETS=ipv4 or if
<replaceable>setname</replaceable> is included in the list of sets
to be saved in SAVE_IPSETS.</para>
</listitem>
</varlistentry>
@@ -806,7 +882,7 @@ net all DROP info</programlisting>then the chain name is 'net-all'
helpers file from the administrative system into the script. When
set to No or not specified, the compiler will not copy the modules
or helpers file from <filename>/usr/share/shorewall</filename> but
will copy the found in another location on the CONFIG_PATH.</para>
will copy those found in another location on the CONFIG_PATH.</para>
<para>When compiling for direct use by Shorewall, causes the
contents of the local module or helpers file to be copied into the
@@ -824,7 +900,8 @@ net all DROP info</programlisting>then the chain name is 'net-all'
packets until these packets reach the chain in which the original
connection was accepted. So for packets going from the 'loc' zone to
the 'net' zone, ESTABLISHED/RELATED packets are ACCEPTED in the
'loc2net' chain.</para>
'loc-net' or 'loc2net' chain, depending on the setting of ZONE2ZONE
(see below).</para>
<para>If you set FASTACCEPT=Yes, then ESTABLISHED/RELATED packets
are accepted early in the INPUT, FORWARD and OUTPUT chains. If you
@@ -834,12 +911,27 @@ net all DROP info</programlisting>then the chain name is 'net-all'
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">FIREWALL</emphasis>=[<emphasis>dnsname-or-ip-address</emphasis>]</term>
<listitem>
<para>This option was added in Shorewall 5.0.13 and may be used on
an administrative system in directories containing the
configurations of remote firewalls. The contents of the variable are
the default value for the <replaceable>system</replaceable>
parameter to the <command>remote-start</command>,
<command>remote-reload</command> and
<command>remote-restart</command> commands.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">FORWARD_CLEAR_MARK=</emphasis>{<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>}</term>
<listitem>
<para>Added in Shorewall 4.4.11 Beta 3. Traditionally, Shorewall has
<para>Added in Shorewall 4.4.11. Traditionally, Shorewall has
cleared the packet mark in the first rule in the mangle FORWARD
chain. This behavior is maintained with the default setting of this
option (FORWARD_CLEAR_MARK=Yes). If FORWARD_CLEAR_MARK is set to
@@ -1330,7 +1422,7 @@ net all DROP info</programlisting>then the chain name is 'net-all'
<varlistentry>
<term><emphasis
role="bold">LOGFILE=</emphasis>[<emphasis>pathname</emphasis>]</term>
role="bold">LOGFILE=</emphasis>[<emphasis>pathname</emphasis>|<option>systemd</option>]</term>
<listitem>
<para>This parameter tells the /sbin/shorewall program where to look
@@ -1340,7 +1432,10 @@ net all DROP info</programlisting>then the chain name is 'net-all'
log</emphasis>, and <emphasis role="bold">hits</emphasis> commands.
If not assigned or if assigned an empty value, /var/log/messages is
assumed. For further information, see <ulink
url="/shorewall_logging.html">http://www.shorewall.net/shorewall_logging.html</ulink>.</para>
url="/shorewall_logging.html">http://www.shorewall.net/shorewall_logging.html</ulink>.
Beginning with Shorewall 5.0.10.1, you may specify
<option>systemd</option> to use <command>journelctl -r</command> to
read the log.</para>
</listitem>
</varlistentry>
@@ -1978,6 +2073,9 @@ LOG:info:,bar net fw</programlisting>
When PAGER is given, the output of verbose <command>status</command>
commands and the <command>dump</command> command are piped through
the named program when the output file is a terminal.</para>
<para>Beginning with Shorewall 5.0.12, the default value of this
option is the DEFAULT_PAGER setting in shorewallrc.</para>
</listitem>
</varlistentry>
@@ -2167,18 +2265,18 @@ LOG:info:,bar net fw</programlisting>
#TARGET SOURCE DEST PROTO
Broadcast(DROP) - - -
DROP - - 2
INLINE - - 6 ; -j REJECT --reject-with tcp-reset
INLINE - - 6 ;; -j REJECT --reject-with tcp-reset
?if __ENHANCED_REJECT
INLINE - - 17 ; -j REJECT
INLINE - - 17 ;; -j REJECT
?if __IPV4
INLINE - - 1 ; -j REJECT --reject-with icmp-host-unreachable
INLINE - - - ; -j REJECT --reject-with icmp-host-prohibited
INLINE - - 1 ;; -j REJECT --reject-with icmp-host-unreachable
INLINE - - - ;; -j REJECT --reject-with icmp-host-prohibited
?else
INLINE - - 58 ; -j REJECT --reject-with icmp6-addr-unreachable
INLINE - - - ; -j REJECT --reject-with icmp6-adm-prohibited
INLINE - - 58 ;; -j REJECT --reject-with icmp6-addr-unreachable
INLINE - - - ;; -j REJECT --reject-with icmp6-adm-prohibited
?endif
?else
INLINE - - - ; -j REJECT
INLINE - - - ;; -j REJECT
?endif</programlisting>
</listitem>
</varlistentry>
@@ -2248,7 +2346,7 @@ INLINE - - - ; -j REJECT
restored unconditionally at the top of the mangle OUTPUT and
PREROUTING chains, even if the saved mark is zero. When this option
is set to <emphasis role="bold">No</emphasis>, the mark is restored
even when it is zero. If you have problems with IPSEC ESP packets
only if it is non-zero. If you have problems with IPSEC ESP packets
not being routed correctly on output, try setting this option to
<emphasis role="bold">No</emphasis>.</para>
</listitem>
@@ -2424,10 +2522,9 @@ INLINE - - - ; -j REJECT
<listitem>
<para>This option is used to specify the shell program to be used to
run the Shorewall compiler and to interpret the compiled script. If
not specified or specified as a null value, /bin/sh is assumed.
Using a light-weight shell such as ash or dash can significantly
improve performance.</para>
interpret the compiled script. If not specified or specified as a
null value, /bin/sh is assumed. Using a light-weight shell such as
ash or dash can significantly improve performance.</para>
</listitem>
</varlistentry>
@@ -2480,8 +2577,10 @@ INLINE - - - ; -j REJECT
<para>If specified, determines where Shorewall will log the details
of each <emphasis role="bold">start</emphasis>, <emphasis
role="bold">reload</emphasis>, <emphasis
role="bold">restart</emphasis> and <emphasis
role="bold">refresh</emphasis> command. Logging verbosity is
role="bold">restart</emphasis>, <emphasis
role="bold">refresh</emphasis>, <emphasis
role="bold">try</emphasis>, and <emphasis
role="bold">safe-</emphasis>* command. Logging verbosity is
determined by the setting of LOG_VERBOSITY above.</para>
</listitem>
</varlistentry>
@@ -2838,6 +2937,20 @@ INLINE - - - ; -j REJECT
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">VERBOSE_MESSAGES=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
<listitem>
<para>Added in Shorewall 5.0.9. When Yes (the default), messages
produced by the ?INFO and ?WARNING directives include the filename
and linenumber of the directive. When set to No, that additional
information is omitted. The setting may be overridden on a directive
by directive basis by following ?INFO or ?WARNING with '!' (no
intervening white space).</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">VERBOSITY=</emphasis>[<emphasis>number</emphasis>]</term>
@@ -2898,6 +3011,23 @@ INLINE - - - ; -j REJECT
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">ZERO_MARKS=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
<listitem>
<para>Added in Shorewall 5.0.12, this is a workaround for an issue
where packet marks are not zeroed by the kernel. It should be set to
No (the default) unless you find that incoming packets are being
mis-routed for no apparent reasons.</para>
<caution>
<para>Do not set this option to Yes if you have IPSEC software
running on the firewall system.</para>
</caution>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">ZONE_BITS</emphasis>=[<replaceable>number</replaceable>]</term>

View File

@@ -49,6 +49,21 @@
<arg choice="plain"><replaceable>address</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>shorewall</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>blacklist</option></arg>
<arg
choice="plain"><replaceable>address</replaceable><arg><replaceable>option</replaceable>
...</arg></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>shorewall</command>
@@ -436,9 +451,9 @@
<arg><option>-i</option></arg>
<arg><replaceable>directory</replaceable></arg>
<arg><arg><option>-D</option></arg><replaceable>directory</replaceable></arg>
<arg choice="plain"><replaceable>system</replaceable></arg>
<arg choice="plain"><arg><replaceable>system</replaceable></arg></arg>
</cmdsynopsis>
<cmdsynopsis>
@@ -460,9 +475,9 @@
<arg><option>-i</option></arg>
<arg><replaceable>directory</replaceable></arg>
<arg><arg><option>-D</option></arg><replaceable>directory</replaceable></arg>
<arg choice="plain"><replaceable>system</replaceable></arg>
<arg choice="plain"><arg><replaceable>system</replaceable></arg></arg>
</cmdsynopsis>
<cmdsynopsis>
@@ -484,9 +499,9 @@
<arg><option>-i</option></arg>
<arg><replaceable>directory</replaceable></arg>
<arg><arg><option>-D</option></arg><replaceable>directory</replaceable></arg>
<arg choice="plain"><replaceable>system</replaceable></arg>
<arg choice="plain"><arg><replaceable>system</replaceable></arg></arg>
</cmdsynopsis>
<cmdsynopsis>
@@ -951,7 +966,45 @@
blacklisted by a <emphasis role="bold">drop</emphasis>, <emphasis
role="bold">logdrop</emphasis>, <emphasis
role="bold">reject</emphasis>, or <emphasis
role="bold">logreject</emphasis> command.</para>
role="bold">logreject</emphasis> command. Beginning with Shorewall
5.0.10, this command can also re-enable addresses blacklisted using
the <command>blacklist</command> command.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">blacklist</emphasis>
<replaceable>address</replaceable> [ <replaceable>option</replaceable>
... ]</term>
<listitem>
<para>Added in Shorewall 5.0.8 and requires
DYNAMIC_BLACKLIST=ipset.. in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5).
Causes packets from the given host or network
<replaceable>address</replaceable> to be dropped, based on the
setting of BLACKLIST in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5). The
<replaceable>address</replaceable> along with any
<replaceable>option</replaceable>s are passed to the <command>ipset
add</command> command.</para>
<para>If the <option>disconnect</option> option is specified in the
DYNAMIC_BLACKLISTING setting, then the effective VERBOSITY
determines the amount of information displayed:</para>
<itemizedlist>
<listitem>
<para>If the effective verbosity is &gt; 0, then a message
giving the number of conntrack flows deleted by the command is
displayed.</para>
</listitem>
<listitem>
<para>If the effective verbosity is &gt; 1, then the conntrack
table entries deleted by the command are also displayed.</para>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
@@ -1578,8 +1631,8 @@
<term><emphasis role="bold">remote-start</emphasis>
[-<option>s</option>] [-<option>c</option>] [-<option>r</option>
<replaceable>root-user-name</replaceable>] [-<option>T</option>]
[-<option>i</option>] [ <replaceable>directory</replaceable> ]
<replaceable>system</replaceable></term>
[-<option>i</option>] [ [ -D ] <replaceable>directory</replaceable> ]
[ <replaceable>system</replaceable> ]</term>
<listitem>
<para>This command was renamed from <command>load</command> in
@@ -1605,7 +1658,13 @@
directory. If compilation succeeds, then firewall is copied to
<replaceable>system</replaceable> using scp. If the copy succeeds,
Shorewall Lite on <replaceable>system</replaceable> is started via
ssh.</para>
ssh. Beginning with Shorewall 5.0.13, if
<replaceable>system</replaceable> is omitted, then the FIREWALL
option setting in <ulink
url="shorewall6.conf.html">shorewall6.conf(5)</ulink> is assumed. In
that case, if you want to specify a
<replaceable>directory</replaceable>, then the <option>-D</option>
option must be given.</para>
<para>If <emphasis role="bold">-s</emphasis> is specified and the
<emphasis role="bold">start</emphasis> command succeeds, then the
@@ -1640,9 +1699,9 @@
<term><emphasis role="bold">remote-reload
</emphasis>[-<option>s</option>] [-<option>c</option>]
[-<option>r</option> <replaceable>root-user-name</replaceable>]
[-<option>T</option>] [-<option>i</option>] [
<replaceable>directory</replaceable> ]
<replaceable>system</replaceable></term>
[-<option>T</option>] [-<option>i</option>] [ [ -D ]
<replaceable>directory</replaceable> ] [
<replaceable>system</replaceable> ]</term>
<listitem>
<para>This command was added in Shorewall 5.0.0.</para>
@@ -1666,8 +1725,14 @@
defaulted) directory is compiled to a file called firewall in that
directory. If compilation succeeds, then firewall is copied to
<emphasis>system</emphasis> using scp. If the copy succeeds,
Shorewall Lite on <emphasis>system</emphasis> is restarted via
ssh.</para>
Shorewall Lite on <emphasis>system</emphasis> is restarted via ssh.
Beginning with Shorewall 5.0.13, if
<replaceable>system</replaceable> is omitted, then the FIREWALL
option setting in <ulink
url="shorewall6.conf.html">shorewall6.conf(5)</ulink> is assumed. In
that case, if you want to specify a
<replaceable>directory</replaceable>, then the <option>-D</option>
option must be given.</para>
<para>If <emphasis role="bold">-s</emphasis> is specified and the
<emphasis role="bold">restart</emphasis> command succeeds, then the
@@ -1702,9 +1767,9 @@
<term><emphasis role="bold">remote-restart
</emphasis>[-<option>s</option>] [-<option>c</option>]
[-<option>r</option> <replaceable>root-user-name</replaceable>]
[-<option>T</option>] [-<option>i</option>] [
<replaceable>directory</replaceable> ]
<replaceable>system</replaceable></term>
[-<option>T</option>] [-<option>i</option>] [ [ -D ]
<replaceable>directory</replaceable> ] [
<replaceable>system</replaceable> ]</term>
<listitem>
<para>This command was renamed from <command>reload</command> in
@@ -1729,8 +1794,14 @@
defaulted) directory is compiled to a file called firewall in that
directory. If compilation succeeds, then firewall is copied to
<emphasis>system</emphasis> using scp. If the copy succeeds,
Shorewall Lite on <emphasis>system</emphasis> is restarted via
ssh.</para>
Shorewall Lite on <emphasis>system</emphasis> is restarted via ssh.
Beginning with Shorewall 5.0.13, if
<replaceable>system</replaceable> is omitted, then the FIREWALL
option setting in <ulink
url="shorewall6.conf.html">shorewall6.conf(5)</ulink> is assumed. In
that case, if you want to specify a
<replaceable>directory</replaceable>, then the <option>-D</option>
option must be given.</para>
<para>If <emphasis role="bold">-s</emphasis> is specified and the
<emphasis role="bold">restart</emphasis> command succeeds, then the
@@ -2593,6 +2664,34 @@
started.</para>
</refsect1>
<refsect1>
<title>ENVIRONMENT</title>
<para>Two environmental variables are recognized by Shorewall:</para>
<variablelist>
<varlistentry>
<term>SHOREWALL_INIT_SCRIPT</term>
<listitem>
<para>When set to 1, causes Std out to be redirected to the file
specified in the STARTUP_LOG option in <ulink
url="shorewall.conf.html">shorewall.conf(5)</ulink>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>SW_LOGGERTAG</term>
<listitem>
<para>Added in Shorewall 5.0.8. When set to a non-empty value, that
value is passed to the logger utility in its -t (--tag)
option.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>FILES</title>

View File

@@ -215,7 +215,7 @@ rm -rf ${SHAREDIR}/shorewall/configfiles/
rm -rf ${SHAREDIR}/shorewall/Samples/
rm -rf ${SHAREDIR}/shorewall/Shorewall/
rm -f ${SHAREDIR}/shorewall/lib.cli-std
rm -f ${SHAREDIR}/shorewall/lib.core
rm -f ${SHAREDIR}/shorewall/lib.runtime
rm -f ${SHAREDIR}/shorewall/compiler.pl
rm -f ${SHAREDIR}/shorewall/prog.*
rm -f ${SHAREDIR}/shorewall/module*

View File

@@ -5,7 +5,7 @@
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: S
# Default-Stop: 0 6
# Default-Stop: 0 1 6
# Short-Description: Configure the firewall at boot time
# Description: Configure the firewall according to the rules specified in
# /etc/shorewall6-lite
@@ -92,10 +92,11 @@ shorewall6_start () {
# stop the firewall
shorewall6_stop () {
echo -n "Stopping \"Shorewall6 Lite firewall\": "
if [ "$SAFESTOP" = 1 ]; then
echo -n "Stopping \"Shorewall6 Lite firewall\": "
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
else
echo -n "Clearing all \"Shorewall6 Lite firewall\" rules: "
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
fi
return 0

View File

@@ -47,6 +47,19 @@
<arg choice="plain"><replaceable>address</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>shorewall6-lite</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>blacklist</option></arg>
<arg choice="plain"><replaceable>address</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>shorewall6-lite</command>
@@ -666,7 +679,45 @@
<para>Re-enables receipt of packets from hosts previously
blacklisted by a <command>drop</command>,
<command>logdrop</command>, <command>reject</command>, or
<command>logreject</command> command.</para>
<command>logreject</command> command. Beginning with Shorewall
5.0.10, this command can also re-enable addresses blacklisted using
the <command>blacklist</command> command.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">blacklist</emphasis>
<replaceable>address</replaceable> [ <replaceable>option</replaceable>
... ]</term>
<listitem>
<para>Added in Shorewall 5.0.8 and requires
DYNAMIC_BLACKLIST=ipset.. in <ulink
url="/manpages6/shorewall6.conf.html">shorewall6.conf</ulink>(5).
Causes packets from the given host or network
<replaceable>address</replaceable> to be dropped, based on the
setting of BLACKLIST in <ulink
url="/manpages6/shorewall6.conf.html">shorewall6.conf</ulink>(5).
The <replaceable>address</replaceable> along with any
<replaceable>option</replaceable>s are passed to the <command>ipset
add</command> command.</para>
<para>If the <option>disconnect</option> option is specified in the
DYNAMIC_BLACKLISTING setting, then the effective VERBOSITY
determines the amount of information displayed:</para>
<itemizedlist>
<listitem>
<para>If the effective verbosity is &gt; 0, then a message
giving the number of conntrack flows deleted by the command is
displayed.</para>
</listitem>
<listitem>
<para>If the effective verbosity is &gt; 1, then the conntrack
table entries deleted by the command are also displayed.</para>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
@@ -1515,6 +1566,35 @@
started.</para>
</refsect1>
<refsect1>
<title>ENVIRONMENT</title>
<para>Two environmental variables are recognized by
Shorewall6-lite:</para>
<variablelist>
<varlistentry>
<term>SHOREWALL_INIT_SCRIPT</term>
<listitem>
<para>When set to 1, causes Std out to be redirected to the file
specified in the STARTUP_LOG option in <ulink
url="shorewall6.conf.html">shorewall6.conf(5)</ulink>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>SW_LOGGERTAG</term>
<listitem>
<para>Added in Shorewall 5.0.8. When set to a non-empty value, that
value is passed to the logger utility in its -t (--tag)
option.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See ALSO</title>

View File

@@ -24,6 +24,12 @@ VERBOSITY=1
PAGER=
###############################################################################
# F I R E W A L L
###############################################################################
FIREWALL=
###############################################################################
# L O G G I N G
###############################################################################
@@ -121,15 +127,13 @@ ACCOUNTING_TABLE=filter
ADMINISABSENTMINDED=Yes
BASIC_FILTERS=No
IGNOREUNKNOWNVARIABLES=No
AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No
AUTOMAKE=Yes
BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED"
@@ -159,6 +163,8 @@ FORWARD_CLEAR_MARK=
HELPERS=
IGNOREUNKNOWNVARIABLES=No
IMPLICIT_CONTINUE=No
INLINE_MATCHES=Yes
@@ -213,10 +219,14 @@ USE_PHYSICAL_NAMES=No
USE_RT_NAMES=No
VERBOSE_MESSAGES=Yes
WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZERO_MARKS=No
ZONE2ZONE=-
###############################################################################

View File

@@ -25,6 +25,12 @@ VERBOSITY=1
PAGER=
###############################################################################
# F I R E W A L L
###############################################################################
FIREWALL=
###############################################################################
# L O G G I N G
###############################################################################
@@ -122,15 +128,13 @@ ACCOUNTING_TABLE=filter
ADMINISABSENTMINDED=Yes
BASIC_FILTERS=No
IGNOREUNKNOWNVARIABLES=No
AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No
AUTOMAKE=Yes
BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED"
@@ -160,6 +164,8 @@ FORWARD_CLEAR_MARK=
HELPERS=
IGNOREUNKNOWNVARIABLES=No
IMPLICIT_CONTINUE=No
INLINE_MATCHES=Yes
@@ -214,10 +220,14 @@ USE_PHYSICAL_NAMES=No
USE_RT_NAMES=No
VERBOSE_MESSAGES=Yes
WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZERO_MARKS=No
ZONE2ZONE=-
###############################################################################

View File

@@ -24,6 +24,12 @@ VERBOSITY=1
PAGER=
###############################################################################
# F I R E W A L L
###############################################################################
FIREWALL=
###############################################################################
# L O G G I N G
###############################################################################
@@ -121,15 +127,13 @@ ACCOUNTING_TABLE=filter
ADMINISABSENTMINDED=Yes
BASIC_FILTERS=No
IGNOREUNKNOWNVARIABLES=No
AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No
AUTOMAKE=Yes
BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED"
@@ -159,6 +163,8 @@ FORWARD_CLEAR_MARK=
HELPERS=
IGNOREUNKNOWNVARIABLES=No
IMPLICIT_CONTINUE=No
INLINE_MATCHES=Yes
@@ -213,10 +219,14 @@ USE_PHYSICAL_NAMES=No
USE_RT_NAMES=No
VERBOSE_MESSAGES=Yes
WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZERO_MARKS=No
ZONE2ZONE=-
###############################################################################

View File

@@ -24,6 +24,12 @@ VERBOSITY=1
PAGER=
###############################################################################
# F I R E W A L L
###############################################################################
FIREWALL=
###############################################################################
# L O G G I N G
###############################################################################
@@ -121,15 +127,13 @@ ACCOUNTING_TABLE=filter
ADMINISABSENTMINDED=Yes
BASIC_FILTERS=No
IGNOREUNKNOWNVARIABLES=No
AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No
AUTOMAKE=Yes
BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED"
@@ -159,6 +163,8 @@ FORWARD_CLEAR_MARK=
HELPERS=
IGNOREUNKNOWNVARIABLES=No
IMPLICIT_CONTINUE=No
INLINE_MATCHES=Yes
@@ -213,10 +219,14 @@ USE_PHYSICAL_NAMES=No
USE_RT_NAMES=No
VERBOSE_MESSAGES=Yes
WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZERO_MARKS=No
ZONE2ZONE=-
###############################################################################

View File

@@ -24,6 +24,12 @@ VERBOSITY=1
PAGER=
###############################################################################
# F I R E W A L L
###############################################################################
FIREWALL=
###############################################################################
# L O G G I N G
###############################################################################
@@ -121,16 +127,14 @@ ACCOUNTING_TABLE=filter
ADMINISABSENTMINDED=Yes
BASIC_FILTERS=No
IGNOREUNKNOWNVARIABLES=No
AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOMAKE=No
BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED"
CHAIN_SCRIPTS=Yes
@@ -159,6 +163,8 @@ FORWARD_CLEAR_MARK=Yes
HELPERS=
IGNOREUNKNOWNVARIABLES=No
IMPLICIT_CONTINUE=No
INLINE_MATCHES=No
@@ -213,10 +219,14 @@ USE_PHYSICAL_NAMES=No
USE_RT_NAMES=No
VERBOSE_MESSAGES=Yes
WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZERO_MARKS=No
ZONE2ZONE=-
###############################################################################

View File

@@ -4,7 +4,7 @@
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: S
# Default-Stop: 0 6
# Default-Stop: 0 1 6
# Short-Description: Configure the firewall at boot time
# Description: Configure the firewall according to the rules specified in
# /etc/shorewall6
@@ -97,10 +97,11 @@ shorewall6_start () {
# stop the firewall
shorewall6_stop () {
echo -n "Stopping \"Shorewall6 firewall\": "
if [ "$SAFESTOP" = 1 ]; then
echo -n "Stopping \"Shorewall6 firewall\": "
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
else
echo -n "Clearing all \"Shorewall6 firewall\" rules: "
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
fi
return 0

View File

@@ -237,6 +237,66 @@ loc eth2 -</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">dbl={none|src|dst|src-dst}</emphasis></term>
<listitem>
<para>Added in Shorewall 5.0.10. This option defined whether
or not dynamic blacklisting is applied to packets entering the
firewall through this interface and whether the source address
and/or destination address is to be compared against the
ipset-based dynamic blacklist (DYNAMIC_BLACKLIST=ipset... in
<ulink
url="manpages6/shorewall6.conf.html">shorewall6.conf(5)</ulink>).
The default is determine by the setting of
DYNAMIC_BLACKLIST:</para>
<variablelist>
<varlistentry>
<term>DYNAMIC_BLACKLIST=No</term>
<listitem>
<para>Default is <emphasis role="bold">none</emphasis>
(e.g., no dynamic blacklist checking).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>DYNAMIC_BLACKLIST=Yes</term>
<listitem>
<para>Default is <emphasis role="bold">src</emphasis>
(e.g., the source IP address is checked against the
ipset).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>DYNAMIC_BLACKLIST=ipset[-only]</term>
<listitem>
<para>Default is <emphasis
role="bold">src</emphasis>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>DYNAMIC_BLACKLIST=ipset[-only],src-dst...</term>
<listitem>
<para>Default is <emphasis
role="bold">src-dst</emphasis> (e.g., the source IP
addresses in checked against the ipset on input and the
destination IP address is checked against the ipset on
packets originating from the firewall and leaving
through this interface).</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">destonly</emphasis></term>
@@ -321,7 +381,7 @@ loc eth2 -</programlisting>
</varlistentry>
<varlistentry>
<term>loopback</term>
<term><emphasis role="bold">loopback</emphasis></term>
<listitem>
<para>Added in Shorewall 4.6.6. Designates the interface as
@@ -365,6 +425,18 @@ loc eth2 -</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">nodbl</emphasis></term>
<listitem>
<para>Added in Shorewall 5.0.8. When specified, dynamic
blacklisting is disabled on the interface. Beginning with
Shorewall 5.0.10, <emphasis role="bold">nodbl</emphasis> is
equivalent to <emphasis
role="bold">dbl=none</emphasis>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">optional</emphasis></term>

View File

@@ -138,7 +138,7 @@
<replaceable>action</replaceable> must be an action declared
with the <option>mangle</option> option in <ulink
url="manpages6/shorewall6-actions.html">shorewall6-actions(5)</ulink>.
If the action accepts paramaters, they are specified as a
If the action accepts parameters, they are specified as a
comma-separated list within parentheses following the
<replaceable>action</replaceable> name.</para>
</listitem>
@@ -356,7 +356,8 @@ DIVERTHA - - tcp</programlisting>
EF =&gt; 0x2e</programlisting>
<para>To indicate more than one class, add their hex values
together and specify the result.</para>
together and specify the result. By default, DSCP rules are
placed in the POSTROUTING chain.</para>
</listitem>
</varlistentry>
@@ -515,7 +516,7 @@ INLINE eth0 - ; -p tcp -j MARK --set
<member>0xc0a80403 LAND 0xFF = 0x03</member>
<member>0x03 LOR 0x0x10100 = 0x10103 or class ID
<member>0x03 LOR 0x10100 = 0x10103 or class ID
1:103</member>
</simplelist>
</blockquote>
@@ -609,6 +610,36 @@ INLINE eth0 - ; -p tcp -j MARK --set
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">NFLOG</emphasis>[(<emphasis>nflog-parameters</emphasis>)]</term>
<listitem>
<para>Added in Shorewall 5.0.9. Logs matching packets using
NFLOG. The <replaceable>nflog-parameters</replaceable> are a
comma-separated list of up to 3 numbers:</para>
<itemizedlist>
<listitem>
<para>The first number specifies the netlink group
(0-65535). If omitted (e.g., NFLOG(,0,10)) then a value of
0 is assumed.</para>
</listitem>
<listitem>
<para>The second number specifies the maximum number of
bytes to copy. If omitted, 0 (no limit) is assumed.</para>
</listitem>
<listitem>
<para>The third number specifies the number of log
messages that should be buffered in the kernel before they
are sent to user space. The default is 1.</para>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">RESTORE</emphasis>[(<emphasis>mask</emphasis>)]</term>
@@ -1300,6 +1331,17 @@ Normal-Service =&gt; 0x00</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>contiguous</term>
<listitem>
<para>Added in Shoreawll 5.0.12. When <emphasis
role="bold">timestop</emphasis> is smaller than <emphasis
role="bold">timestart</emphasis> value, match this as a single
time period instead of distinct intervals.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>utc</term>

View File

@@ -551,8 +551,8 @@
<programlisting>/etc/shorewall/masq:
#INTERFACE SOURCE ADDRESS
INLINE(sit1) 0.0.0.0/0 2001:470:a:227::1 ; -m statistic --mode random --probability 0.50
sit1 0.0.0.0/0 2001:470:a:227::2
INLINE(sit1) ::/0 2001:470:a:227::1 ; -m statistic --mode random --probability 0.50
sit1 ::/0 2001:470:a:227::2
</programlisting>
<para>If INLINE_MATCHES=Yes in <ulink
@@ -562,9 +562,8 @@
<programlisting>/etc/shorewall/masq:
#INTERFACE SOURCE ADDRESS
sit1 0.0.0.0/0 2001:470:a:227::1 ; -m statistic --mode random --probability 0.50
sit1 0.0.0.0/0 2001:470:a:227::2
</programlisting>
sit1 ::/0 2001:470:a:227::1 ; -m statistic --mode random --probability 0.50
sit1 ::/0 2001:470:a:227::2</programlisting>
</listitem>
</varlistentry>
</variablelist>

View File

@@ -35,7 +35,7 @@
<para>This file determines what to do with a new connection request if
we don't get a match from the /etc/shorewall6/rules file . For each
source/destination pair, the file is processed in order until a match is
found ("all" will match any client or server).</para>
found ("all" will match any source or destination).</para>
</important>
<important>
@@ -61,7 +61,7 @@
<variablelist>
<varlistentry>
<term><emphasis role="bold">SOURCE</emphasis> -
<emphasis>zone</emphasis>|<emphasis
<emphasis>zone</emphasis>[,...[+]]|<emphasis
role="bold">$FW</emphasis>|<emphasis
role="bold">all</emphasis>|<emphasis
role="bold">all+</emphasis></term>
@@ -74,12 +74,18 @@
<para>Support for "all+" was added in Shorewall 4.5.17. "all" does
not override the implicit intra-zone ACCEPT policy while "all+"
does.</para>
<para>Beginning with Shorewall 5.0.12, multiple zones may be listed
separated by commas. As above, if '+' is specified after two or more
zone names, then the policy overrides the implicit intra-zone ACCEPT
policy if the same <replaceable>zone</replaceable> appears in both
the SOURCE and DEST columns.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">DEST</emphasis> -
<emphasis>zone</emphasis>|<emphasis
<emphasis>zone</emphasis>[,...[+]]|<emphasis
role="bold">$FW</emphasis>|<emphasis
role="bold">all</emphasis>|<emphasis
role="bold">all+</emphasis></term>
@@ -95,6 +101,12 @@
<para>Support for "all+" was added in Shorewall 4.5.17. "all" does
not override the implicit intra-zone ACCEPT policy while "all+"
does.</para>
<para>Beginning with Shorewall 5.0.12, multiple zones may be listed
separated by commas. As above, if '+' is specified after two or more
zone names, then the policy overrides the implicit intra-zone ACCEPT
policy if the same <replaceable>zone</replaceable> appears in both
the SOURCE and DEST columns.</para>
</listitem>
</varlistentry>

View File

@@ -159,26 +159,40 @@
</varlistentry>
<varlistentry>
<term><emphasis role="bold">balance</emphasis></term>
<term><emphasis
role="bold">balance[=<replaceable>weight</replaceable>]</emphasis></term>
<listitem>
<para>Added in Shorewall 4.4.25. Causes a default route to
this provider's gateway to be added to the <emphasis
role="bold">main</emphasis> routing table (USE_DEFAULT_RT=No)
or to the <emphasis role="bold">balance</emphasis> routing
table (USE_DEFAULT_RT=Yes). Only one provider can specify this
option.</para>
<para>Added in Shorewall 4.4.25. The providers that have
<option>balance</option> specified will get outbound traffic
load-balanced among them. By default, all interfaces with
<option>balance</option> specified will have the same weight
(1). Beginning with Shorewall 5.0.13, you can change the
weight of an interface by specifying
<option>balance=</option><replaceable>weight</replaceable>
where <replaceable>weight</replaceable> is the weight of the
route out of this interface. Prior to Shorewall 5.0.13, only
one provider can specify this option.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">fallback</emphasis></term>
<term><emphasis
role="bold">fallback[=<replaceable>weight</replaceable>]</emphasis></term>
<listitem>
<para>Added in Shorewall 4.4.25. Causes a default route to
this provider's gateway to be added to the <emphasis
role="bold">default</emphasis> routing table.At most one
provider can specify this option.</para>
<para>Added in Shorewall 4.4.25. Indicates that a default
route through the provider should be added to the default
routing table (table 253). If a
<replaceable>weight</replaceable> is given, a balanced route
is added with the weight of this provider equal to the
specified <replaceable>weight</replaceable>. If the option is
given without a <replaceable>weight</replaceable>, an separate
default route is added through the provider's gateway; the
route has a metric equal to the provider's NUMBER. Prior to
Shorewall 5.0.13, at most one provider can specify this option
and a <replaceable>weight</replaceable> may not be
given.</para>
</listitem>
</varlistentry>
@@ -377,6 +391,16 @@
are present.</para>
</listitem>
</itemizedlist>
<note>
<para>The generated script will attempt to reenable a
disabled persistent provider during execution of the
<command>start</command>, <command>restart</command> and
<command>reload</command> commands. When
<option>persistent</option> is not specified, only the
<command>enable</command> and <command>reenable</command>
commands can reenable the provider.</para>
</note>
</listitem>
</varlistentry>
</variablelist>

View File

@@ -574,7 +574,29 @@
the next rule. See <ulink
url="/shorewall_logging.html">http://www.shorewall.net/shorewall_logging.html</ulink>.</para>
<para>Similar to<emphasis role="bold">
<para>The <replaceable>nflog-parameters</replaceable> are a
comma-separated list of up to 3 numbers:</para>
<itemizedlist>
<listitem>
<para>The first number specifies the netlink group
(0-65535). If omitted (e.g., NFLOG(,0,10)) then a value of
0 is assumed.</para>
</listitem>
<listitem>
<para>The second number specifies the maximum number of
bytes to copy. If omitted, 0 (no limit) is assumed.</para>
</listitem>
<listitem>
<para>The third number specifies the number of log
messages that should be buffered in the kernel before they
are sent to user space. The default is 1.</para>
</listitem>
</itemizedlist>
<para>NFLOG is similar to<emphasis role="bold">
LOG:NFLOG</emphasis>[(<replaceable>nflog-parameters</replaceable>)],
except that the log level is not changed when this ACTION is
used in an action or macro and the invocation of that action
@@ -608,7 +630,7 @@
<varlistentry>
<term><emphasis role="bold"><emphasis
role="bold">NFQUEUE</emphasis>[([<replaceable>queuenumber1</replaceable>[,<replaceable>queuenumber2</replaceable>][,bypass]]|bypass)]</emphasis></term>
role="bold">NFQUEUE!</emphasis>[([<replaceable>queuenumber1</replaceable>[,<replaceable>queuenumber2</replaceable>][,bypass]]|bypass)]</emphasis></term>
<listitem>
<para>like NFQUEUE but exempts the rule from being suppressed
@@ -1525,6 +1547,17 @@
</listitem>
</varlistentry>
<varlistentry>
<term>contiguous</term>
<listitem>
<para>Added in Shoreawll 5.0.12. When <emphasis
role="bold">timestop</emphasis> is smaller than <emphasis
role="bold">timestart</emphasis> value, match this as a single
time period instead of distinct intervals.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>utc</term>
@@ -1636,7 +1669,7 @@
<varlistentry>
<term><emphasis role="bold">route</emphasis>, <emphasis
role="bold">ipv6-route</emphasis> or <emphasis
role="bold">41</emphasis></term>
role="bold">43</emphasis></term>
<listitem>
<para>IPv6 Route extension header.</para>

View File

@@ -152,20 +152,23 @@
<varlistentry>
<term><emphasis role="bold">MARK</emphasis> -
{-|<emphasis>value</emphasis>}</term>
{-|<replaceable>value</replaceable>[:<replaceable>priority</replaceable>]}</term>
<listitem>
<para>The mark <emphasis>value</emphasis> which is an integer in the
range 1-255. You set mark values in the <ulink
url="/manpages6/shorewall6-mangle.html">shorewall6-mangle</ulink>(5)
url="/manpages/shorewall-mangle.html">shorewall-mangle</ulink>(5)
file, marking the traffic you want to fit in the classes defined in
here. Must be specified as '-' if the <emphasis
role="bold">classify</emphasis> option is given for the interface in
<ulink
url="/manpages6/shorewall6-tcdevices.html">shorewall6-tcdevices</ulink>(5)
and you are running Shorewall 4.5 5 or earlier.</para>
here. You can use the same marks for different interfaces.</para>
<para>You can use the same marks for different interfaces.</para>
<para>The <replaceable>priority</replaceable>, if specified, is an
integer in the range 1-65535 and determines the relative order in
which the tc mark classification filter for this class is to be
applied to packets being sent on the
<replaceable>interface</replaceable>. Filters are applied in
ascending numerical order. If not supplied, the value is derived
from the class priority (PRIORITY column value below):
(<replaceable>class priority</replaceable> &lt;&lt; 8) | 20.</para>
</listitem>
</varlistentry>
@@ -314,7 +317,7 @@
priority determines the order in which filter rules are
processed during packet classification. If not specified, the
value (<replaceable>class priority</replaceable> &lt;&lt; 8) |
10) is used.</para>
15) is used.</para>
</listitem>
</varlistentry>
@@ -366,7 +369,7 @@
(":") and a <replaceable>priority</replaceable>. This priority
determines the order in which filter rules are processed
during packet classification. If not specified, the value
(<replaceable>class priority</replaceable> &lt;&lt; 8) | 20)
(<replaceable>class priority</replaceable> &lt;&lt; 8) | 10)
is used.</para>
<note>

View File

@@ -239,6 +239,9 @@
that were active when Shorewall stopped continue to work and
all new connections from the firewall system itself are
allowed.</para>
<para>Note that the routestopped file is not supported in
Shorewall 5.0 and later versions.</para>
</listitem>
</varlistentry>
@@ -497,13 +500,14 @@
<listitem>
<para>If this option is set to <emphasis role="bold">No</emphasis>
then Shorewall6 won't clear the current traffic control rules during
[re]start. This setting is intended for use by people that prefer to
configure traffic shaping when the network interfaces come up rather
than when the firewall is started. If that is what you want to do,
set TC_ENABLED=Yes and CLEAR_TC=No and do not supply an
/etc/shorewall6/tcstart file. That way, your traffic shaping rules
can still use the “fwmark” classifier based on packet marking
defined in <ulink
[<command>re</command>]<command>start</command> or
<command>reload</command>. This setting is intended for use by
people that prefer to configure traffic shaping when the network
interfaces come up rather than when the firewall is started. If that
is what you want to do, set TC_ENABLED=Yes and CLEAR_TC=No and do
not supply an /etc/shorewall6/tcstart file. That way, your traffic
shaping rules can still use the “fwmark” classifier based on packet
marking defined in <ulink
url="/manpages6/shorewall6-tcrules.html">shorewall6-tcrules</ulink>(5).
If not specified, CLEAR_TC=No is assumed.</para>
@@ -604,10 +608,9 @@
<listitem>
<para>If set to Yes (the default value), entries in the
/etc/shorewall6/route_stopped files cause an 'ip rule del' command
to be generated in addition to an 'ip rule add' command. Setting
this option to No, causes the 'ip rule del' command to be
omitted.</para>
/etc/shorewall6/rtrules file cause an 'ip rule del' command to be
generated in addition to an 'ip rule add' command. Setting this
option to No, causes the 'ip rule del' command to be omitted.</para>
</listitem>
</varlistentry>
@@ -623,15 +626,87 @@
<varlistentry>
<term><emphasis role="bold">DYNAMIC_BLACKLIST=</emphasis>{<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>}</term>
role="bold">Yes</emphasis>|<emphasis
role="bold">No</emphasis>||<emphasis
role="bold">ipset</emphasis>[<emphasis
role="bold">-only</emphasis>][<replaceable>,option</replaceable>[,...]][:[<replaceable>setname</replaceable>][:<replaceable>log_level</replaceable>|:l<replaceable>og_tag</replaceable>]]]}</term>
<listitem>
<para>Added in Shorewall 4.4.7. When set to <emphasis
role="bold">No</emphasis> or <emphasis role="bold">no</emphasis>,
dynamic blacklisting using the <command>shorewall6 drop</command>,
<command>shorewall6 reject</command>, <command>shorewall6
logdrop</command> and <command>shorewall6 logreject</command> is
disabled. Default is <emphasis role="bold">Yes</emphasis>.</para>
chain-based dynamic blacklisting using <command>shorewall6
drop</command>, <command>shorewall6 reject</command>,
<command>shorewall6 logdrop</command> and <command>shorewall6
logreject</command> is disabled. Default is <emphasis
role="bold">Yes</emphasis>. Beginning with Shorewall 5.0.8,
ipset-based dynamic blacklisting using <command>shorewall6
blacklist</command> is also supported. The name of the set
(<replaceable>setname</replaceable>) and the level
(<replaceable>log_level</replaceable>), if any, at which blacklisted
traffic is to be logged may also be specified. The default set name
is SW_DBL6 and the default log level is <option>none</option> (no
logging). if <option>ipset-only</option> is given, then chain-based
dynamic blacklisting is disabled just as if DYNAMIC_BLACKLISTING=No
had been specified.</para>
<para>Possible <replaceable>option</replaceable>s are:</para>
<variablelist>
<varlistentry>
<term>src-dst</term>
<listitem>
<para>Normally, only packets whose source address matches an
entry in the ipset are dropped. If <option>src-dst</option> is
included, then packets whose destination address matches an
entry in the ipset are also dropped.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>disconnect</option></term>
<listitem>
<para>The <option>disconnect</option> option was added in
Shorewall 5.0.13 and requires that the conntrack utility be
installed on the firewall system. When an address is
blacklisted using the <command>blacklist</command> command,
all connections originating from that address are
disconnected. if the <option>src-dst</option> option was also
specified, then all connections to that address are also
disconnected.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>timeout</option>=<replaceable>seconds</replaceable></term>
<listitem>
<para>Added in Shorewall 5.0.13. Normally, Shorewall creates
the dynamic blacklisting ipset with timeout 0 which means that
entries are permanent. If you want entries in the set that are
not accessed for a period of time to be deleted from the set,
you may specify that period using this option. Note that the
<command>blacklist</command> command can override the ipset's
timeout setting.</para>
<important>
<para>Once the dynamic blacklisting ipset has been created,
changing this option setting requires a complete restart of
the firewall; <command>shorewall6 restart</command> if
RESTART=restart, otherwise <command>shorewall6 stop
&amp;&amp; shorewall6 start</command></para>
</important>
</listitem>
</varlistentry>
</variablelist>
<para>When ipset-based dynamic blacklisting is enabled, the contents
of the blacklist will be preserved over
<command>stop</command>/<command>reboot</command>/<command>start</command>
sequences if SAVE_IPSETS=Yes or if
<replaceable>setname</replaceable> is included in the list of sets
to be saved in SAVE_IPSETS.</para>
</listitem>
</varlistentry>
@@ -668,7 +743,7 @@ net all DROP info</programlisting>then the chain name is 'net-all'
helpers file from the administrative system into the script. When
set to No or not specified, the compiler will not copy the modules
or helpers file from <filename>/usr/share/shorewall6</filename> but
will copy the found in another location on the CONFIG_PATH.</para>
will copy those found in another location on the CONFIG_PATH.</para>
<para>When compiling for direct use by Shorewall6, causes the
contents of the local module or helpers file to be copied into the
@@ -686,7 +761,8 @@ net all DROP info</programlisting>then the chain name is 'net-all'
packets until these packets reach the chain in which the original
connection was accepted. So for packets going from the 'loc' zone to
the 'net' zone, ESTABLISHED/RELATED packets are ACCEPTED in the
'loc2net' chain.</para>
'loc-net' or 'loc2net' chain, depending on the setting of ZONE2ZONE
(see below).</para>
<para>If you set FASTACCEPT=Yes, then ESTABLISHED/RELATED packets
are accepted early in the INPUT, FORWARD and OUTPUT chains. If you
@@ -696,12 +772,27 @@ net all DROP info</programlisting>then the chain name is 'net-all'
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">FIREWALL</emphasis>=[<emphasis>dnsname-or-ip-address</emphasis>]</term>
<listitem>
<para>This option was added in Shorewall 5.0.13 and may be used on
an administrative system in directories containing the
configurations of remote firewalls. The contents of the variable are
the default value for the <replaceable>system</replaceable>
parameter to the <command>remote-start</command>,
<command>remote-reload</command> and
<command>remote-restart</command> commands.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">FORWARD_CLEAR_MARK=</emphasis>{<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>}</term>
<listitem>
<para>Added in Shorewall 4.4.11 Beta 3. Traditionally, Shorewall has
<para>Added in Shorewall 4.4.11. Traditionally, Shorewall has
cleared the packet mark in the first rule in the mangle FORWARD
chain. This behavior is maintained with the default setting of this
option (FORWARD_CLEAR_MARK=Yes). If FORWARD_CLEAR_MARK is set to
@@ -1142,7 +1233,7 @@ net all DROP info</programlisting>then the chain name is 'net-all'
<varlistentry>
<term><emphasis
role="bold">LOGFILE=</emphasis>[<emphasis>pathname</emphasis>]</term>
role="bold">LOGFILE=</emphasis>[<emphasis>pathname</emphasis>|<option>systemd</option>]</term>
<listitem>
<para>This parameter tells the /sbin/shorewall6 program where to
@@ -1151,7 +1242,9 @@ net all DROP info</programlisting>then the chain name is 'net-all'
role="bold">logwatch</emphasis>, <emphasis role="bold">show
log</emphasis>, and <emphasis role="bold">hits</emphasis> commands.
If not assigned or if assigned an empty value, /var/log/messages is
assumed.</para>
assumed. Beginning with Shorewall 5.0.10.1, you may specify
<option>systemd</option> to use <command>journelctl -r</command> to
read the log.</para>
</listitem>
</varlistentry>
@@ -1705,6 +1798,9 @@ LOG:info:,bar net fw</programlisting>
When PAGER is given, the output of verbose <command>status</command>
commands and the <command>dump</command> command are piped through
the named program when the output file is a terminal.</para>
<para>Beginning with Shorewall 5.0.12, the default value of this
option is the DEFAULT_PAGER setting in shorewallrc.</para>
</listitem>
</varlistentry>
@@ -1896,18 +1992,18 @@ LOG:info:,bar net fw</programlisting>
#TARGET SOURCE DEST PROTO
Broadcast(DROP) - - -
DROP - - 2
INLINE - - 6 ; -j REJECT --reject-with tcp-reset
INLINE - - 6 ;; -j REJECT --reject-with tcp-reset
?if __ENHANCED_REJECT
INLINE - - 17 ; -j REJECT
INLINE - - 17 ;; -j REJECT
?if __IPV4
INLINE - - 1 ; -j REJECT --reject-with icmp-host-unreachable
INLINE - - - ; -j REJECT --reject-with icmp-host-prohibited
INLINE - - 1 ;; -j REJECT --reject-with icmp-host-unreachable
INLINE - - - ;; -j REJECT --reject-with icmp-host-prohibited
?else
INLINE - - 58 ; -j REJECT --reject-with icmp6-addr-unreachable
INLINE - - - ; -j REJECT --reject-with icmp6-adm-prohibited
INLINE - - 58 ;; -j REJECT --reject-with icmp6-addr-unreachable
INLINE - - - ;; -j REJECT --reject-with icmp6-adm-prohibited
?endif
?else
INLINE - - - ; -j REJECT
INLINE - - - ;; -j REJECT
?endif</programlisting>
</listitem>
</varlistentry>
@@ -1956,7 +2052,7 @@ INLINE - - - ; -j REJECT
restored unconditionally at the top of the mangle OUTPUT and
PREROUTING chains, even if the saved mark is zero. When this option
is set to <emphasis role="bold">No</emphasis>, the mark is restored
even when it is zero. If you have problems with IPSEC ESP packets
only if it is non-zero. If you have problems with IPSEC ESP packets
not being routed correctly on output, try setting this option to
<emphasis role="bold">No</emphasis>.</para>
</listitem>
@@ -2115,11 +2211,13 @@ INLINE - - - ; -j REJECT
role="bold">STARTUP_LOG=</emphasis>[<emphasis>pathname</emphasis>]</term>
<listitem>
<para>If specified, determines where Shorewall6 will log the details
<para>If specified, determines where Shorewall will log the details
of each <emphasis role="bold">start</emphasis>, <emphasis
role="bold">reload</emphasis>, <emphasis
role="bold">restart</emphasis> and <emphasis
role="bold">refresh</emphasis> command. Logging verbosity is
role="bold">restart</emphasis>, <emphasis
role="bold">refresh</emphasis>, <emphasis
role="bold">try</emphasis>, and <emphasis
role="bold">safe-</emphasis>* command. Logging verbosity is
determined by the setting of LOG_VERBOSITY above.</para>
</listitem>
</varlistentry>
@@ -2480,6 +2578,20 @@ INLINE - - - ; -j REJECT
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">VERBOSE_MESSAGES=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
<listitem>
<para>Added in Shorewall 5.0.9. When Yes (the default), messages
produced by the ?INFO and ?WARNING directives include the filename
and linenumber of the directive. When set to No, that additional
information is omitted. The setting may be overridden on a directive
by directive basis by following ?INFO or ?WARNING with '!' (no
intervening white space).</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">VERBOSITY=</emphasis>[<emphasis>number</emphasis>]</term>
@@ -2556,6 +2668,23 @@ INLINE - - - ; -j REJECT
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">ZERO_MARKS=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
<listitem>
<para>Added in Shorewall 5.0.12, this is a workaround for an issue
where packet marks are not zeroed by the kernel. It should be set to
No (the default) unless you find that incoming packets are being
mis-routed for no apparent reasons.</para>
<caution>
<para>Do not set this option to Yes if you have IPSEC software
running on the firewall system.</para>
</caution>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">ZONE_BITS</emphasis>=[<replaceable>number</replaceable>]</term>

View File

@@ -44,8 +44,21 @@
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>allow</option></arg>
</cmdsynopsis>
<arg choice="plain"><replaceable>address</replaceable></arg>
<cmdsynopsis>
<command>shorewall6</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>blacklist</option></arg>
<arg choice="plain"><replaceable>address</replaceable><arg
choice="plain"><arg><replaceable>option
...</replaceable></arg></arg></arg>
</cmdsynopsis>
<cmdsynopsis>
@@ -390,9 +403,9 @@
<arg><option>-i</option></arg>
<arg><replaceable>directory</replaceable></arg>
<arg><arg><option>-D</option></arg><replaceable>directory</replaceable></arg>
<arg choice="plain"><replaceable>system</replaceable></arg>
<arg choice="opt"><replaceable>system</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
@@ -414,9 +427,9 @@
<arg><option>-i</option></arg>
<arg><replaceable>directory</replaceable></arg>
<arg><arg><option>-D</option></arg><replaceable>directory</replaceable></arg>
<arg choice="plain"><replaceable>system</replaceable></arg>
<arg choice="opt"><replaceable>system</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
@@ -438,9 +451,9 @@
<arg><option>-i</option></arg>
<arg><replaceable>directory</replaceable></arg>
<arg><arg><option>-D</option></arg><replaceable>directory</replaceable></arg>
<arg choice="plain"><replaceable>system</replaceable></arg>
<arg choice="opt"><replaceable>system</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
@@ -919,7 +932,45 @@
blacklisted by a <emphasis role="bold">drop</emphasis>, <emphasis
role="bold">logdrop</emphasis>, <emphasis
role="bold">reject</emphasis>, or <emphasis
role="bold">logreject</emphasis> command.</para>
role="bold">logreject</emphasis> command. Beginning with Shorewall
5.0.10, this command can also re-enable addresses blacklisted using
the <command>blacklist</command> command.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">blacklist</emphasis>
<replaceable>address</replaceable> [ <replaceable>option</replaceable>
... ]</term>
<listitem>
<para>Added in Shorewall 5.0.8 and requires
DYNAMIC_BLACKLIST=ipset.. in <ulink
url="/manpages6/shorewall6.conf.html">shorewall6.conf</ulink>(5).
Causes packets from the given host or network
<replaceable>address</replaceable> to be dropped, based on the
setting of BLACKLIST in <ulink
url="/manpages6/shorewall6.conf.html">shorewall6.conf</ulink>(5).
The <replaceable>address</replaceable> along with any
<replaceable>option</replaceable>s are passed to the <command>ipset
add</command> command.</para>
<para>If the <option>disconnect</option> option is specified in the
DYNAMIC_BLACKLISTING setting, then the effective VERBOSITY
determines the amount of information displayed:</para>
<itemizedlist>
<listitem>
<para>If the effective verbosity is &gt; 0, then a message
giving the number of conntrack flows deleted by the command is
displayed.</para>
</listitem>
<listitem>
<para>If the effective verbosity is &gt; 1, then the conntrack
table entries deleted by the command are also displayed.</para>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
@@ -1514,9 +1565,11 @@
<term><emphasis role="bold">remote-reload
</emphasis>[-<option>s</option>] [-<option>c</option>]
[-<option>r</option> <replaceable>root-user-name</replaceable>]
[-<option>T</option>] [-<option>i</option>] [
<replaceable>directory</replaceable> ]
<replaceable>system</replaceable></term>
[-<option>T</option>] [-<option>i</option>] [ [ -D ]
<replaceable>directory</replaceable> ] [
<replaceable>system</replaceable> ]</term>
<term/>
<listitem>
<para>This command was added in Shorewall 5.0.0.</para>
@@ -1540,8 +1593,14 @@
defaulted) directory is compiled to a file called firewall in that
directory. If compilation succeeds, then firewall is copied to
<emphasis>system</emphasis> using scp. If the copy succeeds,
Shorewall6 Lite on <emphasis>system</emphasis> is restarted via
ssh.</para>
Shorewall6 Lite on <emphasis>system</emphasis> is restarted via ssh.
Beginning with Shorewall 5.0.13, if
<replaceable>system</replaceable> is omitted, then the FIREWALL
option setting in <ulink
url="shorewall6.conf.html">shorewall6.conf(5)</ulink> is assumed. In
that case, if you want to specify a
<replaceable>directory</replaceable>, then the <option>-D</option>
option must be given.</para>
<para>If <option>-s</option> is specified and the
<command>restart</command> command succeeds, then the remote
@@ -1576,9 +1635,9 @@
<term><emphasis role="bold">remote- restart
</emphasis>[-<option>s</option>] [-<option>c</option>]
[-<option>r</option> <replaceable>root-user-name</replaceable>]
[-<option>T</option>] [-<option>i</option>] [
<replaceable>directory</replaceable> ]
<replaceable>system</replaceable></term>
[-<option>T</option>] [-<option>i</option>] [ [ -D ]
<replaceable>directory</replaceable> ] [
<replaceable>system</replaceable> ]</term>
<listitem>
<para>This command was renamed from <command>reload</command> in
@@ -1606,6 +1665,14 @@
Shorewall6 Lite on <emphasis>system</emphasis> is restarted via
ssh.</para>
<para>Beginning with Shorewall 5.0.13, if
<replaceable>system</replaceable> is omitted, then the FIREWALL
option setting in <ulink
url="shorewall6.conf.html">shorewall6.conf(5)</ulink> is assumed. In
that case, if you want to specify a
<replaceable>directory</replaceable>, then the <option>-D</option>
option must be given.</para>
<para>If <option>-s</option> is specified and the
<command>restart</command> command succeeds, then the remote
Shorewall6-lite configuration is saved by executing
@@ -1639,8 +1706,8 @@
<term><emphasis role="bold">remote-start </emphasis>
[-<option>s</option>] [-<option>c</option>] [-<option>r</option>
<replaceable>root-user-name</replaceable>] [-<option>T</option>]
[-<option>i</option>] [ <replaceable>directory</replaceable> ]
<replaceable>system</replaceable></term>
[-<option>i</option>] [ [-D ] <replaceable>directory</replaceable> ] [
<replaceable>system</replaceable> ]</term>
<listitem>
<para>This command was added in Shorewall 5.0.0.</para>
@@ -1665,7 +1732,13 @@
directory. If compilation succeeds, then firewall is copied to
<replaceable>system</replaceable> using scp. If the copy succeeds,
Shorewall6 Lite on <replaceable>system</replaceable> is started via
ssh.</para>
ssh. Beginning with Shorewall 5.0.13, if
<replaceable>system</replaceable> is omitted, then the FIREWALL
option setting in <ulink
url="shorewall6.conf.html">shorewall6.conf(5)</ulink> is assumed. In
that case, if you want to specify a
<replaceable>directory</replaceable>, then the <option>-D</option>
option must be given.</para>
<para>If <option>-s</option> is specified and the <emphasis
role="bold">start</emphasis> command succeeds, then the remote
@@ -2469,6 +2542,34 @@
started.</para>
</refsect1>
<refsect1>
<title>ENVIRONMENT</title>
<para>Two environmental variables are recognized by Shorewall6:</para>
<variablelist>
<varlistentry>
<term>SHOREWALL_INIT_SCRIPT</term>
<listitem>
<para>When set to 1, causes Std out to be redirected to the file
specified in the STARTUP_LOG option in <ulink
url="shorewall6.conf.html">shorewall6.conf(5)</ulink>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>SW_LOGGERTAG</term>
<listitem>
<para>Added in Shorewall 5.0.8. When set to a non-empty value, that
value is passed to the logger utility in its -t (--tag)
option.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See ALSO</title>

View File

@@ -61,7 +61,7 @@
<listitem>
<para><emphasis role="bold">Shorewall6</emphasis>. This package
requires the Shorewall package and adds those components needed to
create an IPv6 fireawall.</para>
create an IPv6 firewall.</para>
</listitem>
<listitem>

View File

@@ -74,7 +74,7 @@
<section>
<title>Documentation for Earlier Versions</title>
<para><ulink url="4.2/Documentation_Index.html">Shorewall 4.4/4.6
<para><ulink url="4.6/Documentation_Index.html">Shorewall 4.4/4.6
Documentation</ulink></para>
<para><ulink url="4.2/Documentation_Index.html">Shorewall 4.0/4.2

View File

@@ -95,6 +95,11 @@ rsyncok eth1:<emphasis role="bold">dynamic</emphasis></programlisting>
<para>When the <emphasis role="bold">dynamic_shared</emphasis> option is
specified, a single ipset is created; the ipset has the same name as the
zone.</para>
<para>In the above example, <emphasis role="bold">rsyncok</emphasis> is
a sub-zone of the single zone <emphasis role="bold">loc</emphasis>.
Making a dynamic zone a sub-zone of multiple other zones is also
supported.</para>
</section>
<section id="Adding">

View File

@@ -204,7 +204,7 @@
<para>If the <replaceable>action</replaceable> involves logging,
then this parameter specifies the disposition that will appear in
the log entry prefix. If no <replaceable>disposition</replaceable>
is given, the log prefix is determines normally. The default is
is given, the log prefix is determined normally. The default is
ACCEPT.</para>
</listitem>
</varlistentry>
@@ -258,7 +258,7 @@
<para>If the <replaceable>action</replaceable> involves logging,
then this parameter specifies the disposition that will appear in
the log entry prefix. If no <replaceable>disposition</replaceable>
is given, the log prefix is determines normally.</para>
is given, the log prefix is determined normally.</para>
</listitem>
</varlistentry>
</variablelist>
@@ -404,7 +404,7 @@
<para>If the <replaceable>action</replaceable> involves logging,
then this parameter specifies the disposition that will appear in
the log entry prefix. If no <replaceable>disposition</replaceable>
is given, the log prefix is determines normally.</para>
is given, the log prefix is determined normally.</para>
</listitem>
</varlistentry>
</variablelist>

View File

@@ -26,6 +26,8 @@
<year>2011</year>
<year>2016</year>
<holder>Thomas M. Eastep</holder>
</copyright>
@@ -89,7 +91,9 @@
<listitem>
<para><ulink url="two-interface.htm">Two-interface</ulink> Linux System
acting as a firewall/router for a small local network</para>
acting as a firewall/router for a small local network. For
Redhat-specific install/configure information, see <ulink url="???">this
article </ulink>contributed by Digimer.</para>
</listitem>
<listitem>

View File

@@ -398,7 +398,7 @@ ACCEPT net $FW tcp 22</programlisting>
<listitem>
<para><emphasis role="bold">Shorewall6</emphasis>. This package
requires the Shorewall package and adds those components needed to
create an IPv6 fireawall.</para>
create an IPv6 firewall.</para>
</listitem>
<listitem>

View File

@@ -766,7 +766,7 @@ fi</programlisting>
provider interfaces as <emphasis role="bold">optional</emphasis> (<ulink
url="manpages/shorewall-interfaces.html">shorewall-interfaces(5)</ulink>)
then <link linkend="LinkMonitor">install and configure
LSM</link>.</para>
FOOLSM</link>.</para>
<para><ulink url="Shorewall-init.html">Shorewall-init</ulink> provides
for handling links that go hard down and are later brought back
@@ -926,7 +926,7 @@ eth1 0.0.0.0/0 130.252.99.27</programlisting>
</section>
<section id="Example2">
<title id="Example99"> Example using USE_DEFAULT_RT=Yes</title>
<title id="Example99">Example using USE_DEFAULT_RT=Yes</title>
<para>This section shows the differences in configuring the above
example with USE_DEFAULT_RT=Yes. The changes are confined to the
@@ -1937,8 +1937,8 @@ if [ $2 != down ]; then
[ -f /var/lib/shorewall/eth0.info ] &amp;&amp; . /var/lib/shorewall/eth0.info
if [ "$GATEWAYS" != "$ETH0_GATEWAY" -o "$IPADDR" != "$ETH0_ADDRESS" ]; then
logger -p daemon.info "eth0 IP configuration changed - restarting lsm and Shorewall"
killall lsm
logger -p daemon.info "eth0 IP configuration changed - restarting foolsm and Shorewall"
killall foolsm
/sbin/shorewall restart
fi
fi
@@ -1953,9 +1953,9 @@ fi
</listitem>
<listitem>
<para>It assumes the use of <link linkend="lsm">LSM</link>; If
you aren't using lSM, you can change the log message and remove
the 'killall lsm'</para>
<para>It assumes the use of <link linkend="lsm">FOOLSM</link>;
If you aren't using foolsm, you can change the log message and
remove the 'killall foolsm'</para>
</listitem>
<listitem>
@@ -2090,9 +2090,9 @@ ComcastC 2 - - eth0 detect loose,fallback,load=0.33
<section id="LinkMonitor">
<title>Gateway Monitoring and Failover</title>
<para>There is an option (LSM) available for monitoring the status of
provider links and taking action when a failure occurs. LSM assumes that
each provider has a unique nexthop gateway.</para>
<para>There is an option (FOOLSM) available for monitoring the status of
provider links and taking action when a failure occurs. FOOLSM assumes
that each provider has a unique nexthop gateway.</para>
<para>You specify the <option>optional</option> option in
<filename>/etc/shorewall/interfaces</filename>:</para>
@@ -2102,7 +2102,7 @@ net eth0 detect <emphasis role="bold">optional</emphasis>
net eth1 detect <emphasis role="bold">optional</emphasis></programlisting>
<section id="lsm">
<title>Link Status Monitor (LSM)</title>
<title>Link Status Monitor (FOOLSM)</title>
<para><ulink url="http://lsm.foobar.fi/">Link Status Monitor</ulink>
was written by Mika Ilmaranta &lt;ilmis at nullnet.fi&gt; and performs
@@ -2116,19 +2116,25 @@ net eth1 detect <emphasis role="bold">optional</emphasis><
file</ulink>) before installing LSM.</para>
</important>
<para>Like many Open Source products, LSM is poorly documented. It's
main configuration file is normally kept in
<filename>/etc/lsm/lsm.conf</filename>, but the file's name is passed
as an argument to the lsm program so you can name it anything you
want.</para>
<important>
<para>To avoid an achronym clash with <emphasis>Linux Security
Module</emphasis>, the Link Status Monitor is now called
<emphasis>foolsm</emphasis>.</para>
</important>
<para>The sample <filename>lsm.conf</filename> included with the
<para>Like many Open Source products, FOOLSM is poorly documented.
It's main configuration file is normally kept in
<filename>/etc/foolsm/foolsm.conf</filename>, but the file's name is
passed as an argument to the foolsm program so you can name it
anything you want.</para>
<para>The sample <filename>foolsm.conf</filename> included with the
product shows some of the possibilities for configuration. One feature
that is not mentioned in the sample is that an "include" directive is
supported. This allows additional files to be sourced in from the main
configuration file.</para>
<para>LSM monitors the status of the links defined in its
<para>FOOLSM monitors the status of the links defined in its
configuration file and runs a user-provided script when the status of
a link changes. The script name is specified in the
<firstterm>eventscript</firstterm> option in the configuration file.
@@ -2175,33 +2181,33 @@ net eth1 detect <emphasis role="bold">optional</emphasis><
<para>It is the responsibility of the script to perform any action
needed in reaction to the connection state change. The default script
supplied with LSM composes an email and sends it to $5.</para>
supplied with FOOLSM composes an email and sends it to $5.</para>
<para>I personally use LSM here at shorewall.net (configuration is
<para>I personally use FOOLSM here at shorewall.net (configuration is
described <link linkend="Complete">below</link>). I have set things up
so that:</para>
<itemizedlist>
<listitem>
<para>Shorewall [re]starts lsm during processing of the
<para>Shorewall [re]starts foolsm during processing of the
<command>start</command> and <command>restore</command> commands.
I don't have Shorewall restart lsm during Shorewall
I don't have Shorewall restart foolsm during Shorewall
<command>restart</command> because I restart Shorewall much more
often than the average user is likely to do.</para>
</listitem>
<listitem>
<para>Shorewall starts lsm because I have a dynamic IP address
<para>Shorewall starts foolsm because I have a dynamic IP address
from one of my providers (Comcast); Shorewall detects the default
gateway to that provider and creates a secondary configuration
file (<filename>/etc/lsm/shorewall.conf</filename>) that contains
the link configurations. That file is included by
<filename>/etc/lsm/lsm.conf</filename>.</para>
file (<filename>/etc/foolsm/shorewall.conf</filename>) that
contains the link configurations. That file is included by
<filename>/etc/foolsm/foolsm.conf</filename>.</para>
</listitem>
<listitem>
<para>The script run by LSM during state change
(<filename>/etc/lsm/script) </filename>writes a<filename>
<para>The script run by FOOLSM during state change
(<filename>/etc/foolsm/script) </filename>writes a<filename>
${VARDIR}/xxx.status</filename> file when the status of an
interface changes. Those files are read by the
<filename>isusable</filename> extension script (see below).</para>
@@ -2224,7 +2230,7 @@ COM_IF=eth1</programlisting>
<programlisting>local status=0
#
# Read the status file (if any) created by /etc/lsm/script
# Read the status file (if any) created by /etc/foolsm/script
#
[ -f ${VARDIR}/${1}.status ] &amp;&amp; status=$(cat ${VARDIR}/${1}.status)
@@ -2233,22 +2239,22 @@ return $status</programlisting>
<para><filename>/etc/shorewall/lib.private</filename>:</para>
<programlisting>###############################################################################
# Create /etc/lsm/shorewall.conf
# Create /etc/foolsm/shorewall.conf
# Remove the current interface status files
# Start lsm
# Start foolsm
###############################################################################
start_lsm() {
start_foolsm() {
#
# Kill any existing lsm process(es)
# Kill any existing foolsm process(es)
#
killall lsm 2&gt; /dev/null
killall foolsm 2&gt; /dev/null
#
# Create the Shorewall-specific part of the LSM configuration. This file is
# included by /etc/lsm/lsm.conf
# Create the Shorewall-specific part of the FOOLSM configuration. This file is
# included by /etc/foolsm/foolsm.conf
#
# Avvanta has a static gateway while Comcast's is dynamic
#
cat &lt;&lt;EOF &gt; /etc/lsm/shorewall.conf
cat &lt;&lt;EOF &gt; /etc/foolsm/shorewall.conf
connection {
name=Avvanta
checkip=206.124.146.254
@@ -2264,14 +2270,9 @@ connection {
}
EOF
#
# Since LSM assumes that interfaces start in the 'up' state, remove any
# existing status files that might have an interface in the down state
# Run FOOLSM -- by default, it forks into the background
#
rm -f /var/lib/shorewall/*.status
#
# Run LSM -- by default, it forks into the background
#
/usr/sbin/lsm -c /etc/lsm/lsm.conf &gt;&gt; /var/log/lsm
/usr/sbin/foolsm -c /etc/foolsm/foolsm.conf &gt;&gt; /var/log/foolsm
}</programlisting>
<para>eth0 has a dynamic IP address so I need to use the
@@ -2286,22 +2287,22 @@ EOF
<para><filename>/etc/shorewall/started</filename>:</para>
<programlisting>##################################################################################
# [re]start lsm if this is a 'start' command or if lsm isn't running
# [re]start foolsm if this is a 'start' command or if foolsm isn't running
##################################################################################
if [ "$COMMAND" = start -o -z "$(ps ax | grep 'lsm ' | grep -v 'grep ' )" ]; then
start_lsm
if [ "$COMMAND" = start -o -z "$(ps ax | grep 'foolsm ' | grep -v 'grep ' )" ]; then
start_foolsm
fi</programlisting>
<para><filename>/etc/shorewall/restored</filename>:</para>
<programlisting>##################################################################################
# Start lsm if it isn't running
# Start foolsm if it isn't running
##################################################################################
if [ -z "$(ps ax | grep 'lsm ' | grep -v 'grep ' )" ]; then
start_lsm
if [ -z "$(ps ax | grep 'foolsm ' | grep -v 'grep ' )" ]; then
start_foolsm
fi</programlisting>
<para><filename>/etc/lsm/lsm.conf</filename>:</para>
<para><filename>/etc/foolsm/foolsm.conf</filename>:</para>
<programlisting>#
# Defaults for the connection entries
@@ -2309,7 +2310,7 @@ fi</programlisting>
defaults {
name=defaults
checkip=127.0.0.1
eventscript=/etc/lsm/script
eventscript=/etc/foolsm/script
max_packet_loss=20
max_successive_pkts_lost=7
min_packet_loss=5
@@ -2322,10 +2323,11 @@ defaults {
ttl=0
}
include /etc/lsm/shorewall.conf</programlisting>
include /etc/foolsm/shorewall.conf</programlisting>
<para><filename>/etc/lsm/script</filename> (Shorewall 4.4.23 and later
- note that this script must be executable by root)<programlisting>#!/bin/sh
<para><filename>/etc/foolsm/script</filename> (Shorewall 4.4.23 and
later - note that this script must be executable by
root)<programlisting>#!/bin/sh
#
# (C) 2009 Mika Ilmaranta &lt;ilmis@nullnet.fi&gt;
# (C) 2009 Tom Eastep &lt;teastep@shorewall.net&gt;
@@ -2382,7 +2384,7 @@ cons_wait = ${CONS_WAIT} consecutive packets waiting for reply
cons_miss = ${CONS_MISS} consecutive packets that have timed out
avg_rtt = ${AVG_RTT} average rtt, notice that waiting and timed out packets have rtt = 0 when calculating this
Your LSM Daemon
Your FOOLSM Daemon
EOM
@@ -2394,7 +2396,7 @@ else
${VARDIR}/firewall disable ${DEVICE}
fi
$TOOL show routing &gt;&gt; /var/log/lsm
$TOOL show routing &gt;&gt; /var/log/foolsm
exit 0
@@ -2457,7 +2459,7 @@ cons_wait = ${CONS_WAIT} consecutive packets waiting for reply
cons_miss = ${CONS_MISS} consecutive packets that have timed out
avg_rtt = ${AVG_RTT} average rtt, notice that waiting and timed out packets have rtt = 0 when calculating this
Your LSM Daemon
Your FOOLSM Daemon
EOM
@@ -2466,9 +2468,9 @@ EOM
# [ ${STATE} = up ] &amp;&amp; state=0 || state=1
# echo $state &gt; ${VARDIR}/${DEVICE}.status
<emphasis role="bold">$TOOL restart -f &gt;&gt; /var/log/lsm 2&gt;&amp;1</emphasis>
<emphasis role="bold">$TOOL restart -f &gt;&gt; /var/log/foolsm 2&gt;&amp;1</emphasis>
$TOOL show routing &gt;&gt; /var/log/lsm
$TOOL show routing &gt;&gt; /var/log/foolsm
exit 0

View File

@@ -301,8 +301,8 @@
<para>COMMENT, FORMAT and SECTION Lines now require the leading question
mark ("?"). In earlier releases, the question mark was optional. The
<command>shorewall[6] update -D</command> command will insert the
question marks for you.</para>
<command>shorewall[6] update -D</command> command in Shorewall 4.6 will
insert the question marks for you.</para>
</section>
</section>
@@ -359,7 +359,7 @@
<para>It is strongly recommended that you first upgrade your installation
to a 4.6 release that supports the <option>-A</option> option to the
<command>update</command> command; 4.6.13 is preferred.</para>
<command>update</command> command; 4.6.13.2 or later is preferred.</para>
<para>Once you are on that release, execute the <command>shorewall update
-A</command> command (and <command>shorewall6 update -A</command> if you
@@ -374,11 +374,11 @@
likely won't start or work correctly until you do.</para>
<para>The <command>update</command> command in Shorewall 5 has many fewer
options. The <option>-b</option>, <option>-t</option>, <option>-n</option>
and <option>-s </option>options have been removed -- the updates triggered
by those options are now performed unconditionally. The <option>-i
</option>and <option>-A </option>options have been retained - both enable
checking for issues that could result if INLINE_MATCHES were to be set to
Yes.</para>
options. The <option>-b</option>, <option>-t</option>,
<option>-n</option>, <option>-D</option> and <option>-s </option>options
have been removed -- the updates triggered by those options are now
performed unconditionally. The <option>-i </option>and <option>-A
</option>options have been retained - both enable checking for issues that
could result if INLINE_MATCHES were to be set to Yes.</para>
</section>
</article>

View File

@@ -48,7 +48,7 @@
<section id="Intro">
<title>Introduction</title>
<para>Shorewall supports two different types of blackliisting; rule-based,
<para>Shorewall supports two different types of blacklisting; rule-based,
static and dynamic. The BLACKLIST option in /etc/shorewall/shorewall.conf
controls the degree of blacklist filtering.</para>

View File

@@ -18,7 +18,7 @@
<pubdate><?dbtimestamp format="Y/m/d"?></pubdate>
<copyright>
<year>2001-2013</year>
<year>2001-2016</year>
<holder>Thomas M. Eastep</holder>
</copyright>
@@ -35,9 +35,9 @@
</articleinfo>
<caution>
<para><emphasis role="bold">This article applies to Shorewall 4.3 and
<para><emphasis role="bold">This article applies to Shorewall 5.0 and
later. If you are running a version of Shorewall earlier than Shorewall
4.3.5 then please see the documentation for that
5.0.0 then please see the documentation for that
release.</emphasis></para>
</caution>
@@ -774,6 +774,17 @@ DNAT net loc:10.0.0.1 tcp 80 ; mark="88"</pro
<programlisting>{ action=&gt;DNAT, source=&gt;net, dest=&gt;loc:10.0.0.1, proto=&gt;tcp, dport=&gt;80, mark=&gt;88 }
; action:"DNAT" source:"net" dest:"loc:10.0.0.1" proto:"tcp" dport:"80" mark:"88"
DNAT { source=net dest=loc:10.0.0.1 proto=tcp dport=80 mark=88 }</programlisting>
<para>Beginning with Shorewall 5.0.11, ip[6]table comments can be attached
to individual rules using the <option>comment</option> keyword.</para>
<para>Example from the rules file:</para>
<programlisting> ACCEPT net $FW { proto=tcp, dport=22, comment="Accept \"SSH\"" }</programlisting>
<para>As shown in that example, when the comment contains whitespace, it
must be enclosed in double quotes and any embedded double quotes must be
escaped using a backslash ("\").</para>
</section>
<section>
@@ -1371,6 +1382,10 @@ SSH(ACCEPT) net:$MYIP $FW
?COMMENT line in the rules file and the generated rule will show <emphasis
role="bold">/* Allow SSH from home */</emphasis> when displayed through
the Shorewall show and dump commands.</para>
<para>Beginning with Shorewall 5.0.11, the <link linkend="Pairs">alternate
input format </link>allows attaching comments to individual rules in the
files listed above.</para>
</section>
<section id="CONFIG_PATH">
@@ -1739,7 +1754,7 @@ SSH(ACCEPT) net:$MYIP $FW
<listitem>
<para><ulink
url="manpages/shorewall-accounting.html">shorewall-blacklist</ulink>
url="manpages/shorewall-blrules.html">shorewall-blrules</ulink>
(5)</para>
</listitem>
@@ -1747,6 +1762,12 @@ SSH(ACCEPT) net:$MYIP $FW
<para><ulink url="Macros.html">Macro</ulink> files</para>
</listitem>
<listitem>
<para><ulink
url="manpages/shorewall-mangle.html">shorewall-mangle</ulink>
(5)</para>
</listitem>
<listitem>
<para><ulink
url="manpages/shorewall-nat.html">shorewall-nat</ulink>(5)</para>
@@ -1756,17 +1777,6 @@ SSH(ACCEPT) net:$MYIP $FW
<para><ulink
url="manpages/shorewall-rules.html">shorewall-rules</ulink> (5)</para>
</listitem>
<listitem>
<para><ulink
url="manpages/shorewall-tcrules.html">shorewall-tcrules</ulink>
(5)</para>
</listitem>
<listitem>
<para><ulink url="manpages/shorewall-tos.html">shorewall-tos</ulink>
(5)</para>
</listitem>
</itemizedlist>
<para>They may also appear in the ORIGDEST column of:</para>
@@ -1830,7 +1840,7 @@ SSH(ACCEPT) net:$MYIP $FW
<listitem>
<para><ulink
url="manpages/shorewall-accounting.html">shorewall-blacklist</ulink>
url="manpages/shorewall-blrules.html">shorewall-blrules</ulink>
(5)</para>
</listitem>
@@ -1838,6 +1848,12 @@ SSH(ACCEPT) net:$MYIP $FW
<para><ulink url="Macros.html">Macro</ulink> files</para>
</listitem>
<listitem>
<para><ulink
url="manpages/shorewall-mangle.html">shorewall-mangle</ulink>
(5)</para>
</listitem>
<listitem>
<para><ulink
url="manpages/shorewall-nat.html">shorewall-nat</ulink>(5) (As a
@@ -1846,18 +1862,13 @@ SSH(ACCEPT) net:$MYIP $FW
<listitem>
<para><ulink
url="manpages/shorewall-rules.html">shorewall-rules</ulink> (5)</para>
url="manpages/shorewall-routes.html">shorewall-routes</ulink>
(5)</para>
</listitem>
<listitem>
<para><ulink
url="manpages/shorewall-tcrules.html">shorewall-tcrules</ulink>
(5)</para>
</listitem>
<listitem>
<para><ulink url="manpages/shorewall-tos.html">shorewall-tos</ulink>
(5)</para>
url="manpages/shorewall-rules.html">shorewall-rules</ulink> (5)</para>
</listitem>
</itemizedlist>
@@ -2227,6 +2238,20 @@ SSH(ACCEPT) net:$MYIP $FW
<programlisting> ERROR: Invalid value for Bricks (2000) /usr/share/shorewall/action.GlusterFS (line 15)
from /etc/shorewall/rules (line 45)</programlisting>
<para>In Shorewall 5.0.8, ?WARNING and ?INFO directives were added.</para>
<programlisting>?WARNING <replaceable>message</replaceable>
?INFO <replaceable>message</replaceable></programlisting>
<para>?WARNING message produces a standard Shorewall WARNING: message,
while ?INFO produces a similar message which is prefaced by INFO: rather
than WARNING:. Both write the message to STDERR. The message is also
written to the STARTUP_LOG, if any, provided that the command is
<command>start</command>, <command>try</command>,
<command>restart</command>, <command>reload</command>,
<command>refresh</command>, or one of the <command>safe</command>-*
commands.</para>
</section>
<section id="Embedded">
@@ -2594,6 +2619,13 @@ DNAT net loc:192.168.1.3 tcp <emphasis role="bold">4000:4100<
<para>Also, unless otherwise documented, a port range can be preceded by
'!' to specify "All ports except those in this range" (e.g.,
"!4000:4100").</para>
<para>Beginning with Shorewall 5.0.14, a hyphen ("-") may also be used to
separate the two port numbers; when using service names, the colon must
still be used.</para>
<programlisting>#ACTION SOURCE DESTINATION PROTO DPORT
DNAT net loc:192.168.1.3 tcp <emphasis role="bold">4000-4100</emphasis></programlisting>
</section>
<section id="Portlists">
@@ -2775,6 +2807,182 @@ redirect =&gt; 137</programlisting>
above.</para>
</section>
<section id="TIME">
<title>TIME Columns</title>
<para>Several of the files include a TIME colum that allows you to specify
times when the rule is to be applied. Contents of this column is a list of
<replaceable>timeelement</replaceable>s separated by apersands
(&amp;).</para>
<para>Each <replaceable>timeelement</replaceable> is one of the
following:</para>
<variablelist>
<varlistentry>
<term>timestart=<replaceable>hh</replaceable>:<replaceable>mm</replaceable>[:<replaceable>ss</replaceable>]</term>
<listitem>
<para>Defines the starting time of day.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>timestop=<replaceable>hh</replaceable>:<replaceable>mm</replaceable>[:<replaceable>ss</replaceable>]</term>
<listitem>
<para>Defines the ending time of day.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>contiguous</term>
<listitem>
<para>Added in Shoreawll 5.0.12. When <emphasis
role="bold">timestop</emphasis> is smaller than <emphasis
role="bold">timestart</emphasis> value, match this as a single time
period instead of distinct intervals. See the Examples below.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>utc</term>
<listitem>
<para>Times are expressed in Greenwich Mean Time.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>localtz</term>
<listitem>
<para>Deprecated by the Netfilter team in favor of <emphasis
role="bold">kerneltz</emphasis>. Times are expressed in Local Civil
Time (default).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>kerneltz</term>
<listitem>
<para>Added in Shorewall 4.5.2. Times are expressed in Local Kernel
Time (requires iptables 1.4.12 or later).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>weekdays=ddd[,ddd]...</term>
<listitem>
<para>where <replaceable>ddd</replaceable> is one of
<option>Mon</option>, <option>Tue</option>, <option>Wed</option>,
<option>Thu</option>, <option>Fri</option>, <option>Sat</option> or
<option>Sun</option></para>
</listitem>
</varlistentry>
<varlistentry>
<term>monthdays=dd[,dd],...</term>
<listitem>
<para>where <replaceable>dd</replaceable> is an ordinal day of the
month</para>
</listitem>
</varlistentry>
<varlistentry>
<term>datestart=<replaceable>yyyy</replaceable>[-<replaceable>mm</replaceable>[-<replaceable>dd</replaceable>[<option>T</option><replaceable>hh</replaceable>[:<replaceable>mm</replaceable>[:<replaceable>ss</replaceable>]]]]]</term>
<listitem>
<para>Defines the starting date and time.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>datestop=<replaceable>yyyy</replaceable>[-<replaceable>mm</replaceable>[-<replaceable>dd</replaceable>[<option>T</option><replaceable>hh</replaceable>[:<replaceable>mm</replaceable>[:<replaceable>ss</replaceable>]]]]]</term>
<listitem>
<para>Defines the ending date and time.</para>
</listitem>
</varlistentry>
</variablelist>
<para>Examples:</para>
<variablelist>
<varlistentry>
<term>To match on weekends, use:</term>
<listitem>
<para/>
<para>weekdays=Sat,Sun</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Or, to match (once) on a national holiday block:</term>
<listitem>
<para/>
<para>datestart=2016-12-24&amp;datestop=2016-12-27</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Since the stop time is actually inclusive, you would need the
following stop time to not match the first second of the new
day:</term>
<listitem>
<para/>
<para>datestart=2016-12-24T17:00&amp;datestop=2016-12-27T23:59:59</para>
</listitem>
</varlistentry>
<varlistentry>
<term>During Lunch Hour</term>
<listitem>
<para/>
</listitem>
</varlistentry>
<varlistentry>
<term>The fourth Friday in the month:</term>
<listitem>
<para/>
<para>weekdays=Fri&amp;monthdays=22,23,24,25,26,27,28</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Matching across days might not do what is expected. For
instance,</term>
<listitem>
<para/>
<para>weekdays=Mon&amp;timestart=23:00&amp;timestop=01:00</para>
<para>Will match Monday, for one hour from midnight to 1 a.m., and
then again for another hour from 23:00 onwards. If this is unwanted,
e.g. if you would like 'match for two hours from Montay 23:00
onwards' you need to also specify the <emphasis
role="bold">contiguous</emphasis> option in the example
above.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section id="Switches">
<title>Switches</title>
@@ -2917,8 +3125,8 @@ Comcast 2 0x20000 main <emphasis role="bold">COM_IF</emphasis>
role="bold">optional</emphasis> option in the OPTIONS column.</para>
<para>When an interface is marked as optional, Shorewall will determine
the interface state at <command>start</command> and
<command>restart</command> and adjust its configuration
the interface state at <command>start</command>, <command>reload</command>
and <command>restart</command> and adjust its configuration
accordingly.</para>
<itemizedlist>
@@ -2971,13 +3179,13 @@ Comcast 2 0x20000 main <emphasis role="bold">COM_IF</emphasis>
<para>Shorewall allows you to have configuration directories other than
<filename class="directory">/etc/shorewall</filename>. The shorewall
<command>check</command>, <command>start</command> and
<command>restart</command> commands allow you to specify an alternate
configuration directory and Shorewall will use the files in the alternate
directory rather than the corresponding files in /etc/shorewall. The
alternate directory need not contain a complete configuration; those files
not in the alternate directory will be read from <filename
class="directory">/etc/shorewall</filename>.<important>
<command>check</command>, <command>start</command>,
<command>reload</command> and <command>restart</command> commands allow
you to specify an alternate configuration directory and Shorewall will use
the files in the alternate directory rather than the corresponding files
in /etc/shorewall. The alternate directory need not contain a complete
configuration; those files not in the alternate directory will be read
from <filename class="directory">/etc/shorewall</filename>.<important>
<para>Shorewall requires that the file
<filename>/etc/shorewall/shorewall.conf</filename> to always exist.
Certain global settings are always obtained from that file. If you

View File

@@ -109,8 +109,8 @@
<listitem>
<para>In the event that the subnet address might change while
Shorewall is started, you need to arrange for a <quote>shorewall
refresh</quote> command to be executed when a new dynamic IP address
Shorewall is started, you need to arrange for a <command>shorewall
reload</command> command to be executed when a new dynamic IP address
gets assigned to the interface. Check your DHCP client's
documentation.</para>
</listitem>

View File

@@ -239,9 +239,9 @@
</listitem>
</orderedlist>
<para>If your kernel has ULOG target support (and most vendor-supplied
kernels do), you may also specify a log level of ULOG (must be all
caps). When ULOG is used, Shorewall will direct Netfilter to log the
<para>If your kernel has NFLOG target support (and most vendor-supplied
kernels do), you may also specify a log level of NFLOG (must be all
caps). When NFLOG is used, Shorewall will direct Netfilter to log the
related messages via the ULOG target which will send them to a process
called <quote>ulogd</quote>. The ulogd program is included in most
distributions and is also available from <ulink
@@ -250,7 +250,7 @@
file.</para>
<note>
<para>The ULOG logging mechanism is <emphasis
<para>The NFLOG logging mechanism is <emphasis
role="underline">completely separate</emphasis> from syslog. Once you
switch to ULOG, the settings in <filename>/etc/syslog.conf</filename>
have absolutely no effect on your Shorewall logging (except for
@@ -259,11 +259,11 @@
<para>You will need to change all instances of log levels (usually
<quote>info</quote>) in your Shorewall configuration files to
<quote>ULOG</quote> - this includes entries in the policy, rules and
<quote>NFLOG</quote> - this includes entries in the policy, rules and
shorewall.conf files. Here's what I had at one time:</para>
<programlisting>gateway:/etc/shorewall# grep -v ^\# * | egrep '\$LOG|ULOG|LOGFILE'
params:LOG=ULOG
params:LOG=NFOG
policy:loc $FW REJECT $LOG
policy:net all DROP $LOG 10/sec:40
policy:all all REJECT $LOG
@@ -287,13 +287,12 @@ gateway:/etc/shorewall# </programl
<quote><command>logwatch</command></quote> and
<quote><command>dump</command></quote> commands.</para>
<para>The NFLOG target, a successor to ULOG, is supported shorewall.
Both ULOG and NFLOG may be followed by a list of up to three numbers in
parentheses.</para>
<para>The NFLOG target is a successor to ULOG. Both ULOG and NFLOG may
be followed by a list of up to three numbers in parentheses.</para>
<itemizedlist>
<listitem>
<para>The first number specifies the netlink group (0-32). If
<para>The first number specifies the netlink group (0-65535). If
omitted (e.g., NFLOG(,0,10)) then a value of 0 is assumed.</para>
</listitem>
@@ -342,6 +341,11 @@ stack=log:NFLOG,base1:BASE,ifi1:IFINDEX,ip2str1:IP2STR,print1:PRINTPKT,firewall:
[firewall]
file="/var/log/firewall"
sync=1</programlisting>
<note>
<para>This sample config file assumes that NFLOG is being used in
logging rules and policies.</para>
</note>
</section>
</section>
@@ -470,7 +474,7 @@ sync=1</programlisting>
<para><ulink
url="manpages/shorewall.conf.html">shorewall.conf(5)</ulink> and <ulink
url="manpages6/shorewall6.conf.html">shorewall6.conf(5)</ulink> have a
number of options whose values are log levels. Beginnint with Shorewall
number of options whose values are log levels. Beginning with Shorewall
5.0.0, these specifcations may include a log tag as described <link
linkend="LogTags">above</link>.</para>
</section>

View File

@@ -297,8 +297,8 @@ State:Stopped (Thu Mar 30 14:08:11 PDT 2006)</programlisting>
</listitem>
<listitem>
<para>Post the <filename>/tmp/status.txt</filename> file as an
attachment compressed with gzip or bzip2.</para>
<para>Post the <filename>/tmp/shorewall_dump.txt</filename> file
as an attachment compressed with gzip or bzip2.</para>
</listitem>
<listitem>