Compare commits

..

162 Commits

Author SHA1 Message Date
Tom Eastep
857539c8b1 Update lib.runtime copyright
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-16 13:09:42 -08:00
Tom Eastep
429070d107 Update Chains.pm and Compiler.pm copyrights
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-16 12:28:27 -08:00
Tom Eastep
89725c530f Change limit of 'wait' option setting to 300 seconds (5 minutes)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-16 11:50:33 -08:00
Tom Eastep
8e5f67797a Allow INLINE() in the accounting file to accept '+' in inline matches
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-14 14:52:18 -08:00
Tom Eastep
0eb0bace9a Update more copyrights
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-09 11:57:41 -08:00
Tom Eastep
fab8cc055b Remove unused local variable
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-08 14:25:09 -08:00
Tom Eastep
bef8ec09b3 Insist that '+' (if present) be the first non-blank character in IL matches
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-08 13:55:02 -08:00
Tom Eastep
cf330afbd9 Allow inline matches in the conntrack file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-08 13:09:00 -08:00
Tom Eastep
49731da807 Update copyright dates
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-04 10:14:27 -08:00
Tom Eastep
f3ecbc185c Add Netmanager gateway detection
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-03 11:22:15 -08:00
Tom Eastep
a71a44346e Document the provider table contents
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-02 15:27:38 -08:00
Tom Eastep
4d278f4c20 Clarify [no]hostroute in shorewall-providers(5).
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-02 15:08:38 -08:00
Tom Eastep
45ec24ea42 Add comments to the Zones module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-30 14:10:28 -08:00
Tom Eastep
bf3880ae59 Add some comments to the Misc module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-30 12:41:55 -08:00
Tom Eastep
9e838e6d04 Add Tuomo Soini's WUDO macro
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-19 14:57:38 -08:00
Tom Eastep
d096db6a94 Add/modify comments in Chains.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-19 09:19:26 -08:00
Tom Eastep
636d82414f Merge branch '5.2.1' 2018-12-16 10:34:34 -08:00
Tom Eastep
cb3273b13b Revert "Allow leading 's' & 'd' to be omitted when specifying two rates"
This reverts commit 23bc6f1ab5.
2018-12-16 10:06:34 -08:00
Tom Eastep
f0c75b5119 Update RATE documentation in shorewall-rules(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-16 10:06:00 -08:00
Tom Eastep
23bc6f1ab5 Allow leading 's' & 'd' to be omitted when specifying two rates
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-16 09:47:45 -08:00
Roberto C. Sánchez
54e6412c49 Fix documentation typos 2018-12-15 15:34:45 -08:00
Tom Eastep
1465035aa4 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2018-12-15 14:57:21 -08:00
Tom Eastep
8473bf2200 Clean up macros contributed by Vincas Dargis
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-15 10:31:57 -08:00
Tom Eastep
0fe45b8f46 Merge branch 'tor' of ssh://teastep@git.code.sf.net/u/talkless/shorewall 2018-12-15 10:25:22 -08:00
Tom Eastep
a4c87149c9 Merge branch 'oncrpc_macro' of ssh://teastep@git.code.sf.net/u/talkless/shorewall 2018-12-15 10:24:56 -08:00
Tom Eastep
83359b098d Merge branch 'bitcoin' of ssh://teastep@git.code.sf.net/u/talkless/shorewall 2018-12-15 10:21:14 -08:00
Tom Eastep
3239fb3eb9 Merge branch '5.2.1' 2018-12-15 09:56:14 -08:00
Roberto C. Sánchez
096f59b5bc Fix documentation typos 2018-12-15 11:02:07 -05:00
Vincas Dargis
9260be402b Add Tor macros
Add macros for various Tor Anonimity Network ports
2018-12-15 13:08:06 +02:00
Vincas Dargis
7bf7000941 Add Bitcoin macros
Add macros for various Bitcoin daemon ports.
2018-12-15 12:35:52 +02:00
Vincas Dargis
840f8b904d Add ONC RPC macro
Add macro for handling ONC RPC calls, for rpcinbd on Linux.
2018-12-15 12:10:03 +02:00
Tom Eastep
61ac08dc7f Correct handling of netmask when two rates are specified in the RATE col.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 14:16:26 -08:00
Tom Eastep
f65b10c375 Remove dead/silly code from Shorewall::Chains::use_input/output_chain()
- combine the two into a single function use_interface_chain().

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 13:54:36 -08:00
Tom Eastep
35c7f304f7 Correct log name for untracked chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 11:00:27 -08:00
Tom Eastep
467544801e Clean up of Chains.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 10:59:31 -08:00
Tom Eastep
7cfe9ec272 Correct log name for untracked chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 10:58:26 -08:00
Tom Eastep
6908a4bcf7 Issue warning when ULOG is used.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 09:00:42 -08:00
Tom Eastep
be2110b47e Revert "Remove ULOG support"
This reverts commit 061ce3d781.
2018-12-14 08:54:07 -08:00
Tom Eastep
ad6401da8c Cleanup of Config.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-13 15:32:39 -08:00
Tom Eastep
2b6d657fb0 Add UDP tip to DNAT solutions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-13 10:33:11 -08:00
Tom Eastep
668cb6deda Make 'status -i' work when there are no providers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-11 13:44:31 -08:00
Tom Eastep
ddd8576ced Merge branch '5.2.1' 2018-12-09 11:07:44 -08:00
Tom Eastep
98aad094fb Correct typo in Anti-Spoofing.xml
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-09 11:07:10 -08:00
Tom Eastep
8ed644a0ec Correct HELPER requires error message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-11-28 11:00:41 -08:00
Tom Eastep
86b82c53cf Correct HELPER requires error message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-11-28 10:59:53 -08:00
Tom Eastep
061ce3d781 Remove ULOG support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-11-15 14:59:29 -08:00
Tom Eastep
45f8d31021 Don't try to load ipt_ULOG
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-11-15 14:33:25 -08:00
Tom Eastep
03d2088cf7 Implement SW_CONFDIR support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-11-06 15:40:26 -08:00
Tom Eastep
6534201284 Fix assertion failure during 'check -r' when DOCKER=Yes
- avoid unnecessary mode transitions

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-10-31 15:30:03 -07:00
Tom Eastep
282ca14182 Corrections to DOCKER-ISOLATION change
- Handle DOCKER-USER

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-10-28 09:20:47 -07:00
Tom Eastep
4b7d346911 Merge branch '5.2.1' 2018-10-27 09:11:00 -07:00
Tom Eastep
131a2cd40d Accommodate Docker version 18.06
- Optionally replace DOCKER-ISOLATION with DOCKER-ISOLATION-STAGE-1 and -2

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-10-27 09:04:34 -07:00
Tom Eastep
ae90ab1f68 Add version of Jeremie Courreges-Anglas's <jca@tranquil.it> patch
- Handle case where we are enabling/disabling a balanced/fallback provider
  and another such provider has lost carrier.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-10-11 15:18:47 -07:00
Tom Eastep
5e57c895b3 Avoid emacs issues with compiled code
- handle embedded spaces in moduledir path names

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-10-09 14:47:36 -07:00
Tom Eastep
aab1df7421 Correct ip[6]tables-restore failure message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-10-06 08:22:46 -07:00
Tom Eastep
9f3cc88cf0 Prevent invalid code generation with SNAT(detect)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-10-02 08:15:20 -07:00
Tom Eastep
aaa80882a0 Add Eric Teeter's Cockpit macro
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-09-28 09:43:55 -07:00
Tom Eastep
1b6de901e0 Merge branch '5.2.0' 2018-08-24 15:33:16 -07:00
Tom Eastep
56780a5d1f Apply rate limiting in the nat table on nat+accept rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-24 15:31:20 -07:00
Tom Eastep
22c1bc2e9c Apply rate limiting in the nat table on nat+accept rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-23 14:07:10 -07:00
Tom Eastep
5048e68cb5 Correct IPv4 examples in shorewall-blrules(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-13 19:21:03 -07:00
Tom Eastep
1897794dbf Change reference to 'masq' to 'snat'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-12 11:37:12 -07:00
Tom Eastep
4fca96f10e Fix typo in IPSEC-2.6.xml
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-09 08:14:01 -07:00
Tom Eastep
2d2ded7efc Merge branch '5.2.0' 2018-08-07 07:46:29 -07:00
Tom Eastep
e5e427f278 Merge branch '5.2.0' of ssh://git.code.sf.net/p/shorewall/code into 5.2.0 2018-08-07 07:44:38 -07:00
Tom Eastep
5e8fd570d1 Prepare for Perl 5.32
- Escape '{' in REs

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-07 07:43:58 -07:00
Tom Eastep
e8428cc298 Prepare for Perl 5.32
- Escape '{' in REs

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-07 07:42:34 -07:00
Tom Eastep
aa94772fc6 Merge branch '5.2.0' 2018-08-06 08:08:39 -07:00
Matt Darfeuille
732ae3ce19 Ipcalc: Fail when missing arguments
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-05 10:26:17 -07:00
Tom Eastep
9cbcb328af More mutex changes for LEDE
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-01 13:58:50 -07:00
Tom Eastep
82e84f724d Use -h rather than -L for checking a symlink
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-01 13:58:35 -07:00
Tom Eastep
23cf8328d5 Fix mutex on OpenWRT - patch 1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-01 13:58:28 -07:00
Tom Eastep
7c31f70dc8 Use '=' rather than '&' to create UNTRACKED rule chains.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-01 13:50:20 -07:00
Tom Eastep
f1eafdc314 Use '=' rather than '&' to create UNTRACKED rule chains.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-08-01 13:48:29 -07:00
Tom Eastep
69745caa41 Revert previous emacs-related change.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-31 15:16:24 -07:00
Tom Eastep
0b49477e0d More mutex changes for LEDE
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-31 15:03:58 -07:00
Tom Eastep
c195bab01d Correct handling of a provider interface that matches a wildcard.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-29 20:34:02 -07:00
Tom Eastep
1b550baf7e Eliminate broken links
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-28 07:58:32 -07:00
Tom Eastep
d829093caa Use -h rather than -L for checking a symlink
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-26 13:57:10 -07:00
Tom Eastep
1fa77ac470 Fix mutex on OpenWRT - patch 1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-26 11:47:51 -07:00
Tom Eastep
5083246266 Avoid emacs issues with lib.common
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-26 11:28:06 -07:00
Tom Eastep
c0d6c9e7c0 Document issue with optional shared interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-19 10:08:17 -07:00
Tom Eastep
0d682fe78b Disallow optional shared providers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-19 09:57:06 -07:00
Tom Eastep
410a20dda3 Make shared interface and 'load=<load-factor' play nice together
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-17 13:25:26 -07:00
Tom Eastep
0685d0edfd Fix rate limiting
- Avoid specifying a timeout when the match is '-m limit'

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-15 08:57:43 -07:00
Tom Eastep
474604b1fe Correct source interface exclusion
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-04 08:01:27 -07:00
Tom Eastep
6fef1f34ba Correct links in manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-03 15:31:14 -07:00
Tom Eastep
93f0183550 Tweak do_ratelimit()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-03 14:22:30 -07:00
Tom Eastep
5a599552f2 Correct INLINE typos
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-02 16:56:57 -07:00
Tom Eastep
a42972644c Allow specification of 'hashlimit' table sizes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-02 14:14:36 -07:00
Tom Eastep
b271c52603 Update RATE column documentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-02 14:10:53 -07:00
Tom Eastep
49514e2d58 Allow specification of ht buckets and max entries in RATE columns
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-02 10:23:36 -07:00
Tom Eastep
a265685e20 Allow specification of VLSM in the RATE columns
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-07-02 09:08:45 -07:00
Matt Darfeuille
442e6ac152 Update version to 5.2
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-06-23 09:09:00 -07:00
Matt Darfeuille
14e5a2d5ca Be more verbose in progress messages
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-06-23 09:02:18 -07:00
Matt Darfeuille
6e32f052c8 Use proper function name on fatal error
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-06-23 09:01:49 -07:00
Tom Eastep
780eb0402c Update manpages for interface exclusion
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-06-15 08:23:35 -07:00
Tom Eastep
bfb9852eb6 Allow MARK, CONNMARK, SAVE and RESTORE in the nat table
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-06-14 10:01:12 -07:00
Tom Eastep
a8b6a301f2 Revert "MARK and CONNMARK in the snat file"
This reverts commit e36547f8be.
2018-06-14 07:58:33 -07:00
Tom Eastep
150f7ab798 Allow specification of the TPROXY mark in CONNMARK and MARK.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-06-14 07:58:06 -07:00
Tom Eastep
b11d63a7bd More manpage corrections
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-06-11 08:54:34 -07:00
Tom Eastep
84b283533b Correct dangling link
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-06-11 08:52:07 -07:00
Tom Eastep
e36547f8be MARK and CONNMARK in the snat file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-06-10 16:34:55 -07:00
Tom Eastep
0632723a6c Support interface exclusion
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-06-10 12:02:19 -07:00
Tom Eastep
43543b5c32 Clean up shorewall-addresses(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-06-10 12:00:54 -07:00
Tom Eastep
ffc5a3c7df Add ALT Linux support by Alexey Shabalin <sha-ba@mail.ru>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-29 08:13:26 -07:00
Tom Eastep
b6d1293b2e Merge branch '5.2.0' 2018-05-20 14:48:40 -07:00
Tom Eastep
ec21b03c5b Correct handling of dbl=src_dst in interface OPTIONS
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-18 10:18:09 -07:00
Tom Eastep
25dcf8c5d6 Check for linkdown in interface_is_usable() rather than ..._is_up().
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-18 07:56:06 -07:00
Tom Eastep
c02b71b530 Correct interface_is_up() to look for the 'state' as well as 'UP'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-12 08:09:46 -07:00
Tom Eastep
78269d57bc Handle missing AUTOMAKE
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-10 11:12:23 -07:00
Tom Eastep
fc91648315 Avoid split_line2 confusion when processing a raw line
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-10 09:30:02 -07:00
Tom Eastep
067f435ac5 Update BLACKLIST_DEFAULT if Drop or Reject
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-06 13:31:54 -07:00
Tom Eastep
2039f38faf Fix 'show saves' when there are no saves
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-05 13:27:37 -07:00
Tom Eastep
07654d8f8d Fix 'compile -c'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-05 13:26:58 -07:00
Tom Eastep
b5e8f9bd50 Restore the read_yesno_with_timeout() function
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-04 08:52:40 -07:00
Tom Eastep
f9995a9515 New manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-04 08:47:33 -07:00
Tom Eastep
9c950082f6 Add new IPFS macros
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-05-04 08:45:39 -07:00
Tom Eastep
defdd320cf Merge branch '5.2.0' 2018-04-27 14:09:07 -07:00
Matt Darfeuille
fc44eb7516 Update version to 5.2 in RC files
- Mention LEDE distro in OpenWRT RC file

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-27 14:08:36 -07:00
Matt Darfeuille
bb89d509ea Ipdecimal: Correct error when missing arguments
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-27 14:08:00 -07:00
Matt Darfeuille
c2fe389da8 Update version to 5.2 in RC files
- Mention LEDE distro in OpenWRT RC file

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-27 11:42:04 -07:00
Matt Darfeuille
45d1ef3978 Ipdecimal: Correct error when missing arguments
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-27 11:41:44 -07:00
Tom Eastep
65e174a073 Add IPFS macros from Răzvan Sandu <razvan.sandu@mobexpert.ro>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-21 09:05:48 -07:00
Tom Eastep
6822803802 Correct Netfilter Diagram
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-18 15:53:01 -07:00
Tom Eastep
66edd76b10 Correct typo in patch merged from 5.1.12
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-15 08:46:05 -07:00
Matt Darfeuille
99be0ce970 Use a function to load configuration files
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-14 13:06:54 -07:00
Tom Eastep
98d5bf8f55 Correct 'reset' handling in 'IfEvent'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-13 09:22:29 -07:00
Tom Eastep
370901e873 Add link to Events.html from PortKnocking.html
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-13 08:50:19 -07:00
Tom Eastep
c59ff50de4 Process params file in remote_capture()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-13 08:49:35 -07:00
Matt Darfeuille
3df5c032da Be more verbose when executing remote commands
- Reword progress messages

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-12 11:12:39 -07:00
Tom Eastep
b997bfcd97 Update copyright of Shorewall 5 Document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-10 10:44:38 -07:00
Tom Eastep
7630d3cdb1 Update Shorewall 5 Article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-04-10 10:00:52 -07:00
Tom Eastep
90df607d79 Finish removal of 'refresh command'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-30 15:30:34 -07:00
Matt Darfeuille
f012244acd Add 5.2 as a supported Shorewall version
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-28 13:03:49 -07:00
Tom Eastep
5e2f1f573d Unconditionally convert masq->snat
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-27 11:38:47 -07:00
Tom Eastep
011322992e Revert "Delete masq file processing"
This reverts commit 609ee8dea2.
2018-03-27 11:08:33 -07:00
Tom Eastep
16bb41db15 Document 'getcaps', 'getrc' and 'show rc'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-27 09:54:32 -07:00
Tom Eastep
47a96e9ff9 Delete masq file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-26 15:57:49 -07:00
Tom Eastep
4a1d8ba0f9 delete shorewall-masq.xml
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-26 15:56:11 -07:00
Tom Eastep
7c99059a66 Supersede the masq file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-26 15:53:07 -07:00
Tom Eastep
609ee8dea2 Delete masq file processing
- Automatically convert the masq file if it exists

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-26 11:40:22 -07:00
Matt Darfeuille
299ea2b41f Update version to 5.2
- Remove unneeded punctuation marks

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-24 09:53:02 -07:00
Tom Eastep
224400833a Correct port knocking action in the Events article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-24 09:47:56 -07:00
Tom Eastep
32f1ae1992 Make &lo work correctly
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-19 18:23:19 -07:00
Matt Darfeuille
9b5468cd4a Add and document the show rc command
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-18 17:36:44 -07:00
Matt Darfeuille
47a59cdd7c Add and document the remote-getcaps command
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-18 17:36:38 -07:00
Matt Darfeuille
676ca872d6 Add and document the remote-getrc command
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-18 17:36:33 -07:00
Matt Darfeuille
ef28208c0e Use a more consistent name for function definition
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-18 17:36:20 -07:00
Matt Darfeuille
cdeb82bdab Improve when to capture capabilities
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-18 17:35:42 -07:00
Tom Eastep
3be071ca3d Up the INCLUDE depth limit to 20
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-12 14:39:53 -07:00
Tom Eastep
6f6abfc8cd Clarify the processing of the params file in shorewall-params(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-08 08:51:36 -08:00
Tom Eastep
f99f3539d1 Recommend using the link-level IP of upstream IPv6 routers.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-05 16:42:15 -08:00
Tom Eastep
e08e239c00 Implement AUTOMAKE=recursive
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-03 15:50:56 -08:00
Tom Eastep
02ed6f26a9 Allow AUTOMAKE=<depth> to specify search depth
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-03-03 13:04:48 -08:00
Tom Eastep
9e002a7689 Be sure that mutex is released when exiting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-02-28 13:38:30 -08:00
Tom Eastep
34c5441768 Apply optimize category 16 again after 8 if 8 did anything
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-02-27 14:17:21 -08:00
Tom Eastep
c3d8cba042 Reverse the order of optimize 8 and optimize 16 application
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-02-23 15:01:47 -08:00
Tom Eastep
8bc97bcd35 Replace ${VARDIR}/firewall with $g_firewall in CLI
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-02-23 12:40:14 -08:00
Tom Eastep
c1a74b54fc Implement RENAME_COMBINED
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-02-22 12:49:55 -08:00
Tom Eastep
88547f5140 Handle two-chain case when LOG_ZONE != 'Both'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-02-22 11:25:19 -08:00
Tom Eastep
4a714b3ab9 More INLINE_MATCHES changes
Signed-off-by: Tom Eastep <teastep@shorewall.net>

# Conflicts:
#	Shorewall/manpages/shorewall-mangle.xml
#	Shorewall/manpages/shorewall-rules.xml
2018-02-21 15:15:23 -08:00
128 changed files with 4089 additions and 1469 deletions

View File

@@ -1,6 +1,6 @@
#!/bin/bash
#
# Shorewall Packet Filtering Firewall RPM configuration program - V4.6
# Shorewall Packet Filtering Firewall configuration program - V5.2
#
# (c) 2012,2014,2017 - Tom Eastep (teastep@shorewall.net)
#
@@ -109,6 +109,9 @@ if [ -z "$vendor" ]; then
opensuse)
vendor=suse
;;
alt|basealt|altlinux)
vendor=alt
;;
*)
vendor="$ID"
;;
@@ -132,6 +135,8 @@ if [ -z "$vendor" ]; then
if [ -f /etc/debian_version ]; then
params[HOST]=debian
ls -l /sbin/init | fgrep -q systemd && rcfile=shorewallrc.debian.systemd || rcfile=shorewallrc.debian.sysvinit
elif [ -f /etc/altlinux-release ] ; then
params[HOST]=alt
elif [ -f /etc/redhat-release ]; then
params[HOST]=redhat
rcfile=shorewallrc.redhat

View File

@@ -1,6 +1,6 @@
#! /usr/bin/perl -w
#
# Shorewall Packet Filtering Firewall RPM configuration program - V4.5
# Shorewall Packet Filtering Firewall configuration program - V5.2
#
# (c) 2012, 2014 - Tom Eastep (teastep@shorewall.net)
#
@@ -74,6 +74,8 @@ unless ( defined $vendor ) {
} elsif ( $id eq 'ubuntu' || $id eq 'debian' ) {
my $init = `ls -l /sbin/init`;
$vendor = $init =~ /systemd/ ? 'debian.systemd' : 'debian.sysvinit';
} elsif ( $id eq 'alt' || $id eq 'basealt' || $id eq 'altlinux' ) {
$vendor = 'alt';
} else {
$vendor = $id;
}
@@ -117,6 +119,9 @@ if ( defined $vendor ) {
} else {
$rcfilename = 'shorewallrc.debian.sysvinit';
}
} elsif ( -f '/etc/altlinux-release' ){
$vendor = 'alt';
$rcfilename = 'shorewallrc.alt';
} elsif ( -f '/etc/redhat-release' ){
$vendor = 'redhat';
$rcfilename = 'shorewallrc.redhat';

View File

@@ -172,6 +172,9 @@ if [ -z "$BUILD" ]; then
opensuse)
BUILD=suse
;;
alt|basealt|altlinux)
BUILD=alt
;;
*)
BUILD="$ID"
;;
@@ -180,6 +183,8 @@ if [ -z "$BUILD" ]; then
BUILD=debian
elif [ -f /etc/gentoo-release ]; then
BUILD=gentoo
elif [ -f /etc/altlinux-release ]; then
BUILD=alt
elif [ -f /etc/redhat-release ]; then
BUILD=redhat
elif [ -f /etc/slackware-version ] ; then
@@ -238,7 +243,7 @@ case "$HOST" in
apple)
echo "Installing Mac-specific configuration...";
;;
debian|gentoo|redhat|slackware|archlinux|linux|suse|openwrt)
debian|gentoo|redhat|slackware|archlinux|linux|suse|openwrt|alt)
;;
*)
fatal_error "Unknown HOST \"$HOST\""

View File

@@ -1,5 +1,5 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/lib.base
# Shorewall 5.2 -- /usr/share/shorewall/lib.base
#
# (c) 1999-2017 - Tom Eastep (teastep@shorewall.net)
#

View File

@@ -1,5 +1,5 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/lib.cli.
# Shorewall 5.2 -- /usr/share/shorewall/lib.cli
#
# (c) 1999-2018 - Tom Eastep (teastep@shorewall.net)
#
@@ -417,9 +417,9 @@ resolve_arptables() {
savesets() {
local supported
supported=$(run_it ${VARDIR}/firewall help | fgrep savesets )
supported=$(run_it $g_firewall help | fgrep savesets )
[ -n "$supported" ] && run_it ${VARDIR}/firewall savesets ${g_restorepath}-ipsets
[ -n "$supported" ] && run_it $g_firewall savesets ${g_restorepath}-ipsets
}
#
@@ -428,9 +428,9 @@ savesets() {
savesets1() {
local supported
supported=$(run_it ${VARDIR}/firewall help | fgrep savesets )
supported=$(run_it $g_firewall help | fgrep savesets )
[ -n "$supported" ] && run_it ${VARDIR}/firewall savesets ${VARDIR}/ipsets.save && progress_message3 "The ipsets have been saved to ${VARDIR}/ipsets.save"
[ -n "$supported" ] && run_it $g_firewall savesets ${VARDIR}/ipsets.save && progress_message3 "The ipsets have been saved to ${VARDIR}/ipsets.save"
}
#
@@ -441,9 +441,9 @@ do_save() {
local arptables
status=0
if [ -f ${VARDIR}/firewall ]; then
if [ -f $g_firewall ]; then
if $iptables_save | grep -v -- '-A dynamic.* -j ACCEPT' > ${VARDIR}/restore-$$; then
cp -f ${VARDIR}/firewall $g_restorepath
cp -f $g_firewall $g_restorepath
mv -f ${VARDIR}/restore-$$ ${g_restorepath}-iptables
chmod 700 $g_restorepath
chmod 600 ${g_restorepath}-iptables
@@ -455,7 +455,7 @@ do_save() {
status=1
fi
else
echo " ERROR: ${VARDIR}/firewall does not exist" >&2
echo " ERROR: $g_firewall does not exist" >&2
status=1
fi
@@ -1201,11 +1201,17 @@ show_saves_command() {
echo
for f in ${VARDIR}/*-iptables; do
fn=$(basename $f)
fn=${fn%-iptables}
mtime=$(ls -lt $f | tail -n 1 | cut -d ' ' -f '6 7 8' )
[ $fn = "$RESTOREFILE" ] && fn="$fn (default)"
echo " $mtime ${fn%-iptables}"
case $f in
*\**)
;;
*)
fn=$(basename $f)
fn=${fn%-iptables}
mtime=$(ls -lt $f | tail -n 1 | cut -d ' ' -f '6 7 8' )
[ $fn = "$RESTOREFILE" ] && fn="$fn (default)"
echo " $mtime ${fn%-iptables}"
;;
esac
done
echo
@@ -1432,6 +1438,17 @@ show_command() {
vardir)
echo $VARDIR;
;;
rc)
shift
[ $# -gt 1 ] && too_many_arguments $2
if [ -n "$1" -a -d "$1" ]; then
cat $1/shorewallrc
elif [ -n "$g_basedir" -a -d "$g_basedir" ]; then
cat $g_basedir/shorewallrc
else
fatal_error "Can not determine the location of the shorewallrc file."
fi
;;
policies)
only_root
[ $# -gt 1 ] && too_many_arguments $2
@@ -2749,7 +2766,7 @@ determine_capabilities() {
g_tool=$(mywhich $tool)
if [ -z "$g_tool" ]; then
fatal-error "No executable $tool binary can be found on your PATH"
fatal_error "No executable $tool binary can be found on your PATH"
fi
fi
@@ -3758,7 +3775,7 @@ ipcalc_command() {
elif [ $# -eq 3 ]; then
address=$2
vlsm=$(ip_vlsm $3)
elif [ $# -eq 0 ]; then
elif [ $# -eq 1 ]; then
missing_argument
else
too_many_arguments $4
@@ -3804,7 +3821,7 @@ iprange_command() {
}
ipdecimal_command() {
if [ $# eq 1 ]; then
if [ $# -eq 1 ]; then
missing_argument
else
[ $# -eq 2 ] || too_many_arguments $3
@@ -3847,7 +3864,7 @@ noiptrace_command() {
verify_firewall_script() {
if [ ! -f $g_firewall ]; then
echo " ERROR: $g_product is not properly installed" >&2
if [ -L $g_firewall ]; then
if [ -h $g_firewall ]; then
echo " $g_firewall is a symbolic link to a" >&2
echo " non-existant file" >&2
else
@@ -3947,7 +3964,7 @@ get_config() {
ensure_config_path
[ -f ${VARDIR}/firewall.conf ] && . ${VARDIR}/firewall.conf
[ -f $g_firewall.conf ] && . ${VARDIR}/firewall.conf
[ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
@@ -4101,15 +4118,15 @@ start_command() {
rc=0
[ -n "$g_nolock" ] || mutex_on
if [ -x ${VARDIR}/firewall ]; then
if [ -n "$g_fast" -a -x ${VARDIR}/${RESTOREFILE} -a ! ${VARDIR}/firewall -nt ${VARDIR}/${RESTOREFILE} ]; then
if [ -x $g_firewall ]; then
if [ -n "$g_fast" -a -x ${VARDIR}/${RESTOREFILE} -a ! $g_firewall -nt ${VARDIR}/${RESTOREFILE} ]; then
run_it ${VARDIR}/${RESTOREFILE} $g_debugging restore
else
run_it ${VARDIR}/firewall $g_debugging start
run_it $g_firewall $g_debugging start
fi
rc=$?
else
error_message "${VARDIR}/firewall is missing or is not executable"
error_message "$g_firewall is missing or is not executable"
mylogger kern.err "ERROR:$g_product start failed"
rc=6
fi
@@ -4238,11 +4255,11 @@ restart_command() {
[ -n "$g_nolock" ] || mutex_on
if [ -x ${VARDIR}/firewall ]; then
run_it ${VARDIR}/firewall $g_debugging $COMMAND
if [ -x $g_firewall ]; then
run_it $g_firewall $g_debugging $COMMAND
rc=$?
else
error_message "${VARDIR}/firewall is missing or is not executable"
error_message "$g_firewall is missing or is not executable"
mylogger kern.err "ERROR:$g_product $COMMAND failed"
rc=6
fi
@@ -4252,10 +4269,10 @@ restart_command() {
}
run_command() {
if [ -x ${VARDIR}/firewall ] ; then
run_it ${VARDIR}/firewall $g_debugging $@
if [ -x $g_firewall ] ; then
run_it $g_firewall $g_debugging $@
else
fatal_error "${VARDIR}/firewall does not exist or is not executable"
fatal_error "$g_firewall does not exist or is not executable"
fi
}
@@ -4322,9 +4339,11 @@ usage() # $1 = exit status
fi
if [ -z "$g_lite" ]; then
echo " remote-reload [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>"
echo " remote-restart [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>"
echo " remote-start [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>"
echo " remote-getrc [ -T ] [ -c ] [ -r <root-name> ] [ [ -D ] <directory> ] [ <system> ]"
echo " remote-getcaps [ -T ] [ -R ] [ -r <root-name> ] [ [ -D ] <directory> ] [ <system> ]"
echo " remote-reload [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] [ <system> ]"
echo " remote-restart [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] [ <system> ]"
echo " remote-start [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] [ <system> ]"
fi
echo " reset [ <chain> ... ]"
@@ -4367,6 +4386,7 @@ usage() # $1 = exit status
echo " [ show | list | ls ] nfacct"
echo " [ show | list | ls ] opens"
echo " [ show | list | ls ] policies"
echo " [ show | list | ls ] rc"
echo " [ show | list | ls ] routing"
echo " [ show | list | ls ] saves"
echo " [ show | list | ls ] tc [ device ]"
@@ -4435,6 +4455,7 @@ shorewall_cli() {
g_nopager=
g_blacklistipset=
g_disconnect=
g_havemutex=
VERBOSE=
VERBOSITY=1
@@ -4640,7 +4661,7 @@ shorewall_cli() {
only_root
get_config Yes
if product_is_started; then
run_it ${VARDIR}/firewall $g_debugging $@
run_it $g_firewall $g_debugging $@
else
fatal_error "$g_product is not running"
fi

View File

@@ -1,7 +1,7 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/lib.common.
# Shorewall 5.2 -- /usr/share/shorewall/lib.common
#
# (c) 2010-2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2010-2018 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -419,7 +419,7 @@ load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
. $modules
if [ $savemoduleinfo = Yes ]; then
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir
echo MODULESDIR=\"$MODULESDIR\" > ${VARDIR}/.modulesdir
cp -f $modules ${VARDIR}/.modules
fi
elif [ $savemoduleinfo = Yes ]; then
@@ -501,7 +501,7 @@ ip_network() {
#
# The following hack is supplied to compensate for the fact that many of
# the popular light-weight Bourne shell derivatives don't support XOR ("^").
# the popular light-weight Bourne shell derivatives do not support XOR ("^").
#
ip_broadcast() {
local x
@@ -751,36 +751,44 @@ mutex_on()
lockf=${LOCKFILE:=${VARDIR}/lock}
local lockpid
local lockd
local lockbin
local openwrt
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
if [ $MUTEX_TIMEOUT -gt 0 ]; then
if [ -z "$g_havemutex" -a $MUTEX_TIMEOUT -gt 0 ]; then
lockd=$(dirname $LOCKFILE)
[ -d "$lockd" ] || mkdir -p "$lockd"
lockbin=$(mywhich lock)
[ -n "$lockbin" -a -h "$lockbin" ] && openwrt=Yes
if [ -f $lockf ]; then
lockpid=`cat ${lockf} 2> /dev/null`
if [ -z "$lockpid" -o $lockpid = 0 ]; then
if [ -z "$lockpid" ] || [ $lockpid = 0 ]; then
rm -f ${lockf}
error_message "WARNING: Stale lockfile ${lockf} removed"
elif [ $lockpid -eq $$ ]; then
return 0
elif ! ps | grep -v grep | qt grep ${lockpid}; then
rm -f ${lockf}
error_message "WARNING: Stale lockfile ${lockf} from pid ${lockpid} removed"
elif [ -z "$openwrt" ]; then
if [ $lockpid -eq $$ ]; then
fatal_error "Mutex_on confusion"
elif ! qt ps --pid ${lockpid}; then
rm -f ${lockf}
error_message "WARNING: Stale lockfile ${lockf} from pid ${lockpid} removed"
fi
fi
fi
if qt mywhich lockfile; then
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
if [ -n "$openwrt" ]; then
lock ${lockf} || fatal_error "Can't lock ${lockf}"
g_havemutex="lock -u ${lockf}"
elif qt mywhich lockfile; then
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf} || fatal_error "Can't lock ${lockf}"
g_havemutex="rm -f ${lockf}"
chmod u+w ${lockf}
echo $$ > ${lockf}
chmod u-w ${lockf}
elif qt mywhich lock; then
lock ${lockf}
chmod u=r ${lockf}
else
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
sleep 1
@@ -790,10 +798,15 @@ mutex_on()
if [ ${try} -lt ${MUTEX_TIMEOUT} ] ; then
# Create the lockfile
echo $$ > ${lockf}
g_havemutex="rm -f ${lockf}"
else
echo "Giving up on lock file ${lockf}" >&2
fi
fi
if [ -n "$g_havemutex" ]; then
trap mutex_off EXIT
fi
fi
}
@@ -802,7 +815,10 @@ mutex_on()
#
mutex_off()
{
[ -f ${CONFDIR}/rc.common ] && lock -u ${LOCKFILE:=${VARDIR}/lock}
rm -f ${LOCKFILE:=${VARDIR}/lock}
if [ -n "$g_havemutex" ]; then
eval $g_havemutex
g_havemutex=
trap '' exit
fi
}

View File

@@ -1,5 +1,5 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/lib.core
# Shorewall 5.2 -- /usr/share/shorewall/lib.core
#
# (c) 1999-2017 - Tom Eastep (teastep@shorewall.net)
#

View File

@@ -1,6 +1,5 @@
#
#
# Shorewall 5.1 -- /usr/share/shorewall/lib.installer.
# Shorewall 5.2 -- /usr/share/shorewall/lib.installer
#
# (c) 2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2017 - Matt Darfeuille (matdarf@gmail.com)

View File

@@ -1,6 +1,5 @@
#
#
# Shorewall 5.1 -- /usr/share/shorewall/lib.installer.
# Shorewall 5.2 -- /usr/share/shorewall/lib.installer
#
# (c) 2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2017 - Matt Darfeuille (matdarf@gmail.com)
@@ -61,7 +60,7 @@ mywhich() {
remove_file() # $1 = file to remove
{
if [ -n "$1" ] ; then
if [ -f $1 -o -L $1 ] ; then
if [ -f $1 -o -h $1 ] ; then
rm -f $1
echo "$1 Removed"
fi
@@ -85,7 +84,7 @@ remove_file_with_wildcard() # $1 = file with wildcard to remove
if [ -d $f ] ; then
rm -rf $f
echo "$f Removed"
elif [ -f $f -o -L $f ] ; then
elif [ -f $f -o -h $f ] ; then
rm -f $f
echo "$f Removed"
fi

View File

@@ -445,6 +445,54 @@
<arg><replaceable>directory</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>shorewall[6]</command>
<arg choice="opt"><option>trace</option>|<option>debug</option></arg>
<arg>options</arg>
<arg choice="plain"><option>remote-getcaps</option></arg>
<arg><option>-s</option></arg>
<arg><option>-R</option></arg>
<arg><option>-r</option> <replaceable>root-user-name</replaceable></arg>
<arg><option>-T</option></arg>
<arg><option>-i</option></arg>
<arg><arg><option>-D</option></arg><replaceable>directory</replaceable></arg>
<arg choice="plain"><arg><replaceable>system</replaceable></arg></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>shorewall[6]</command>
<arg choice="opt"><option>trace</option>|<option>debug</option></arg>
<arg>options</arg>
<arg choice="plain"><option>remote-getrc</option></arg>
<arg><option>-s</option></arg>
<arg><option>-c</option></arg>
<arg><option>-r</option> <replaceable>root-user-name</replaceable></arg>
<arg><option>-T</option></arg>
<arg><option>-i</option></arg>
<arg><arg><option>-D</option></arg><replaceable>directory</replaceable></arg>
<arg choice="plain"><arg><replaceable>system</replaceable></arg></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>shorewall[6]</command>
@@ -1870,6 +1918,57 @@
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">remote-getcaps</emphasis>
[-<option>R</option>] [-<option>r</option>
<replaceable>root-user-name</replaceable>] [ [ -D ]
<replaceable>directory</replaceable> ] [
<replaceable>system</replaceable> ]</term>
<listitem>
<para>Added in Shoreall 5.2.0, this command executes <emphasis
role="bold">shorewall[6]-lite show capabilities -f &gt;
/var/lib/shorewall[6]-lite/capabilities</emphasis> on the remote
<replaceable>system</replaceable> via ssh then the generated file is
copied to <replaceable>directory</replaceable> on the local system.
If no <replaceable>directory</replaceable> is given, the current
working directory is assumed.</para>
<para>if <emphasis role="bold">-R</emphasis> is included, the remote
shorewallrc file is also copied to
<replaceable>directory</replaceable>.</para>
<para>If <option>-r</option> is included, it specifies that the root
user on <replaceable>system</replaceable> is named
<replaceable>root-user-name</replaceable> rather than "root".</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">remote-getrc</emphasis>
[-<option>c</option>] [-<option>r</option>
<replaceable>root-user-name</replaceable>] [ [ -D ]
<replaceable>directory</replaceable> ] [
<replaceable>system</replaceable> ]</term>
<listitem>
<para>Added in Shoreall 5.2.0, this command copies the shorewallrc
file from the remote <replaceable>system</replaceable> to
<replaceable>directory</replaceable> on the local system. If no
<replaceable>directory</replaceable> is given, the current working
directory is assumed.</para>
<para>if <emphasis role="bold">-c</emphasis> is included, the remote
capabilities are also copied to
<replaceable>directory</replaceable>, as is done by the
<command>remote-getcaps</command> command.</para>
<para>If <option>-r</option> is included, it specifies that the root
user on <replaceable>system</replaceable> is named
<replaceable>root-user-name</replaceable> rather than "root".</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">remote-start</emphasis>
[-<option>n</option>] [-<option>s</option>] [-<option>c</option>]
@@ -1921,9 +2020,9 @@
role="bold">shorewall-lite save</emphasis> via ssh.</para>
<para>if <emphasis role="bold">-c</emphasis> is included, the
command <emphasis role="bold">shorewall-lite show capabilities -f
&gt; /var/lib/shorewall-lite/capabilities</emphasis> is executed via
ssh then the generated file is copied to
command <emphasis role="bold">shorewall[6]-lite show capabilities -f
&gt; /var/lib/shorewall[6]-lite/capabilities</emphasis> is executed
via ssh then the generated file is copied to
<replaceable>directory</replaceable> using scp. This step is
performed before the configuration is compiled.</para>
@@ -1934,13 +2033,6 @@
<para>The <option>-T</option> option was added in Shorewall 4.5.3
and causes a Perl stack trace to be included with each
compiler-generated error and warning message.</para>
<para>The <option>-i</option> option was added in Shorewall 4.6.0
and causes a warning message to be issued if the current line
contains alternative input specifications following a semicolon
(";"). Such lines will be handled incorrectly if INLINE_MATCHES is
set to Yes in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5).</para>
</listitem>
</varlistentry>
@@ -2666,6 +2758,15 @@
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">rc</emphasis></term>
<listitem>
<para>Added in Shorewall 5.2.0. Displays the contents of
$SHAREDIR/shorewall/shorewallrc.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>[-<option>c</option>]<emphasis role="bold">
routing</emphasis></term>
@@ -3115,30 +3216,38 @@
<refsect1>
<title>FILES</title>
<para>/etc/shorewall/</para>
<para>/etc/shorewall/*</para>
<para>/etc/shorewall6/</para>
<para>/etc/shorewall6/*</para>
</refsect1>
<refsect1>
<title>See ALSO</title>
<para><ulink
url="/starting_and_stopping_shorewall.htm">http://www.shorewall.net/starting_and_stopping_shorewall.htm</ulink></para>
<simplelist>
<member><ulink
url="/starting_and_stopping_shorewall.htm">http://www.shorewall.net/starting_and_stopping_shorewall.htm</ulink>
- Describes operational aspects of Shorewall.</member>
<para>shorewall-accounting(5), shorewall-actions(5),
shorewall-arprules(5), shorewall-blrules(5), shorewall.conf(5),
shorewall-conntrack(5), shorewall-ecn(5), shorewall-exclusion(5),
shorewall-hosts(5), shorewall-init(5), shorewall_interfaces(5),
shorewall-ipsets(5), shorewall-logging(), shorewall-maclist(5),
shorewall-mangle(5), shorewall-masq(5), shorewall-modules(5),
shorewall-nat(5), shorewall-nesting(5), shorewall-netmap(5),
shorewall-params(5), shorewall-policy(5), shorewall-providers(5),
shorewall-proxyarp(5), shorewall6-proxyndp(5), shorewall-routes(5),
shorewall-rtrules(5), shorewall-rtrules(5), shorewall-rules(5),
shorewall-secmarks(5), shorewall-snat(5), shorewall-tcclasses(5),
shorewall-tcdevices(5), shorewall-tcfilters(5), shorewall-tcinterfaces(5),
shorewall-tcpri(5), shorewall-tunnels(5), shorewall-vardir(5),
shorewall-zones(5)</para>
<member><ulink url="shorewall-files.html">shorewall-files(5)</ulink> -
Describes the various configuration files along with features and
conventions common to those files.</member>
<member><ulink url="shorewall-names.html">shorewall-names(5)</ulink> -
Describes naming of objects within a Shorewall configuration.</member>
<member><ulink
url="shorewall-addresses.html">shorewall-addresses(5)</ulink> -
Describes how to specify addresses within a Shorewall
configuration.</member>
<member><ulink
url="shorewall-exclusion.html">shorewall-exclusion(5)</ulink> -
Describes how to exclude certain hosts and/or networks from matching a
rule.</member>
<member><ulink url="shorewall-nesting.html">shorewall-nesting(5)</ulink>
- Describes how to nest one Shorewall zone inside another.</member>
</simplelist>
</refsect1>
</refentry>

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# Shorewall Packet Filtering Firewall Control Program - V5.1
# Shorewall Packet Filtering Firewall Control Program - V5.2
#
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2014,2015-2017
# Tom Eastep (teastep@shorewall.net)

View File

@@ -0,0 +1,25 @@
#
# ALT/BaseALT/ALTLinux Shorewall 5.2 rc file
#
BUILD= #Default is to detect the build system
HOST=alt
PREFIX=/usr #Top-level directory for shared files, libraries, etc.
SHAREDIR=${PREFIX}/share #Directory for arch-neutral files.
LIBEXECDIR=${PREFIX}/libexec #Directory for executable scripts.
PERLLIBDIR=${SHAREDIR}/perl5 #Directory to install Shorewall Perl module directory
CONFDIR=/etc #Directory where subsystem configurations are installed
SBINDIR=/sbin #Directory where system administration programs are installed
MANDIR=${SHAREDIR}/man #Directory where manpages are installed.
INITDIR=${CONFDIR}/rc.d/init.d #Directory where SysV init scripts are installed.
INITFILE=$PRODUCT #Name of the product's installed SysV init script
INITSOURCE=init.alt.sh #Name of the distributed file to be installed as the SysV init script
ANNOTATED= #If non-zero, annotated configuration files are installed
SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
SYSCONFFILE=sysconfig #Name of the distributed file to be installed as $SYSCONFDIR/$PRODUCT
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter files are installed
SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
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=/usr/bin/less #Pager to use if none specified in shorewall[6].conf

View File

@@ -1,5 +1,5 @@
#
# Apple OS X Shorewall 5.0 rc file
# Apple OS X Shorewall 5.2 rc file
#
BUILD=apple
HOST=apple

View File

@@ -1,5 +1,5 @@
#
# Arch Linux Shorewall 5.0 rc file
# Arch Linux Shorewall 5.2 rc file
#
BUILD= #Default is to detect the build system
HOST=archlinux

View File

@@ -1,5 +1,5 @@
#
# Cygwin Shorewall 5.0 rc file
# Cygwin Shorewall 5.2 rc file
#
BUILD=cygwin
HOST=cygwin

View File

@@ -1,5 +1,5 @@
#
# Debian Shorewall 5.0 rc file
# Debian Shorewall 5.2 rc file
#
BUILD= #Default is to detect the build system
HOST=debian

View File

@@ -1,5 +1,5 @@
#
# Debian Shorewall 5.0 rc file
# Debian Shorewall 5.2 rc file
#
BUILD= #Default is to detect the build system
HOST=debian

View File

@@ -1,5 +1,5 @@
#
# Default Shorewall 5.0 rc file
# Default Shorewall 5.2 rc file
#
BUILD= #Default is to detect the build system
HOST=linux #Generic Linux

View File

@@ -1,5 +1,5 @@
#
# OpenWRT Shorewall 5.0 rc file
# OpenWRT/LEDE Shorewall 5.2 rc file
#
BUILD= #Default is to detect the build system
HOST=openwrt

View File

@@ -1,5 +1,5 @@
#
# RedHat/FedoraShorewall 5.0 rc file
# RedHat/FedoraShorewall 5.2 rc file
#
BUILD= #Default is to detect the build system
HOST=redhat

View File

@@ -1,5 +1,5 @@
#
# Slackware Shorewall 5.0 rc file
# Slackware Shorewall 5.2 rc file
#
BUILD=slackware
HOST=slackware

View File

@@ -1,5 +1,5 @@
#
# SuSE Shorewall 5.0 rc file
# SuSE Shorewall 5.2 rc file
#
BUILD= #Default is to detect the build system
HOST=suse

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# Shorewall interface helper utility - V4.2
# Shorewall interface helper utility - V5.2
#
# (c) 2007,2014 - Tom Eastep (teastep@shorewall.net)
#

150
Shorewall-init/init.alt.sh Executable file
View File

@@ -0,0 +1,150 @@
#!/bin/sh
#
# Shorewall init script
#
# chkconfig: - 09 91
# description: Initialize the shorewall firewall at boot time
#
### BEGIN INIT INFO
# Provides: shorewall-init
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Initialize the shorewall firewall at boot time
# Description: Place the firewall in a safe state at boot time
# prior to bringing up the network.
### END INIT INFO
# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1
# Source function library.
. /etc/init.d/functions
#
# The installer may alter this
#
. /usr/share/shorewall/shorewallrc
NAME="Shorewall-init firewall"
PROG="shorewall-init"
SHOREWALL="$SBINDIR/$PROG"
LOGGER="logger -i -t $PROG"
# Get startup options (override default)
OPTIONS=
LOCKFILE=/var/lock/subsys/shorewall-init
# check if shorewall-init is configured or not
if [ -f "/etc/sysconfig/shorewall-init" ]; then
. /etc/sysconfig/shorewall-init
if [ -z "$PRODUCTS" ]; then
echo "No PRODUCTS configured"
exit 6
fi
else
echo "/etc/sysconfig/shorewall-init not found"
exit 6
fi
RETVAL=0
# set the STATEDIR variable
setstatedir() {
local statedir
if [ -f ${CONFDIR}/${PRODUCT}/vardir ]; then
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
fi
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ -x ${STATEDIR}/firewall ]; then
return 0
elif [ $PRODUCT = shorewall ]; then
${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
else
return 1
fi
}
start() {
local PRODUCT
local STATEDIR
printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do
if setstatedir; then
$STATEDIR/$PRODUCT/firewall ${OPTIONS} stop 2>&1 | "$LOGGER"
RETVAL=$?
else
RETVAL=6
break
fi
done
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
ipset -R < "$SAVE_IPSETS"
fi
[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
return $RETVAL
}
stop() {
local PRODUCT
local STATEDIR
printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do
if setstatedir; then
${STATEDIR}/firewall ${OPTIONS} clear 2>&1 | "$LOGGER"
RETVAL=$?
else
RETVAL=6
break
fi
done
if [ -n "$SAVE_IPSETS" ]; then
mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi
fi
[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|condrestart|condreload)
# "Not implemented"
;;
condstop)
if [ -e "$LOCKFILE" ]; then
stop
fi
;;
status)
status "$PROG"
RETVAL=$?
;;
*)
echo $"Usage: ${0##*/} {start|stop|restart|reload|condrestart|condstop|status}"
RETVAL=1
esac
exit $RETVAL

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.0
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#

View File

@@ -1,5 +1,5 @@
#!/bin/sh /etc/rc.common
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.0
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
#
# (c) 2010,2012-2014 - Tom Eastep (teastep@shorewall.net)
# (c) 2016 - Matt Darfeuille (matdarf@gmail.com)

View File

@@ -1,5 +1,5 @@
#! /bin/bash
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.0
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
#
# (c) 2010,2012-2014 - Tom Eastep (teastep@shorewall.net)
#

View File

@@ -1,5 +1,5 @@
#! /bin/bash
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.0
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#

View File

@@ -181,6 +181,9 @@ if [ -z "$BUILD" ]; then
opensuse)
BUILD=suse
;;
alt|basealt|altlinux)
BUILD=alt
;;
*)
BUILD="$ID"
;;
@@ -191,6 +194,8 @@ if [ -z "$BUILD" ]; then
BUILD=debian
elif [ -f /etc/gentoo-release ]; then
BUILD=gentoo
elif [ -f /etc/altlinux-release ]; then
BUILD=alt
elif [ -f /etc/redhat-release ]; then
BUILD=redhat
elif [ -f /etc/SuSE-release ]; then
@@ -253,6 +258,9 @@ case "$HOST" in
openwrt)
echo "Installing Openwrt-specific configuration..."
;;
alt)
echo "Installing ALT-specific configuration...";
;;
linux)
fatal_error "Shorewall-init is not supported on this system"
;;

View File

@@ -1,5 +1,5 @@
#!/bin/bash
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.0
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
#
# (c) 2012-2014 - Tom Eastep (teastep@shorewall.net)
#

117
Shorewall-lite/init.alt.sh Executable file
View File

@@ -0,0 +1,117 @@
#!/bin/sh
#
# Shorewall-Lite init script
#
# chkconfig: - 28 90
# description: Packet filtering firewall
#
### BEGIN INIT INFO
# Provides: shorewall-lite
# Required-Start: $local_fs $remote_fs $syslog $network
# Should-Start: $time $named
# Required-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Packet filtering firewall
# Description: The Shoreline Firewall, more commonly known as "Shorewall", is a
# Netfilter (iptables) based firewall
### END INIT INFO
# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1
# Source function library.
. /etc/init.d/functions
#
# The installer may alter this
#
. /usr/share/shorewall/shorewallrc
NAME="Shorewall-Lite firewall"
PROG="shorewall"
SHOREWALL="$SBINDIR/$PROG -l"
LOGGER="logger -i -t $PROG"
# Get startup options (override default)
OPTIONS=
SourceIfNotEmpty $SYSCONFDIR/${PROG}-lite
LOCKFILE="/var/lock/subsys/${PROG}-lite"
RETVAL=0
start() {
action $"Applying $NAME rules:" "$SHOREWALL" "$OPTIONS" start "$STARTOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
return $RETVAL
}
stop() {
action $"Stoping $NAME :" "$SHOREWALL" "$OPTIONS" stop "$STOPOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
return $RETVAL
}
restart() {
action $"Restarting $NAME rules: " "$SHOREWALL" "$OPTIONS" restart "$RESTARTOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
return $RETVAL
}
reload() {
action $"Reloadinging $NAME rules: " "$SHOREWALL" "$OPTIONS" reload "$RELOADOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
return $RETVAL
}
clear() {
action $"Clearing $NAME rules: " "$SHOREWALL" "$OPTIONS" clear 2>&1 | "$LOGGER"
RETVAL=$?
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
clear)
clear
;;
condrestart)
if [ -e "$LOCKFILE" ]; then
restart
fi
;;
condreload)
if [ -e "$LOCKFILE" ]; then
restart
fi
;;
condstop)
if [ -e "$LOCKFILE" ]; then
stop
fi
;;
status)
"$SHOREWALL" status
RETVAL=$?
;;
*)
echo $"Usage: ${0##*/} {start|stop|restart|reload|clear|condrestart|condstop|status}"
RETVAL=1
esac
exit $RETVAL

View File

@@ -1,6 +1,6 @@
#!/bin/sh /etc/rc.common
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.5
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
#
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2012,2014 - Tom Eastep (teastep@shorewall.net)
# (c) 2015 - Matt Darfeuille - (matdarf@gmail.com)

View File

@@ -1,7 +1,7 @@
#!/bin/sh
RCDLINKS="2,S41 3,S41 6,K41"
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.5
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
#
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2012,2014 - Tom Eastep (teastep@shorewall.net)
#

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.5
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#

View File

@@ -190,6 +190,9 @@ if [ -z "$BUILD" ]; then
opensuse)
BUILD=suse
;;
alt|basealt|altlinux)
BUILD=alt
;;
*)
BUILD="$ID"
;;
@@ -198,6 +201,8 @@ if [ -z "$BUILD" ]; then
BUILD=debian
elif [ -f /etc/gentoo-release ]; then
BUILD=gentoo
elif [ -f /etc/altlinux-release ]; then
BUILD=alt
elif [ -f ${CONFDIR}/redhat-release ]; then
BUILD=redhat
elif [ -f ${CONFDIR}/SuSE-release ]; then
@@ -266,6 +271,9 @@ case "$HOST" in
openwrt)
echo "Installing OpenWRT-specific configuration..."
;;
alt)
echo "Installing ALT-specific configuration...";
;;
linux)
;;
*)

View File

@@ -1,5 +1,5 @@
#
# Shorewall 4.4 -- /usr/share/shorewall-lite/lib.base
# Shorewall 5.2 -- /usr/share/shorewall-lite/lib.base
#
# (c) 2011,2014 - Tom Eastep (teastep@shorewall.net)
#

View File

@@ -151,7 +151,7 @@ fi
remove_file ${SBINDIR}/$PRODUCT
if [ -L ${SHAREDIR}/$PRODUCT/init ]; then
if [ -h ${SHAREDIR}/$PRODUCT/init ]; then
if [ $HOST = openwrt ]; then
if [ $configure -eq 1 ] && /etc/init.d/$PRODUCT enabled; then
/etc/init.d/$PRODUCT disable

View File

@@ -135,7 +135,7 @@ if ( $command & $RESET_CMD ) {
#
# if the event is armed, remove it and perform the action
#
perl_action_helper( $action , "-m mark --mark $mark/$mark -m recent --remove --name $event" );
perl_action_helper( $action , "-m mark --mark $mark/$mark -m recent --remove --name $event $srcdst" );
} elsif ( $command & $UPDATE_CMD ) {
perl_action_helper( $action, "-m recent --update ${duration}--hitcount $hitcount --name $event $srcdst" );
} else {

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# Shorewall WAN Interface monitor - V4.4
# Shorewall WAN Interface monitor - V5.2
#
# Inspired by Angsuman Chakraborty's gwping script.
#

View File

@@ -1,5 +1,5 @@
#!/bin/sh
# Shorewall WAN Interface monitor - V4.4
# Shorewall WAN Interface monitor - V5.2
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#

View File

@@ -0,0 +1,9 @@
#
# Shorewall -- /usr/share/shorewall/macro.IPFS-swarm
#
# This macro handles IPFS data traffic (the connection to IPFS swarm).
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - tcp 4001

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.Bitcoin
#
# Macro for handling Bitcoin P2P traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 8333

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.BitcoinRPC
#
# Macro for handling Bitcoin RPC traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 8332

View File

@@ -0,0 +1,9 @@
#
# Shorewall --/usr/share/shorewall/macro.BitcoinZMQ
#
# Macro for handling Bitcoin ZMQ traffic
# See https://github.com/bitcoin/bitcoin/blob/master/doc/zmq.md
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 28332

View File

@@ -0,0 +1,12 @@
#
# Shorewall -- /usr/share/shorewall/macro.Cockpit
#
# This macro handles Time protocol (RFC868).
# Unless you are supporting extremely old hardware or software,
# you shouldn't be using this. NTP is a superior alternative.
#
# By Eric Teeter
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - tcp 9090

View File

@@ -0,0 +1,9 @@
#
# Shorewall -- /usr/share/shorewall/macro.IPFS-API
#
# This macro handles IPFS API port (commands for the IPFS daemon).
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - tcp 5001

View File

@@ -0,0 +1,9 @@
#
# Shorewall -- /usr/share/shorewall/macro.IPFS-gateway
#
# This macro handles the IPFS gateway to HTTP.
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - tcp 8080

View File

@@ -0,0 +1,9 @@
#
# Shorewall -- /usr/share/shorewall/macro.IPFS-swarm
#
# This macro handles IPFS data traffic (the connection to IPFS swarm).
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - tcp 4001

View File

@@ -0,0 +1,8 @@
#
# Shorewall -- /usr/share/shorewall/macro.ONCRPC
#
# This macro handles ONC RCP traffic (for rpcbind on Linux, etc).
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp,udp 111

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.Tor
#
# Macro for handling Tor Onion Network traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 9001

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.TorBrowserBundle
#
# Macro for handling Tor Onion Network traffic provided by Tor Browser Bundle
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 9150

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.TorControl
#
# Macro for handling Tor Controller Applications traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 9051

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.TorDirectory
#
# Macro for handling Tor Directory traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 9030

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.TorSocks
#
# Macro for handling Tor Socks Proxy traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 9050

View File

@@ -0,0 +1,9 @@
# Shorewall -- /usr/share/shorewall/macro.WUDO
#
# This macro handles WUDO (Windows Update Delivery Optimization)
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - tcp 7680

View File

@@ -1,5 +1,5 @@
#
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/ARP.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/ARP.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#

View File

@@ -1,9 +1,9 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Accounting.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Accounting.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -201,6 +201,13 @@ sub process_accounting_rule1( $$$$$$$$$$$ ) {
my $prerule = '';
my $rule2 = 0;
my $jump = 0;
my $raw_matches = get_inline_matches(1);
if ( $raw_matches =~ s/^\s*+// ) {
$prerule = $raw_matches;
} else {
$rule .= $raw_matches;
}
unless ( $action eq 'COUNT' ) {
if ( $action eq 'DONE' ) {
@@ -242,9 +249,7 @@ sub process_accounting_rule1( $$$$$$$$$$$ ) {
$rule .= do_nfacct( $_ );
}
}
} elsif ( $action eq 'INLINE' ) {
$rule .= get_inline_matches(1);
} else {
} elsif ( $action ne 'INLINE' ) {
( $action, my $cmd ) = split /:/, $action;
if ( $cmd ) {

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,10 @@
#! /usr/bin/perl -w
#
# The Shoreline Firewall Packet Filtering Firewall Compiler - V5.0
# The Shoreline Firewall Packet Filtering Firewall Compiler - V5.2
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -269,7 +269,12 @@ sub generate_script_2() {
'chain_exists DOCKER nat && chain_exists DOCKER && g_docker=Yes',
);
emit( 'chain_exists DOCKER-INGRESS && g_dockeringress=Yes' );
emit( 'chain_exists DOCKER-ISOLATION && g_dockernetwork=Yes' );
emit( 'chain_exists DOCKER-USER && g_dockeruser=Yes' );
emit( 'if chain_exists DOCKER-ISOLATION; then',
' g_dockernetwork=One',
'elif chain_exists DOCKER-ISOLATION-STAGE-1; then',
' g_dockernetwork=Two',
'fi' );
}
pop_indent;
@@ -356,7 +361,7 @@ sub generate_script_2() {
# Note: This function is not called when $command eq 'check'. So it must have no side effects other
# than those related to writing to the output script file.
#
sub generate_script_3($) {
sub generate_script_3() {
if ( $family == F_IPV4 ) {
progress_message2 "Creating iptables-restore input...";
@@ -382,7 +387,7 @@ sub generate_script_3($) {
my $fn = find_file( $config{LOAD_HELPERS_ONLY} ? 'helpers' : 'modules' );
if ( -f $fn && ( $config{EXPORTMODULES} || ( $export && ! $fn =~ "^$globals{SHAREDIR}/" ) ) ) {
emit 'echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir';
emit 'echo MODULESDIR=\"$MODULESDIR\" > ${VARDIR}/.modulesdir';
emit 'cat > ${VARDIR}/.modules << EOF';
open_file $fn;
@@ -582,8 +587,8 @@ sub compile_info_command() {
#
sub compiler {
my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview, $confess , $update , $annotate , $config_path, $shorewallrc , $shorewallrc1 ) =
( '', '', -1, '', 0, '', '', -1, 0, 0, 0, 0, , '' , '/usr/share/shorewall/shorewallrc', '' );
my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $log , $log_verbosity, $preview, $confess , $update , $annotate , $config_path, $shorewallrc , $shorewallrc1 ) =
( '', '', -1, '', 0, '', -1, 0, 0, 0, 0, , '' , '/usr/share/shorewall/shorewallrc', '' );
$export = 0;
$test = 0;
@@ -612,7 +617,6 @@ sub compiler {
timestamp => { store => \$timestamp, validate => \&validate_boolean } ,
debug => { store => \$debug, validate => \&validate_boolean } ,
export => { store => \$export , validate => \&validate_boolean } ,
chains => { store => \$chains },
log => { store => \$log },
log_verbosity => { store => \$log_verbosity, validate => \&validate_verbosity } ,
test => { store => \$test },
@@ -779,7 +783,7 @@ sub compiler {
#
# Setup Masquerade/SNAT
#
setup_snat( $update );
setup_snat;
#
# Setup Nat
#
@@ -882,7 +886,7 @@ sub compiler {
# N E T F I L T E R L O A D
# (Produces setup_netfilter(), setup_arptables(), chainlist_reload() and define_firewall() )
#
generate_script_3( $chains );
generate_script_3();
#
# We must reinitialize Shorewall::Chains before generating the iptables-restore input
# for stopping the firewall

View File

@@ -1,9 +1,9 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Config.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Config.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007-2018 - Tom Eastep (teastep@shorewall.net)
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -465,7 +465,7 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
TPROXY_TARGET => 'TPROXY Target',
FLOW_FILTER => 'Flow Classifier',
FWMARK_RT_MASK => 'fwmark route mask',
MARK_ANYWHERE => 'Mark in the filter table',
MARK_ANYWHERE => 'Mark in the filter and nat tables',
HEADER_MATCH => 'Header Match',
ACCOUNT_TARGET => 'ACCOUNT Target',
AUDIT_TARGET => 'AUDIT Target',
@@ -523,13 +523,17 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
CAPVERSION => 'Capability Version',
KERNELVERSION => 'Kernel Version',
);
#
# Keeps track of which capabilities were used or required - Key is capability name
#
our %used;
use constant {
USED => 1,
REQUIRED => 2 };
#
# Common Protocols
#
use constant {
ICMP => 1,
TCP => 6,
@@ -541,7 +545,7 @@ use constant {
UDPLITE => 136,
};
#
# Optimization masks
# Optimization masks (OPTIMIZE option)
#
use constant {
OPTIMIZE_POLICY_MASK => 0x02 , # Call optimize_policy_chains()
@@ -550,7 +554,9 @@ use constant {
OPTIMIZE_MASK => 0x1E , # Do optimizations beyond level 1
OPTIMIZE_ALL => 0x1F , # Maximum value for documented categories.
};
#
# Map helpers to protocols
#
our %helpers = ( amanda => UDP,
ftp => TCP,
irc => TCP,
@@ -562,7 +568,9 @@ our %helpers = ( amanda => UDP,
sip => UDP,
snmp => UDP,
tftp => UDP,
);
);
use constant { INCLUDE_LIMIT => 20 };
our %helpers_map;
@@ -623,7 +631,7 @@ our %config_files = ( #accounting => 1,
#
our @auditoptions = qw( BLACKLIST_DISPOSITION MACLIST_DISPOSITION TCP_FLAGS_DISPOSITION );
#
# Directories to search for configuration files
# Directories to search for configuration files (CONFIG_PATH option)
#
our @config_path;
#
@@ -646,10 +654,12 @@ our %compiler_params;
# Action parameters
#
our %actparams;
our $parmsmodified;
our $usedcaller;
our $inline_matches;
our $parmsmodified; # True of the current action has modified its parameters
our $usedcaller; # True if $CALLER has been acceseed in the current action
our $inline_matches; # Inline matches from the current rule
#
# File handling
#
our $currentline; # Current config file line image
our $rawcurrentline; # Current config file line with no variable expansion
our $currentfile; # File handle reference
@@ -667,6 +677,7 @@ 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 $ulogcount; # Used to suppress duplicate warnings about ULOG support
our $directive_callback; # Function to call in compiler_directive
our $shorewall_dir; # Shorewall Directory; if non-empty, search here first for files.
@@ -745,10 +756,11 @@ our $ifstack;
# [0] - Keyword (IF, ELSEIF, ELSE or ENDIF)
# [1] - True if the outermost IF evaluated to false
# [2] - True if the the last unterminated IF evaluated to false
# [3] = The line number of the directive
#
# From .shorewallrc
#
our ( %shorewallrc, %shorewallrc1 );
our ( %shorewallrc, %shorewallrc1 ); # Shorewallrc setting from local system and from remote firewall respectively
#
# read_a_line options
#
@@ -826,6 +838,7 @@ sub initialize( $;$$$) {
$comment = '';
$sr_comment = '';
$warningcount = 0;
$ulogcount = 0;
#
# Misc Globals
#
@@ -995,6 +1008,7 @@ sub initialize( $;$$$) {
BALANCE_PROVIDERS => undef ,
PERL_HASH_SEED => undef ,
USE_NFLOG_SIZE => undef ,
RENAME_COMBINED => undef ,
#
# Packet Disposition
#
@@ -1288,7 +1302,7 @@ sub initialize( $;$$$) {
$compiletime =~ s/ +/ /g;
}
my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
my @moabbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
sub add_ipset( $ ) {
$ipsets{$_[0]} = 1;
@@ -1388,7 +1402,7 @@ sub info_message
if ( $log ) {
@localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
}
if ( $confess ) {
@@ -1416,7 +1430,7 @@ sub warning_message
if ( $log ) {
@localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
}
if ( $confess ) {
@@ -1541,7 +1555,7 @@ sub fatal_error {
if ( $log ) {
our @localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
if ( $confess ) {
print $log longmess( " ERROR: @_$currentlineinfo\n" );
@@ -1564,6 +1578,9 @@ sub fatal_error {
}
}
#
# This one is used for reporting syntax errors in embedded Perl code
#
sub fatal_error1 {
handle_first_entry if $first_entry;
@@ -1571,7 +1588,7 @@ sub fatal_error1 {
if ( $log ) {
our @localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
if ( $debug ) {
print $log longmess( " ERROR: @_\n" );
@@ -1681,7 +1698,7 @@ sub emit {
if ( $script || $debug ) {
#
# 'compile' as opposed to 'check'
# 'compile' (as opposed to 'check') or debugging (CLI 'trace' command)
#
for ( @_ ) {
unless ( /^\s*$/ ) {
@@ -1842,12 +1859,15 @@ sub progress_message {
@localtime = localtime unless $havelocaltime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log "${leading}${line}\n";
}
}
}
#
# This one doesn't compress out superfluous white space
#
sub progress_message_nocompress {
my $havelocaltime = 0;
@@ -1861,7 +1881,7 @@ sub progress_message_nocompress {
@localtime = localtime unless $havelocaltime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log "@_\n";
}
}
@@ -1882,7 +1902,7 @@ sub progress_message2 {
@localtime = localtime unless $havelocaltime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log "@_\n";
}
}
@@ -1903,7 +1923,7 @@ sub progress_message3 {
@localtime = localtime unless $havelocaltime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log "@_\n";
}
}
@@ -2074,7 +2094,7 @@ sub set_debug( $$ ) {
#
sub find_file($)
{
my ( $filename, $nosearch ) = @_;
my ( $filename ) = @_;
return $filename if $filename =~ '/';
@@ -2091,8 +2111,12 @@ sub find_file($)
"$config_path[0]$filename";
}
#
# Search the CONFIG_PATH for a file that is writable. Ignore directories where sample/default files are installed,
# because users have a bad habit of including those in the CONFIG_PATH
#
sub find_writable_file($) {
my ( $filename, $nosearch ) = @_;
my ( $filename ) = @_;
return $filename if $filename =~ '/';
@@ -2114,6 +2138,9 @@ sub supplied( $ ) {
defined $val && $val ne '';
}
#
# This one is used for determining if an action argument has been passed (excludes '-')
#
sub passed( $ ) {
my $val = shift;
@@ -2132,7 +2159,7 @@ sub split_list( $$;$ ) {
}
#
# This version handles parenthetical list elements with embedded commas. It removes the parentheses
# This version handles parenthetical list elements containing embedded commas. It removes the parentheses
#
sub split_list1( $$;$ ) {
my ($list, $type, $keepparens ) = @_;
@@ -2516,7 +2543,7 @@ sub split_line2( $$;$$$ ) {
}
#
# Same as above, only it splits the raw current line
# Same as above, only it splits the raw current line (line prior to variable expansion)
#
sub split_rawline2( $$;$$$ ) {
my $savecurrentline = $currentline;
@@ -2526,6 +2553,10 @@ sub split_rawline2( $$;$$$ ) {
# Delete trailing comment
#
$currentline =~ s/\s*#.*//;
#
# Convert ${...} to $...
#
$currentline =~ s/\$\{(.*?)\}/\$$1/g;
my @result = &split_line2( @_ );
@@ -2620,6 +2651,7 @@ sub do_open_file( $ ) {
# - Maximum value allowed in ?FORMAT directives
# - ?COMMENT allowed in this file
# - Ignore ?COMMENT in ths file
# - Default file format
#
sub open_file( $;$$$$ ) {
my ( $fname, $mf, $ca, $nc, $cf ) = @_;
@@ -2712,7 +2744,7 @@ sub clear_currentfilename() {
}
#
# Process an ?IF, ?ELSIF, ?ELSE or ?END directive
# Utility functions for processing compiler directives
#
#
@@ -2739,7 +2771,7 @@ sub directive_warning( $$$$ ) {
if ( $log ) {
@localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log " WARNING: $_[0]\n";
}
@@ -2764,7 +2796,7 @@ sub directive_info( $$$$ ) {
if ( $log ) {
@localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log " INFO: $_[0]\n";
}
@@ -2826,7 +2858,7 @@ sub evaluate_expression( $$$$ ) {
}
# $1 $2 $3 - $4
while ( $expression =~ m( ^(.*?) \$({)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
while ( $expression =~ m( ^(.*?) \$(\{)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
my ( $first, $var, $rest ) = ( $1, $3, $4);
if ( $var =~ /^\d+$/ ) {
@@ -2843,7 +2875,7 @@ sub evaluate_expression( $$$$ ) {
if ( $chain ) {
# $1 $2 $3 - $4
while ( $expression =~ m( ^(.*?) \@({)? (\d+|[a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
while ( $expression =~ m( ^(.*?) \@(\{)? (\d+|[a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
my ( $first, $var, $rest ) = ( $1, $3, $4);
$var = numeric_value( $var ) if $var =~ /^\d/;
$val = $var ? $actparams{$var} : $chain;
@@ -2854,7 +2886,7 @@ sub evaluate_expression( $$$$ ) {
}
# $1 $2 $3 - $4
while ( $expression =~ m( ^(.*?) __({)? (\w+) (?(2)}) (.*)$ )x ) {
while ( $expression =~ m( ^(.*?) __(\{)? (\w+) (?(2)}) (.*)$ )x ) {
my ( $first, $cap, $rest ) = ( $1, $3, $4);
if ( exists $capdesc{$cap} ) {
@@ -3319,7 +3351,7 @@ sub copy1( $ ) {
my @line = split / /;
fatal_error "Invalid INCLUDE command" if @line != 2;
fatal_error "INCLUDEs nested too deeply" if @includestack >= 4;
fatal_error "INCLUDEs nested too deeply" if @includestack >= INCLUDE_LIMIT;
my $filename = find_file $line[1];
@@ -3516,7 +3548,7 @@ sub shorewall {
# We do this processing in read_a_line() rather than in the higher-level routines because
# Embedded Shell/Perl scripts are processed out of read_a_line(). If we were to defer announcement
# until we get back to the caller of read_a_line(), we could issue error messages about parsing and
# running scripts in the file before we'd even indicated that we are processing it.
# running scripts in the file before we'd even reported that we are processing it.
#
sub first_entry( $ ) {
$first_entry = shift;
@@ -3529,7 +3561,7 @@ sub read_a_line($);
sub embedded_shell( $ ) {
my $multiline = shift;
fatal_error "INCLUDEs nested too deeply" if @includestack >= 4;
fatal_error "INCLUDEs nested too deeply" if @includestack >= INCLUDE_LIMIT;
my ( $command, $linenumber ) = ( "/bin/sh -c '$currentline", $currentlinenumber );
$directive_callback->( 'SHELL', $currentline ) if $directive_callback;
@@ -3616,7 +3648,7 @@ sub embedded_perl( $ ) {
$embedded--;
if ( $perlscript ) {
fatal_error "INCLUDEs nested too deeply" if @includestack >= 4;
fatal_error "INCLUDEs nested too deeply" if @includestack >= INCLUDE_LIMIT;
assert( close $perlscript );
@@ -3693,6 +3725,7 @@ sub push_action_params( $$$$$$ ) {
# Return:
# 1 if the popped parameters were modified
# 2 if the action used @CALLER
# 3 if both
#
sub pop_action_params( $ ) {
my $oldparms = shift;
@@ -3703,6 +3736,10 @@ sub pop_action_params( $ ) {
$return;
}
#
# This is called when a DEFAULTS line is found in an action body. It supplies default values
# for those paramaters that were not passed, or that were passed as '-'.
#
sub default_action_params {
my $action = shift;
my ( $val, $i );
@@ -3716,6 +3753,9 @@ sub default_action_params {
fatal_error "Too Many arguments to action $action" if defined $actparams{$i};
}
#
# This function allows embedded Perl in actions to retreive the action paramaters
#
sub get_action_params( $ ) {
my $num = shift;
@@ -3731,6 +3771,9 @@ sub get_action_params( $ ) {
@return;
}
#
# Helper for A_* actions
#
sub setup_audit_action( $ ) {
my ( $action ) = @_;
@@ -3750,26 +3793,44 @@ sub get_action_logging() {
@actparams{ 'loglevel', 'logtag' };
}
#
# Allow embedded Perl in Actions to get the name of the action chain
#
sub get_action_chain() {
$actparams{0};
}
#
# Get the action name from an action file
#
sub get_action_chain_name() {
$actparams{chain};
}
#
# This allows an action to make subsequent log messages refer to the invoker of the action rather than the
# action itself
#
sub set_action_name_to_caller() {
$actparams{chain} = $actparams{caller};
}
#
# Get the current action's disposition
#
sub get_action_disposition() {
$actparams{disposition};
}
#
# Set the current action disposition for subsequent logging
#
sub set_action_disposition($) {
$actparams{disposition} = $_[0];
}
#
# Alter the value of one of the current actions parameters
#
sub set_action_param( $$ ) {
my $i = shift;
@@ -3784,7 +3845,7 @@ sub expand_variables( \$ ) {
my ( $lineref, $count ) = ( $_[0], 0 );
my $chain = $actparams{chain};
# $1 $2 $3 - $4
while ( $$lineref =~ m( ^(.*?) \$({)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
while ( $$lineref =~ m( ^(.*?) \$(\{)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
my ( $first, $var, $rest ) = ( $1, $3, $4);
@@ -3823,7 +3884,7 @@ sub expand_variables( \$ ) {
#
$$lineref =~ s/\\@/??/g;
# $1 $2 $3 - $4
while ( $$lineref =~ m( ^(.*?) \@({)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
while ( $$lineref =~ m( ^(.*?) \@(\{)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
my ( $first, $var, $rest ) = ( $1, $3, $4);
my $val = $var ? $actparams{$var} : $actparams{chain};
$usedcaller = USEDCALLER if $var eq 'caller';
@@ -3836,10 +3897,13 @@ sub expand_variables( \$ ) {
}
}
#
# Expand variables from shorewallrc in the current passed line
#
sub expand_shorewallrc_variables( \$ ) {
my ( $lineref, $count ) = ( $_[0], 0 );
# $1 $2 $3 - $4
while ( $$lineref =~ m( ^(.*?) \$({)? (\d+|[a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
while ( $$lineref =~ m( ^(.*?) \$(\{)? (\d+|[a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
my ( $first, $var, $rest ) = ( $1, $3, $4);
@@ -3879,7 +3943,7 @@ sub handle_first_entry() {
# - Handle embedded SHELL and PERL scripts
# - Expand shell variables from %params and %ENV.
# - Handle INCLUDE <filename>
# - Handle ?IF, ?ELSE, ?ENDIF
# - Handle ?SECTION
#
sub read_a_line($) {
@@ -3970,7 +4034,7 @@ sub read_a_line($) {
my @line = split ' ', $currentline;
fatal_error "Invalid INCLUDE command" if @line != 2;
fatal_error "INCLUDEs/Scripts nested too deeply" if @includestack >= 4;
fatal_error "INCLUDEs/Scripts nested too deeply" if @includestack >= INCLUDE_LIMIT;
my $filename = find_file $line[1];
@@ -4002,6 +4066,9 @@ sub read_a_line($) {
}
}
#
# Process the passed shorewallrc file, populating %shorewallrc
#
sub process_shorewallrc( $$ ) {
my ( $shorewallrc , $product ) = @_;
@@ -4022,6 +4089,12 @@ sub process_shorewallrc( $$ ) {
fatal_error "Failed to open $shorewallrc: $!";
}
#
# Older files may contain VARDIR= rather than VARLIB= to specify the directory
# where each product maintains its own state directory. This was confusing,
# because in the shell context, VARDIR points to the current product's state
# directory.
#
if ( supplied $shorewallrc{VARDIR} ) {
if ( ! supplied $shorewallrc{VARLIB} ) {
$shorewallrc{VARLIB} = $shorewallrc{VARDIR};
@@ -4084,12 +4157,19 @@ sub default_yes_no ( $$;$ ) {
$result;
}
#
# This one is used for options that are supported by IPv4 but not IPv6. It issues a
# warning message if the option is specified in shorewall6.conf.
#
sub default_yes_no_ipv4 ( $$ ) {
my ( $var, $val ) = @_;
default_yes_no( $var, $val );
warning_message "$var=Yes is ignored for IPv6" if $family == F_IPV6 && $config{$var};
}
#
# This function handles options that have a numeric value.
#
sub numeric_option( $$$ ) {
my ( $option, $default, $min ) = @_;
@@ -4107,6 +4187,9 @@ sub numeric_option( $$$ ) {
$config{$option} = $val;
}
#
# Returns a 32-bit value with the low order n bits set, where n is the passed argument.
#
sub make_mask( $ ) {
0xffffffff >> ( 32 - $_[0] );
}
@@ -4207,6 +4290,10 @@ sub validate_level( $;$ ) {
if ( $value =~ /^(NFLOG|ULOG)$/ ) {
my $olevel = $value;
if ( $value eq 'ULOG' ) {
warning_message "ULOG is deprecated in favor of NFLOG. Support for ULOG will be removed in a future release" unless $ulogcount++;
}
if ( $qualifier =~ /^[(](.*)[)]$/ ) {
my @options = split /,/, $1;
my $prefix = lc $olevel;
@@ -4282,7 +4369,7 @@ sub default_log_level( $$ ) {
}
#
# Check a tri-valued variable
# Check a tri-valued option ("on", "of" and "keep")
#
sub check_trivalue( $$ ) {
my ( $var, $default) = @_;
@@ -4418,7 +4505,8 @@ sub determine_kernelversion() {
}
#
# Capability Reporting and detection.
# Capability Reporting and detection. Each of the following functions detect the
# availability of the related capability.
#
sub Nat_Enabled() {
qt1( "$iptables $iptablesw -t nat -L -n" );
@@ -5133,7 +5221,7 @@ sub have_capability( $;$ ) {
$setting = $capabilities{ $capability } = detect_capability( $capability ) unless defined $setting;
$used{$capability} = $required ? 2 : 1 if $setting;
$used{$capability} = $required ? REQUIRED : USED if $setting;
$setting;
}
@@ -5330,6 +5418,9 @@ sub ensure_config_path() {
}
if ( $shorewall_dir ) {
#
# A directory has been specified -- place it at the front of the CONFIG_PATH
#
$shorewall_dir = getcwd if $shorewall_dir =~ m|^(\./*)+$|;
$shorewall_dir .= '/' unless $shorewall_dir =~ m|/$|;
unshift @config_path, $shorewall_dir if $shorewall_dir ne $config_path[0];
@@ -5364,7 +5455,8 @@ sub conditional_quote( $ ) {
}
#
# Update the shorewall[6].conf file. Save the current file with a .bak suffix.
# 'update' default values are sometimes different from the normal defaut value, to provide
# backward compatibility.
#
sub update_default($$) {
my ( $var, $val ) = @_;
@@ -5385,6 +5477,9 @@ sub transfer_permissions( $$ ) {
}
}
#
# Update the shorewall[6].conf file. Save the current file with a .bak suffix.
#
sub update_config_file( $ ) {
my ( $annotate ) = @_;
@@ -5456,7 +5551,7 @@ sub update_config_file( $ ) {
update_default( 'BLACKLIST_DEFAULT', 'AllowICMPs,dropBcasts,dropNotSyn,dropInvalid' );
}
for ( qw/DROP_DEFAULT REJECT_DEFAULT/ ) {
for ( qw/DROP_DEFAULT REJECT_DEFAULT BLACKLIST_DEFAULT/ ) {
my $policy = $config{ $_ };
if ( $policy =~ /\bA_(?:Drop|Reject)\b/ ) {
@@ -5783,7 +5878,7 @@ sub unsupported_yes_no_warning( $ ) {
}
#
# Process the params file
# Process the params file. Actually processing is done by the 'getparams' program in $LIBEXECDIR/shorewall/.
#
sub get_params( $ ) {
my $export = $_[0];
@@ -5918,7 +6013,7 @@ sub get_params( $ ) {
#
delete $params{$_};
} else {
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' || $_ eq 'SW_LOGGERTAG' ) {
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' || $_ eq 'SW_LOGGERTAG' || $_ eq 'SW_CONFDIR' ) {
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{$_};
}
@@ -6540,6 +6635,7 @@ sub get_configuration( $$$ ) {
default_yes_no 'AUTOCOMMENT' , 'Yes';
default_yes_no 'MULTICAST' , '';
default_yes_no 'MARK_IN_FORWARD_CHAIN' , '';
default_yes_no 'RENAME_COMBINED' , 'Yes';
if ( supplied ( $val = $config{TRACK_RULES} ) ) {
if ( lc( $val ) eq 'file' ) {
@@ -6591,11 +6687,14 @@ sub get_configuration( $$$ ) {
default_yes_no 'MANGLE_ENABLED' , have_capability( 'MANGLE_ENABLED' ) ? 'Yes' : '';
default_yes_no 'USE_DEFAULT_RT' , '';
default_yes_no 'RESTORE_DEFAULT_ROUTE' , 'Yes';
default_yes_no 'AUTOMAKE' , '';
default_yes_no 'TRACK_PROVIDERS' , 'Yes';
default_yes_no 'BALANCE_PROVIDERS' , $config{USE_DEFAULT_RT} ? 'Yes' : '';
default_yes_no 'USE_NFLOG_SIZE' , '';
if ( ( $val = ( $config{AUTOMAKE} || '' ) ) !~ /^[Rr]ecursive$/ ) {
default_yes_no( 'AUTOMAKE' , '' ) unless $val && $val =~ /^\d{1,2}$/;
}
if ( $config{USE_NFLOG_SIZE} ) {
if ( have_capability( 'NFLOG_SIZE' ) ) {
@suffixes = qw(group size threshold nlgroup cprange qthreshold);
@@ -7185,6 +7284,9 @@ sub generate_aux_config() {
finalize_aux_config;
}
#
# Generate a report of the fwmark layout
#
sub dump_mark_layout() {
sub dumpout( $$$$$ ) {
my ( $name, $bits, $min, $max, $mask ) = @_;

View File

@@ -1,5 +1,5 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/IPAddrs.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/IPAddrs.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
@@ -60,6 +60,7 @@ our @EXPORT = ( qw( ALLIPv4
decompose_net
decompose_net_u32
compare_nets
loopback_address
validate_host
validate_range
ip_range_explicit
@@ -98,12 +99,14 @@ our $resolve_dnsname;
our $validate_range;
our $validate_host;
our $family;
our $loopback_address;
use constant { ALLIPv4 => '0.0.0.0/0' ,
ALLIPv6 => '::/0' ,
NILIPv4 => '0.0.0.0' ,
NILIPv6 => '::' ,
IPv4_MULTICAST => '224.0.0.0/4' ,
IPv4_LOOPBACK => '127.0.0.1' ,
IPv6_MULTICAST => 'ff00::/8' ,
IPv6_LINKLOCAL => 'fe80::/10' ,
IPv6_SITELOCAL => 'feC0::/10' ,
@@ -370,6 +373,10 @@ sub rfc1918_networks() {
@rfc1918_networks
}
sub loopback_address() {
$loopback_address;
}
#
# Protocol/port validation
#
@@ -755,6 +762,7 @@ sub initialize( $ ) {
$nilip = NILIPv4;
@nilip = @nilipv4;
$vlsm_width = VLSMv4;
$loopback_address = IPv4_LOOPBACK;
$valid_address = \&valid_4address;
$validate_address = \&validate_4address;
$validate_net = \&validate_4net;
@@ -767,6 +775,7 @@ sub initialize( $ ) {
$nilip = NILIPv6;
@nilip = @nilipv6;
$vlsm_width = VLSMv6;
$loopback_address = IPv6_LOOPBACK;
$valid_address = \&valid_6address;
$validate_address = \&validate_6address;
$validate_net = \&validate_6net;

View File

@@ -1,9 +1,9 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Misc.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Misc.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -66,6 +66,9 @@ sub initialize( $ ) {
$family = shift;
}
#
# Warn that the tos file is no longer supported
#
sub process_tos() {
if ( my $fn = open_file 'tos' ) {
@@ -145,6 +148,9 @@ sub setup_ecn()
}
}
#
# Add a logging rule followed by a jump
#
sub add_rule_pair( $$$$$ ) {
my ($chainref , $predicate , $target , $level, $tag ) = @_;
@@ -402,6 +408,9 @@ EOF
}
}
#
# Convert a routestopped file into an equivalent stoppedrules file
#
sub convert_routestopped() {
if ( my $fn = open_file 'routestopped' ) {
@@ -662,13 +671,26 @@ sub process_stoppedrules() {
$result;
}
#
# Generate the rules required when DOCKER=Yes
#
sub create_docker_rules() {
add_commands( $nat_table->{PREROUTING} , '[ -n "$g_docker" ] && echo "-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER" >&3' );
my $chainref = $filter_table->{FORWARD};
add_commands( $chainref, '[ -n "$g_dockeringress" ] && echo "-A FORWARD -j DOCKER-INGRESS" >&3', );
add_commands( $chainref, '[ -n "$g_dockernetwork" ] && echo "-A FORWARD -j DOCKER-ISOLATION" >&3', );
add_commands( $chainref, '[ -n "$g_dockeringress" ] && echo "-A FORWARD -j DOCKER-INGRESS" >&3', );
add_commands( $chainref, '[ -n "$g_dockeruser" ] && echo "-A FORWARD -j DOCKER-USER" >&3', );
add_commands( $chainref ,
'',
'case "$g_dockernetwork" in',
' One)',
' echo "-A FORWARD -j DOCKER-ISOLATION" >&3',
' ;;',
' Two)',
' echo "-A FORWARD -j DOCKER-ISOLATION-STAGE-1" >&3',
' ;;',
'esac' );
if ( my $dockerref = known_interface('docker0') ) {
add_commands( $chainref, 'if [ -n "$g_docker" ]; then' );
@@ -693,6 +715,9 @@ sub create_docker_rules() {
sub setup_mss();
#
# Add rules generated by .conf options and interface options
#
sub add_common_rules ( $ ) {
my ( $upgrade ) = @_;
my $interface;
@@ -810,7 +835,7 @@ sub add_common_rules ( $ ) {
$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 );
my $chainref = set_optflags( new_standard_chain( $dbl_src_target = $dbl_dst_target = 'dbl_log' ) , DONT_OPTIMIZE | DONT_DELETE );
log_rule_limit( $dbl_level,
$chainref,
@@ -1273,6 +1298,13 @@ my %maclist_targets = ( ACCEPT => { target => 'RETURN' , mangle => 1 } ,
REJECT => { target => 'reject' , mangle => 0 } ,
DROP => { target => 'DROP' , mangle => 1 } );
#
# Create rules generated by the 'maclist' option and by entries in the maclist file.
#
# The function is called twice. The first call passes '1' and causes the maclist file
# to be processed. The second call passes '2' and generates the jumps for 'maclist'
# interfaces.
#
sub setup_mac_lists( $ ) {
my $phase = $_[0];
@@ -1714,9 +1746,9 @@ sub add_interface_jumps {
add_ijump( $filter_table->{input_chain $bridge },
j => $inputref ,
imatch_source_dev( $interface, 1 )
) unless $input_jump_added{$interface} || ! use_input_chain $interface, $inputref;
) unless $input_jump_added{$interface} || ! use_interface_chain( $interface, 'use_input_chain' );
unless ( $output_jump_added{$interface} || ! use_output_chain $interface, $outputref ) {
unless ( $output_jump_added{$interface} || ! use_interface_chain( $interface, 'use_output_chain') ) {
add_ijump( $filter_table->{output_chain $bridge} ,
j => $outputref ,
imatch_dest_dev( $interface, 1 ) )
@@ -1725,10 +1757,10 @@ sub add_interface_jumps {
} else {
add_ijump ( $filter_table->{FORWARD}, j => 'ACCEPT', imatch_source_dev( $interface) , imatch_dest_dev( $interface) ) unless $interfaceref->{nets} || ! $interfaceref->{options}{bridge};
add_ijump( $filter_table->{FORWARD} , j => $forwardref , imatch_source_dev( $interface ) ) if use_forward_chain( $interface, $forwardref ) && ! $forward_jump_added{$interface}++;
add_ijump( $filter_table->{INPUT} , j => $inputref , imatch_source_dev( $interface ) ) if use_input_chain( $interface, $inputref ) && ! $input_jump_added{$interface}++;
add_ijump( $filter_table->{FORWARD} , j => $forwardref , imatch_source_dev( $interface ) ) if use_forward_chain( $interface, $forwardref ) && ! $forward_jump_added{$interface}++;
add_ijump( $filter_table->{INPUT} , j => $inputref , imatch_source_dev( $interface ) ) if use_interface_chain( $interface, 'use_input_chain' ) && ! $input_jump_added{$interface}++;
if ( use_output_chain $interface, $outputref ) {
if ( use_interface_chain( $interface, 'use_output_chain' ) ) {
add_ijump $filter_table->{OUTPUT} , j => $outputref , imatch_dest_dev( $interface ) unless get_interface_option( $interface, 'port' ) || $output_jump_added{$interface}++;
}
}
@@ -1917,7 +1949,7 @@ sub add_output_jumps( $$$$$$$$ ) {
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 ) || @zone_interfaces > 1 ) {
if ( @vservers || use_interface_chain( $interface, 'use_output_chain' ) || ( @{$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
@@ -2051,7 +2083,7 @@ sub add_input_jumps( $$$$$$$$$ ) {
my @source = imatch_source_net $net;
my @ipsec_in_match = match_ipsec_in $zone , $hostref;
if ( @vservers || use_input_chain( $interface, $interfacechainref ) || ! $chain2 || ( @{$interfacechainref->{rules}} && ! $chain2ref ) ) {
if ( @vservers || use_interface_chain( $interface, 'use_input_chain' ) || ! $chain2 || ( @{$interfacechainref->{rules}} && ! $chain2ref ) ) {
#
# - There are vserver zones (so INPUT will have multiple destinations; or
# - We must use the interface input chain; or
@@ -2444,6 +2476,9 @@ sub generate_matrix() {
}
}
#
# Generate MSS rules
#
sub setup_mss( ) {
my $clampmss = $config{CLAMPMSS};
my $option;

View File

@@ -1,9 +1,9 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Nat.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Nat.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -37,7 +37,7 @@ use strict;
our @ISA = qw(Exporter);
our @EXPORT = qw( setup_nat setup_netmap add_addresses );
our %EXPORT_TAGS = ( rules => [ qw ( handle_nat_rule handle_nonat_rule process_one_masq convert_masq @addresses_to_add %addresses_to_add ) ] );
our %EXPORT_TAGS = ( rules => [ qw ( handle_nat_rule handle_nonat_rule convert_masq @addresses_to_add %addresses_to_add ) ] );
our @EXPORT_OK = ();
Exporter::export_ok_tags('rules');
@@ -90,7 +90,7 @@ sub process_one_masq1( $$$$$$$$$$$ )
#
# Handle early matches
#
if ( $inlinematches =~ s/s*\+// ) {
if ( $inlinematches =~ s/^s*\+// ) {
$prerule = $inlinematches;
$inlinematches = '';
}
@@ -587,11 +587,11 @@ EOF
# Convert a masq file into the equivalent snat file
#
sub convert_masq() {
my $have_masq_rules;
if ( my $fn = open_file( 'masq', 1, 1 ) ) {
my ( $snat, $fn1 ) = open_snat_for_output( $fn );
my $have_masq_rules;
directive_callback(
sub ()
{
@@ -647,6 +647,8 @@ sub convert_masq() {
close $snat, directive_callback( 0 );
}
$have_masq_rules;
}
#

View File

@@ -1,5 +1,5 @@
#
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/Proc.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Proc.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#

View File

@@ -1,9 +1,9 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Providers.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Providers.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -60,25 +60,63 @@ our @routemarked_providers;
our %routemarked_interfaces;
our @routemarked_interfaces;
our %provider_interfaces;
our @load_interfaces;
our @load_providers;
our $balancing;
our $fallback;
our $balanced_providers;
our $fallback_providers;
our $metrics;
our $first_default_route;
our $first_fallback_route;
our $maxload;
our $tproxies;
our $balancing; # True, if there are balanced providers
our $fallback; # True, if there are fallback providers
our $balanced_providers; # Count of balanced providers
our $fallback_providers; # Count of fallback providers
our $metrics; # True, if using statistical balancing
our $first_default_route; # True, until we generate the first 'via' clause for balanced providers
our $first_fallback_route; # True, until we generate the first 'via' clause for fallback providers
our $maxload; # Sum of 'load' values
our $tproxies; # Count of tproxy providers
our %providers;
our %providers; # Provider table
#
# %provider_table { <provider> => { provider => <provider name>,
# number => <provider number>,
# id => <name> or <number> depending on USE_RT_NAMES,
# rawmark => <specified mark value>,
# mark => <mark, in hex>,
# interface => <logical interface>,
# physical => <physical interface>,
# optional => {0|1},
# wildcard => <from interface>,
# gateway => <gateway>,
# gatewaycase => { 'detect', 'none', or 'specified' },
# shared => <true, if multiple providers through this interface>,
# copy => <contents of the COPY column>,
# balance => <balance count>,
# pref => <route rules preference (priority) value>,
# mtu => <mtu>,
# noautosrc => {0|1} based on [no]autosrc setting,
# track => {0|1} based on 'track' setting,
# loose => {0|1} based on 'loose' setting,
# duplicate => <contents of the DUPLICATE column>,
# address => If {shared} above, then the local IP address.
# Otherwise, the value of the 'src' option,
# mac => Mac address of gateway, if {shared} above,
# tproxy => {0|1},
# load => <load % for statistical balancing>,
# pseudo => {0|1}. 1 means this is an optional interface and not
# a real provider,
# what => 'provider' or 'interface' depending on {pseudo} above,
# hostroute => {0|1} based on [no]hostroute setting,
# rules => ( <routing rules> ),
# persistent_rules => ( <persistent routing rules> ),
# routes => ( <routes> ),
# persistent_routes => ( <persistent routes> ),
# persistent => {0|1} depending on 'persistent' setting,
# routedests => { <subnet> => 1 , ... }, (used for duplicate destination detection),
# origin => <filename and linenumber where provider/interface defined>
# }
our @providers;
our @providers; # Provider names. Only declared names are included in this array.
our $family;
our $family; # Address family
our $lastmark;
our $lastmark; # Highest assigned mark
use constant { ROUTEMARKED_SHARED => 1, ROUTEMARKED_UNSHARED => 2 };
@@ -99,7 +137,7 @@ sub initialize( $ ) {
%routemarked_interfaces = ();
@routemarked_interfaces = ();
%provider_interfaces = ();
@load_interfaces = ();
@load_providers = ();
$balancing = 0;
$balanced_providers = 0;
$fallback_providers = 0;
@@ -163,8 +201,8 @@ sub setup_route_marking() {
add_ijump_extended $mangle_table->{OUTPUT} , j => $chainref2, $origin, mark => "--mark $mark/$mask";
if ( have_ipsec ) {
if ( have_capability( 'MARK_ANYWHERE' ) ) {
add_ijump_extended $filter_table->{forward_chain($interface)}, j => 'CONNMARK', $origin, targetopts => "--set-mark 0${exmask}", , state_imatch('NEW'), policy => '--dir in --pol ipsec';
if ( have_capability( 'MARK_ANYWHERE' ) && ( my $chainref = $filter_table->{forward_chain($interface)} ) ) {
add_ijump_extended $chainref, j => 'CONNMARK', $origin, targetopts => "--set-mark 0${exmask}", , state_imatch('NEW'), policy => '--dir in --pol ipsec';
} elsif ( have_capability( 'MANGLE_FORWARD' ) ) {
add_ijump_extended $mangle_table->{FORWARD}, j => 'CONNMARK', $origin, targetopts => "--set-mark 0${exmask}", i => $physical, state_imatch('NEW'), policy => '--dir in --pol ipsec';
}
@@ -185,16 +223,16 @@ sub setup_route_marking() {
add_ijump $chainref, j => 'CONNMARK', targetopts => "--save-mark --mask $mask", mark => "! --mark 0/$mask";
}
if ( @load_interfaces ) {
if ( @load_providers ) {
my $chainref1 = new_chain 'mangle', 'balance';
my @match;
add_ijump $chainref, g => $chainref1, mark => "--mark 0/$mask";
add_ijump $mangle_table->{OUTPUT}, j => $chainref1, state_imatch( 'NEW,RELATED' ), mark => "--mark 0/$mask";
for my $physical ( @load_interfaces ) {
for my $provider ( @load_providers ) {
my $chainref2 = new_chain( 'mangle', load_chain( $physical ) );
my $chainref2 = new_chain( 'mangle', load_chain( $provider ) );
set_optflags( $chainref2, DONT_OPTIMIZE | DONT_MOVE | DONT_DELETE );
@@ -446,7 +484,7 @@ sub process_a_provider( $ ) {
fatal_error 'NAME must be specified' if $table eq '-';
unless ( $pseudo ) {
fatal_error "Invalid Provider Name ($table)" unless $table =~ /^[\w]+$/;
fatal_error "Invalid Provider Name ($table)" unless $table =~ /^[A-Za-z][\w]*$/;
my $num = numeric_value $number;
@@ -636,6 +674,7 @@ sub process_a_provider( $ ) {
}
fatal_error "A provider interface must have at least one associated zone" unless $tproxy || %{interface_zones($interface)};
fatal_error "An interface supporting multiple providers may not be optional" if $shared && $optional;
unless ( $pseudo ) {
if ( $local ) {
@@ -779,7 +818,7 @@ sub process_a_provider( $ ) {
push @routemarked_providers, $providers{$table};
}
push @load_interfaces, $physical if $load;
push @load_providers, $table if $load;
push @providers, $table;
@@ -941,8 +980,9 @@ sub add_a_provider( $$ ) {
}
}
emit( "echo $load > \${VARDIR}/${physical}_load",
'echo ' . in_hex( $mark ) . '/' . in_hex( $globals{PROVIDER_MASK} ) . " > \${VARDIR}/${physical}_mark" ) if $load;
emit( "echo $load > \${VARDIR}/${table}_load",
'echo ' . in_hex( $mark ) . '/' . in_hex( $globals{PROVIDER_MASK} ) . " > \${VARDIR}/${table}_mark",
"echo $physical > \${VARDIR}/${table}_interface" ) if $load;
emit( '',
"cat <<EOF >> \${VARDIR}/undo_${table}_routing" );
@@ -1097,7 +1137,7 @@ CEOF
$weight = 1;
}
emit ( "distribute_load $maxload @load_interfaces" ) if $load;
emit ( "distribute_load $maxload @load_providers" ) if $load;
unless ( $shared ) {
emit( "setup_${dev}_tc" ) if $tcdevices->{$interface};
@@ -1244,7 +1284,7 @@ CEOF
}
emit ( '',
"distribute_load $maxload @load_interfaces" ) if $load;
"distribute_load $maxload @load_providers" ) if $load;
if ( $persistent ) {
emit ( '',
@@ -1615,7 +1655,7 @@ sub finish_providers() {
emit( 'fi',
'' );
} else {
if ( ( $fallback || @load_interfaces ) && $config{USE_DEFAULT_RT} ) {
if ( ( $fallback || @load_providers ) && $config{USE_DEFAULT_RT} ) {
emit ( q(#),
q(# Delete any default routes in the 'main' table),
q(#),
@@ -1909,24 +1949,24 @@ sub setup_providers() {
pop_indent;
emit 'fi';
setup_route_marking if @routemarked_interfaces || @load_interfaces;
setup_route_marking if @routemarked_interfaces || @load_providers;
} else {
emit "\nif [ -z \"\$g_noroutes\" ]; then";
push_indent;
emit "undo_routing";
emit "restore_default_route $config{USE_DEFAULT_RT}";
if ( $pseudoproviders ) {
emit '';
emit "start_$providers{$_}->{what}_$_" for @providers;
emit '';
}
emit "undo_routing";
emit "restore_default_route $config{USE_DEFAULT_RT}";
my $standard_routes = @{$providers{main}{routes}} || @{$providers{default}{routes}};
if ( $config{NULL_ROUTE_RFC1918} ) {
emit '';
setup_null_routing;
emit "\nrun_ip route flush cache" unless $standard_routes;
}
@@ -2485,7 +2525,7 @@ sub handle_stickiness( $ ) {
}
}
if ( @routemarked_providers || @load_interfaces ) {
if ( @routemarked_providers || @load_providers ) {
delete_jumps $mangle_table->{PREROUTING}, $setstickyref unless @{$setstickyref->{rules}};
delete_jumps $mangle_table->{OUTPUT}, $setstickoref unless @{$setstickoref->{rules}};
}
@@ -2493,9 +2533,9 @@ sub handle_stickiness( $ ) {
sub setup_load_distribution() {
emit ( '',
"distribute_load $maxload @load_interfaces" ,
"distribute_load $maxload @load_providers" ,
''
) if @load_interfaces;
) if @load_providers;
}
1;

View File

@@ -1,5 +1,5 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Proxyarp.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Proxyarp.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#

View File

@@ -1,9 +1,9 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Raw.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Raw.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2009-2018 - Tom Eastep (teastep@shorewall.net)
# (c) 2009-2019 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -70,6 +70,13 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
my $zone;
my $restriction = PREROUTE_RESTRICT;
my $raw_matches = get_inline_matches(0);
my $prerule = '';
if ( $raw_matches =~ /^s*+/ ) {
$prerule = $raw_matches;
$raw_matches = '';
}
if ( $chainref ) {
$restriction = OUTPUT_RESTRICT if $chainref->{name} eq 'OUTPUT';
@@ -206,10 +213,11 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
expand_rule( $chainref ,
$restriction ,
'',
$prerule,
do_proto( $proto, $ports, $sports ) .
do_user ( $user ) .
do_condition( $switch , $chainref->{name} ),
do_condition( $switch , $chainref->{name} ) .
$raw_matches ,
$source ,
$dest ,
'' ,
@@ -316,7 +324,7 @@ sub setup_conntrack($) {
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, user => 5, switch => 6 } );
$action = 'NOTRACK';
} else {
( $action, $source, $dest, $protos, $ports, $sports, $user, $switch ) = split_line1 'Conntrack File', { action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, switch => 7 };
( $action, $source, $dest, $protos, $ports, $sports, $user, $switch ) = split_line2( 'Conntrack File', { action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, switch => 7 }, undef, undef, 1 );
}
$empty = 0;

View File

@@ -1,9 +1,9 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Rules.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Rules.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -1232,7 +1232,7 @@ sub finish_chain_section ($$$) {
if ( $twochains ) {
$chain2ref = $chainref;
} else {
$chain2ref = new_chain( 'filter', "${char}$chainref->{name}" );
$chain2ref = new_chain( 'filter', "${char}$chainref->{name}" , "${char}$chainref->{logname}" );
}
log_rule_limit( $level,
@@ -2609,7 +2609,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
#
# Handle early matches
#
if ( $raw_matches =~ s/s*\+// ) {
if ( $raw_matches =~ s/^s*\+// ) {
$prerule = $raw_matches;
$raw_matches = '';
}
@@ -2781,7 +2781,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
LOG => sub { fatal_error 'LOG requires a log level' unless supplied $loglevel; } ,
HELPER => sub {
fatal_error "HELPER requires require that the helper be specified in the HELPER column" if $helper eq '-';
fatal_error "HELPER requires that a helper be specified in the HELPER column" if $helper eq '-';
fatal_error "HELPER rules may only appear in the NEW section" unless $section == NEW_SECTION;
$action = ''; } ,
@@ -3137,13 +3137,14 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
if ( $actiontype & ( NATRULE | NONAT ) && ! ( $actiontype & NATONLY ) ) {
#
# Either a DNAT, REDIRECT or ACCEPT+ rule or an Action with NAT;
# don't apply rate limiting twice
#
$rule .= join( '',
do_proto($proto, $ports, $sports),
do_ratelimit( $ratelimit, 'ACCEPT' ),
do_user( $user ) ,
do_test( $mark , $globals{TC_MASK} ) ,
do_connlimit( $connlimit ),
do_ratelimit( $ratelimit, 'ACCEPT' ),
do_time( $time ) ,
do_headers( $headers ) ,
do_condition( $condition , $chain ) ,
@@ -3239,12 +3240,12 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
# - the destination IP will be the server IP ($dest) -- also done above
# - there will be no log level (we log NAT rules in the nat table rather than in the filter table).
# - the target will be ACCEPT.
# - don't apply rate limiting twice
#
unless ( $actiontype & NATONLY ) {
$rule = join( '',
$matches,
do_proto( $proto, $ports, $sports ),
do_ratelimit( $ratelimit, 'ACCEPT' ),
do_user $user,
do_test( $mark , $globals{TC_MASK} ),
do_condition( $condition , $chain ),
@@ -4077,6 +4078,10 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
O => OUTPUT,
T => POSTROUTING,
R => REALPREROUTING,
NP => REALPREROUTING,
NI => REALINPUT,
NO => REALOUTPUT,
NT => REALPOSTROUTING
);
my %chainlabels = ( 1 => 'PREROUTING',
@@ -4085,14 +4090,17 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
8 => 'OUTPUT',
16 => 'POSTROUTING' );
my %chainnames = ( 1 => 'tcpre',
2 => 'tcin',
4 => 'tcfor',
8 => 'tcout',
16 => 'tcpost',
32 => 'sticky',
64 => 'sticko',
128 => 'PREROUTING',
my %chainnames = ( 1 => 'tcpre',
2 => 'tcin',
4 => 'tcfor',
8 => 'tcout',
16 => 'tcpost',
32 => 'sticky',
64 => 'sticko',
128 => 'PREROUTING',
256 => 'INPUT',
512 => 'OUTPUT',
1024 => 'POSTROUTING',
);
my $inchain = defined $chainref;
@@ -4116,6 +4124,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
my $actiontype;
my $commandref;
my $prerule = '';
my $table = 'mangle';
my $tabletype = MANGLE_TABLE;
#
# Subroutine for handling MARK and CONNMARK. We use an enclosure so as to keep visibility of the
# function's local variables without making them static. process_mangle_rule1() is called
@@ -4157,7 +4167,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
$option ||= ( $and_or eq '|' ? '--or-mark' : $and_or ? '--and-mark' : '--set-mark' );
my $chainref = ensure_chain( 'mangle', $chain = $chainnames{$chain} );
my $chainref = ensure_chain( $table, $chain = $chainnames{$chain} );
$restriction |= $chainref->{restriction};
@@ -4476,7 +4486,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
my ( $tgt, $options ) = split( ' ', $params, 2 );
my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type;
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & MANGLE_TABLE;
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & $tabletype;
$target = $params;
$usergenerated = 1;
},
@@ -4492,7 +4502,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
my ( $tgt, $options ) = split( ' ', $params, 2 );
my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type;
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & MANGLE_TABLE;
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & $tabletype;
$target = $params;
$usergenerated = 1;
},
@@ -4564,7 +4574,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
RESTORE => {
defaultchain => 0,
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING,
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING | REALPREROUTING | REALINPUT | REALOUTPUT | REALPOSTROUTING,
minparams => 0,
maxparams => 1,
function => sub () {
@@ -4600,7 +4610,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
SAVE => {
defaultchain => 0,
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING,
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING | REALPREROUTING | REALINPUT | REALOUTPUT | REALPOSTROUTING,
minparams => 0,
maxparams => 1,
function => sub () {
@@ -4846,6 +4856,14 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
fatal_error "A chain designator may not be specified in an action body" if $inaction;
my $temp = $designators{$designator};
fatal_error "Invalid chain designator ( $designator )" unless $temp;
if ( $designator =~ /^N/ ) {
fatal_error "Only MARK, CONNMARK, SAVE and RESTORE may be used in the nat table" unless $cmd =~ /^(?:(?:(?:CONN)MARK)|SAVE|RESTORE)[(]?/;
require_capability('MARK_ANYWHERE', "The $designator designator", 's');
$table = 'nat';
$tabletype = NAT_TABLE;
}
$designator = $temp;
}
@@ -4871,19 +4889,28 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
#
# Handle early matches
#
if ( $raw_matches =~ s/s*\+// ) {
if ( $raw_matches =~ s/^s*\+// ) {
$prerule = $raw_matches;
$raw_matches = '';
}
if ( $source ne '-' ) {
if ( $source eq $fw ) {
fatal_error 'Rules with SOURCE $FW must use the OUTPUT chain' if $designator && $designator != OUTPUT;
$chain = OUTPUT;
if ( $designator ) {
fatal_error 'Rules with SOURCE $FW must use the OUTPUT chain' unless $designator & ( OUTPUT | REALOUTPUT );
$chain = $designator;
} else {
$chain = OUTPUT;
}
$source = '-';
} elsif ( $source =~ s/^($fw):// ) {
fatal_error 'Rules with SOURCE $FW must use the OUTPUT chain' if $designator && $designator != OUTPUT;
$chain = OUTPUT;
if ( $designator ) {
fatal_error 'Rules with SOURCE $FW must use the OUTPUT chain' unless $designator & ( OUTPUT | REALOUTPUT );
$chain = $designator;
} else {
$chain = OUTPUT;
}
}
}
@@ -4953,11 +4980,11 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
} else {
$resolve_chain->();
fatal_error "$cmd rules are not allowed in the $chainlabels{$chain} chain" unless $commandref->{allowedchains} & $chain;
unless ( $chain == OUTPUT || $chain == POSTROUTING ) {
unless ( $chain & ( OUTPUT | POSTROUTING | REALOUTPUT | REALPOSTROUTING ) ) {
fatal_error 'A USER/GROUP may only be specified when the SOURCE is $FW' unless $user eq '-';
}
$chainref = ensure_chain( 'mangle', $chainnames{$chain} );
$chainref = ensure_chain( $table, $chainnames{$chain} );
}
$restriction |= $chainref->{restriction};
@@ -5547,6 +5574,15 @@ sub process_snat1( $$$$$$$$$$$$ ) {
$chainref = $interface ? ensure_chain('nat', $pre_nat ? snat_chain $interface : masq_chain $interface) : $nat_table->{INPUT};
}
if ( $chainref->{complete} ) {
if ( $interface ) {
warning_message( "Interface $interface entry generated no $toolname rule" );
} else {
warning_message( "Entry generated no $toolname rule" );
}
next;
}
$baserule .= do_condition( $condition , $chainref->{name} );
#
# Handle IPSEC options, if any
@@ -5851,23 +5887,15 @@ sub process_snat( )
}
#
# Process the masq or snat file
# Process the snat file. Convert the masq file if found and non-empty
#
sub setup_snat( $ ) # Convert masq->snat if true
sub setup_snat()
{
my $fn;
my $have_masq;
if ( $_[0] ) {
convert_masq();
} elsif ( $fn = open_file( 'masq', 1, 1 ) ) {
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , "a non-empty masq file" , 's'; } );
process_one_masq(0), $have_masq = 1 while read_a_line( NORMAL_READ );
}
unless ( $have_masq ) {
unless ( convert_masq ) {
#
# Masq file empty or didn't exist
# Masq file was empty or didn't exist
#
if ( $fn = open_file( 'snat', 1, 1 ) ) {
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , "a non-empty snat file" , 's'; } );

View File

@@ -1,5 +1,5 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Tc.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Tc.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#

View File

@@ -1,5 +1,5 @@
#
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/Tunnels.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Tunnels.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)

View File

@@ -1,9 +1,9 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Zones.pm
# Shorewall 5.2 -- /usr/share/shorewall/Shorewall/Zones.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2010,2011-2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -222,6 +222,9 @@ use constant { IN_OUT => 1,
IN => 2,
OUT => 3 };
#
# Zone types
#
use constant { FIREWALL => 1,
IP => 2,
BPORT => 4,
@@ -231,6 +234,9 @@ use constant { FIREWALL => 1,
LOCAL => 64,
};
#
# Interface option classification
#
use constant { SIMPLE_IF_OPTION => 1,
BINARY_IF_OPTION => 2,
ENUM_IF_OPTION => 3,
@@ -247,11 +253,17 @@ use constant { SIMPLE_IF_OPTION => 1,
IF_OPTION_WILDOK => 64
};
#
# 'ignore' option flags
#
use constant { NO_UPDOWN => 1,
NO_SFILTER => 2 };
our %validinterfaceoptions;
#
# Interface options that are implemented in /proc
#
our %procinterfaceoptions=( accept_ra => 1,
arp_filter => 1,
arp_ignore => 1,
@@ -263,6 +275,9 @@ our %procinterfaceoptions=( accept_ra => 1,
sourceroute => 1,
);
#
# Options that are not allowed with unmanaged interfaces
#
our %prohibitunmanaged = (
blacklist => 1,
bridge => 1,
@@ -281,10 +296,15 @@ our %prohibitunmanaged = (
upnp => 1,
upnpclient => 1,
);
#
# Default values for options that admit an optional value
#
our %defaultinterfaceoptions = ( routefilter => 1 , wait => 60, accept_ra => 1 , ignore => 3, routeback => 1 );
our %maxoptionvalue = ( routefilter => 2, mss => 100000 , wait => 120 , ignore => NO_UPDOWN | NO_SFILTER, accept_ra => 2 );
#
# Maximum value for options that accept a range of values
#
our %maxoptionvalue = ( routefilter => 2, mss => 100000 , wait => 300 , ignore => NO_UPDOWN | NO_SFILTER, accept_ra => 2 );
our %validhostoptions;
@@ -701,7 +721,7 @@ sub determine_zones()
}
#
# Return true of we have any ipsec zones
# Return true If we have any ipsec zones
#
sub haveipseczones() {
for my $zoneref ( values %zones ) {
@@ -872,6 +892,9 @@ sub single_interface( $ ) {
@keys == 1 ? $keys[0] : '';
}
#
# This function adds an interface:network pair to a zone
#
sub add_group_to_zone($$$$$$)
{
my ($zone, $type, $interface, $networks, $options, $inherit_options) = @_;
@@ -976,6 +999,9 @@ sub find_zone( $ ) {
$zoneref;
}
#
# Access functions for zone members
#
sub zone_type( $ ) {
find_zone( $_[0] )->{type};
}
@@ -990,26 +1016,44 @@ sub zone_mark( $ ) {
$zoneref->{mark};
}
#
# Returns the zone table entry for the passed zone name
#
sub defined_zone( $ ) {
$zones{$_[0]};
}
#
# Returns a list of all defined zones
#
sub all_zones() {
@zones;
}
#
# Returns a list of zones in the firewall itself (the firewall zone and vserver zones)
#
sub on_firewall_zones() {
grep ( ( $zones{$_}{type} & ( FIREWALL | VSERVER ) ) , @zones );
}
#
# Returns a list of zones excluding the firewall and vserver zones
#
sub off_firewall_zones() {
grep ( ! ( $zones{$_}{type} & ( FIREWALL | VSERVER ) ) , @zones );
}
#
# Returns a list of zones excluding the firewall zones
#
sub non_firewall_zones() {
grep ( ! ( $zones{$_}{type} & FIREWALL ) , @zones );
}
#
# Returns the list of zones that don't contain sub-zones
#
sub all_parent_zones() {
#
# Although the firewall zone is technically a parent zone, we let the caller decide
@@ -1018,22 +1062,37 @@ sub all_parent_zones() {
grep ( ! @{$zones{$_}{parents}} , off_firewall_zones );
}
#
# Returns a list of complex zones (ipsec or with multiple interface:subnets)
#
sub complex_zones() {
grep( $zones{$_}{complex} , @zones );
}
#
# Returns a list of vserver zones
#
sub vserver_zones() {
grep ( $zones{$_}{type} & VSERVER, @zones );
}
#
# Returns the name of the firewall zone
#
sub firewall_zone() {
$firewall_zone;
}
#
# Returns a list of loopback zones
#
sub loopback_zones() {
@loopback_zones;
}
#
# Returns a list of local zones
#
sub local_zones() {
@local_zones;
}

View File

@@ -32,7 +32,6 @@
# --directory=<directory> # Directory where configuration resides (default is /etc/shorewall)
# --timestamp # Timestamp all progress messages
# --debug # Print stack trace on warnings and fatal error.
# --refresh=<chainlist> # Make the 'refresh' command refresh a comma-separated list of chains rather than 'blacklst'.
# --log=<filename> # Log file
# --log_verbosity=<number> # Log Verbosity range -1 to 2
# --family=<number> # IP family; 4 = IPv4 (default), 6 = IPv6
@@ -63,7 +62,6 @@ usage: compiler.pl [ <option> ... ] [ <filename> ]
[ --timestamp ]
[ --debug ]
[ --confess ]
[ --refresh=<chainlist> ]
[ --log=<filename> ]
[ --log-verbose={-1|0-2} ]
[ --test ]
@@ -88,7 +86,6 @@ my $verbose = 0;
my $timestamp = 0;
my $debug = 0;
my $confess = 0;
my $chains = ':none:';
my $log = '';
my $log_verbose = 0;
my $help = 0;
@@ -114,8 +111,6 @@ my $result = GetOptions('h' => \$help,
'timestamp' => \$timestamp,
't' => \$timestamp,
'debug' => \$debug,
'r=s' => \$chains,
'refresh=s' => \$chains,
'log=s' => \$log,
'l=s' => \$log,
'log_verbosity=i' => \$log_verbose,
@@ -143,7 +138,6 @@ compiler( script => $ARGV[0] || '',
timestamp => $timestamp,
debug => $debug,
export => $export,
chains => $chains,
log => $log,
log_verbosity => $log_verbose,
test => $test,

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# The Shoreline Firewall Packet Filtering Firewall Param File Helper - V4.4
# The Shoreline Firewall Packet Filtering Firewall Param File Helper - V5.2
#
# (c) 2010,2011,2014 - Tom Eastep (teastep@shorewall.net)
#

View File

@@ -1,4 +1,4 @@
# (c) 1999-2018 - Tom Eastep (teastep@shorewall.net)
# (c) 1999-2019 - Tom Eastep (teastep@shorewall.net)
#
# This program is part of Shorewall.
#
@@ -601,26 +601,29 @@ interface_enabled() {
}
distribute_load() {
local provider
local interface
local currentload # Total load of enabled interfaces
local load # Specified load of an enabled interface
local mark # Mark of an enabled interface
local totalload # Total load of all interfaces - usually 1.000000
local nload # Normalized load of an enabled interface
local var # Interface name to embed in a variable name
local currentload # Total load of enabled providers
local load # Specified load of an enabled provider
local mark # Mark of an enabled provider
local totalload # Total load of all providers - usually 1.000000
local nload # Normalized load of an enabled provider
totalload=$1
shift
currentload=0
for interface in $@; do
for provider in $@; do
interface=$(cat ${VARDIR}/${provider}_interface)
eval ${provider}_interface=$interface
if interface_enabled $interface; then
var=$(echo $interface | sed 's/[.-]/_/g')
load=$(cat ${VARDIR}/${interface}_load)
eval ${var}_load=$load
mark=$(cat ${VARDIR}/${interface}_mark)
eval ${var}_mark=$mark
load=$(cat ${VARDIR}/${provider}_load)
eval ${provider}_load=$load
mark=$(cat ${VARDIR}/${provider}_mark)
eval ${provider}_mark=$mark
currentload=$( bc <<EOF
scale=8
$currentload + $load
@@ -630,12 +633,13 @@ EOF
done
if [ $currentload ]; then
for interface in $@; do
qt $g_tool -t mangle -F ~$interface
for provider in $@; do
eval interface=\$${provider}_interface
var=$(echo $interface | sed 's/[.-]/_/g')
eval load=\$${var}_load
eval mark=\$${var}_mark
qt $g_tool -t mangle -F ~$provider
eval load=\$${provider}_load
eval mark=\$${provider}_mark
if [ -n "$load" ]; then
nload=$(bc <<EOF
@@ -651,10 +655,10 @@ EOF
case $nload in
.*|0.*)
run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $nload -j MARK --set-mark $mark
run_iptables -t mangle -A ~$provider -m statistic --mode random --probability $nload -j MARK --set-mark $mark
;;
*)
run_iptables -t mangle -A ~$interface -j MARK --set-mark $mark
run_iptables -t mangle -A ~$provider -j MARK --set-mark $mark
;;
esac
fi
@@ -675,7 +679,7 @@ interface_is_usable() # $1 = interface
status=0
if ! loopback_interface $1; then
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != 0.0.0.0 ]; then
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != 0.0.0.0 ] && [ -z "$($IP -$g_family link list dev $1 2> /dev/null | fgrep 'state DOWN')" ]; then
if [ "$COMMAND" != enable ]; then
[ ! -f ${VARDIR}/${1}_disabled ] && run_isusable_exit $1
status=$?
@@ -893,6 +897,14 @@ detect_dynamic_gateway() { # $1 = interface
fi
done
if [ -z "$gateway" -a -n "$(mywhich nmcli)" ]; then
if [ $g_family = 4 ]; then
gateway=$(nmcli --fields DHCP4.OPTION,IP4.GATEWAY device show ${1} 2> /dev/null | sed -rn '/( routers = |IP4.GATEWAY:.*[1-9])/{s/.* //;p;q}')
else
gateway=$(nmcli --terse --fields IP6.GATEWAY device show ${1} 2> /dev/null | cut -f2- -d':')
fi
fi
[ -n "$gateway" ] && echo $gateway
}
@@ -959,7 +971,7 @@ add_gateway() # $1 = Delta $2 = Table Number
local delta
local dev
route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/default //; s/[\]//g'`
route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/default //; s/linkdown//g; s/[\]//g'`
if [ -z "$route" ]; then
run_ip route add default scope global table $2 $1
@@ -993,7 +1005,7 @@ delete_gateway() # $! = Description of the Gateway $2 = table number $3 = device
local gateway
local dev
route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/[\]//g'`
route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/linkdown//g; s/[\]//g'`
gateway=$1
if [ -n "$route" ]; then
@@ -1101,7 +1113,7 @@ interface_is_usable() # $1 = interface
status=0
if [ "$1" != lo ]; then
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != :: ]; then
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != :: ] && [ -z "$($IP -$g_family link list dev $1 2> /dev/null | fgrep 'state DOWN')" ]; then
if [ "$COMMAND" != enable ]; then
[ ! -f ${VARDIR}/${1}_disabled ] && run_isusable_exit $1
status=$?

View File

@@ -217,6 +217,8 @@ PERL_HASH_SEED=0
REJECT_ACTION=
RENAME_COMBINED=Yes
REQUIRE_INTERFACE=Yes
RESTART=restart

View File

@@ -228,6 +228,8 @@ PERL_HASH_SEED=0
REJECT_ACTION=
RENAME_COMBINED=Yes
REQUIRE_INTERFACE=No
RESTART=restart

View File

@@ -225,6 +225,8 @@ PERL_HASH_SEED=0
REJECT_ACTION=
RENAME_COMBINED=Yes
REQUIRE_INTERFACE=No
RESTART=restart

View File

@@ -228,6 +228,8 @@ PERL_HASH_SEED=0
REJECT_ACTION=
RENAME_COMBINED=Yes
REQUIRE_INTERFACE=No
RESTART=restart

View File

@@ -1,10 +0,0 @@
#
# Shorewall -- /etc/shorewall/masq
#
# For information about entries in this file, type "man shorewall-masq"
#
# The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-masq.html
#
###################################################################################################################################
#INTERFACE SOURCE ADDRESS PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY

View File

@@ -217,6 +217,8 @@ PERL_HASH_SEED=0
REJECT_ACTION=
RENAME_COMBINED=Yes
REQUIRE_INTERFACE=No
RESTART=restart

View File

@@ -67,5 +67,4 @@ loadmodule ipt_LOG
loadmodule nf_log_ipv4
loadmodule xt_LOG
loadmodule xt_NFLOG
loadmodule ipt_ULOG
loadmodule nfnetlink_log

117
Shorewall/init.alt.sh Executable file
View File

@@ -0,0 +1,117 @@
#!/bin/sh
#
# Shorewall init script
#
# chkconfig: - 28 90
# description: Packet filtering firewall
#
### BEGIN INIT INFO
# Provides: shorewall
# Required-Start: $local_fs $remote_fs $syslog $network
# Should-Start: $time $named
# Required-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Packet filtering firewall
# Description: The Shoreline Firewall, more commonly known as "Shorewall", is a
# Netfilter (iptables) based firewall
### END INIT INFO
# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1
# Source function library.
. /etc/init.d/functions
#
# The installer may alter this
#
. /usr/share/shorewall/shorewallrc
NAME="Shorewall firewall"
PROG="shorewall"
SHOREWALL="$SBINDIR/$PROG"
LOGGER="logger -i -t $PROG"
# Get startup options (override default)
OPTIONS=
SourceIfNotEmpty $SYSCONFDIR/$PROG
LOCKFILE=/var/lock/subsys/shorewall
RETVAL=0
start() {
action $"Applying $NAME rules:" "$SHOREWALL" "$OPTIONS" start "$STARTOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
return $RETVAL
}
stop() {
action $"Stoping $NAME :" "$SHOREWALL" "$OPTIONS" stop "$STOPOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
return $RETVAL
}
restart() {
action $"Restarting $NAME rules: " "$SHOREWALL" "$OPTIONS" restart "$RESTARTOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
return $RETVAL
}
reload() {
action $"Reloading $NAME rules: " "$SHOREWALL" "$OPTIONS" reload "$RELOADOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
return $RETVAL
}
clear() {
action $"Clearing $NAME rules: " "$SHOREWALL" "$OPTIONS" clear 2>&1 | "$LOGGER"
RETVAL=$?
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
clear)
clear
;;
condrestart)
if [ -e "$LOCKFILE" ]; then
restart
fi
;;
condreload)
if [ -e "$LOCKFILE" ]; then
restart
fi
;;
condstop)
if [ -e "$LOCKFILE" ]; then
stop
fi
;;
status)
"$SHOREWALL" status
RETVAL=$?
;;
*)
echo $"Usage: ${0##*/} {start|stop|restart|reload|clear|condrestart|condstop|status}"
RETVAL=1
esac
exit $RETVAL

View File

@@ -1,7 +1,7 @@
#!/bin/sh
RCDLINKS="2,S41 3,S41 6,K41"
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.2
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
#
# (c) 1999,2000,2001,2002,2003,2004,2005, 2014 - Tom Eastep (teastep@shorewall.net)
#

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.2
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#

View File

@@ -197,6 +197,9 @@ if [ -z "$BUILD" ]; then
opensuse)
BUILD=suse
;;
alt|basealt|altlinux)
BUILD=alt
;;
*)
BUILD="$ID"
;;
@@ -205,6 +208,8 @@ if [ -z "$BUILD" ]; then
BUILD=debian
elif [ -f /etc/gentoo-release ]; then
BUILD=gentoo
elif [ -f /etc/altlinux-release ]; then
BUILD=alt
elif [ -f /etc/redhat-release ]; then
BUILD=redhat
elif [ -f /etc/slackware-version ] ; then
@@ -269,6 +274,9 @@ case "$HOST" in
openwrt)
echo "Installing OpenWRT-specific configuration..."
;;
alt)
echo "Installing ALT-specific configuration...";
;;
linux)
;;
*)

View File

@@ -1,5 +1,5 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/lib.cli-std.
# Shorewall 5.2 -- /usr/share/shorewall/lib.cli-std
#
# (c) 1999-2018 - Tom Eastep (teastep@shorewall.net)
#
@@ -281,10 +281,18 @@ get_config() {
case $AUTOMAKE in
Yes|yes)
AUTOMAKE=1
;;
No|no)
AUTOMAKE=
;;
[1-9])
;;
[1-9][0-9])
;;
[Rr]ecursive)
AUTOMAKE=recursive
;;
*)
if [ -n "$AUTOMAKE" ]; then
fatal_error "Invalid AUTOMAKE setting ($AUTOMAKE)"
@@ -397,10 +405,22 @@ uptodate() {
#
# Busybox 'find' doesn't support -quit.
#
if [ -n "$(${find} ${dir} -maxdepth 1 -type f -newer $1 -print)" ]; then
if [ $AUTOMAKE = recursive ]; then
if [ -n "$(${find} ${dir} -newer $1 -print)" ]; then
return 1;
fi
elif [ -n "$(${find} ${dir} -maxdepth $AUTOMAKE -type f -newer $1 -print)" ]; then
return 1;
fi
elif [ -n "$(${find} ${dir} -maxdepth 1 -type f -newer $1 -print -quit)" ]; then
elif [ "$AUTOMAKE" = recursive ]; then
if [ -n "$(${find} ${dir} -newer $1 -print -quit)" ]; then
return 1;
fi
elif [ -z "$AUTOMAKE" ]; then
if [ -n "$(${find} ${dir} -maxdepth 1 -type f -newer $1 -print -quit)" ]; then
return 1;
fi
elif [ -n "$(${find} ${dir} -maxdepth $AUTOMAKE -type f -newer $1 -print -quit)" ]; then
return 1;
fi
done
@@ -436,6 +456,16 @@ compiler() {
ensure_root
#
# Let params and the compiler know the base configuration directory
#
if [ -n "$g_shorewalldir" ]; then
SW_CONFDIR="$g_shorewalldir"
else
SW_CONFDIR="$g_confdir"
fi
export SW_CONFDIR
#
# We've now set g_shorewalldir so recalculate CONFIG_PATH
#
[ -n "$g_haveconfig" ] || ensure_config_path
@@ -635,24 +665,24 @@ start_command() {
esac
if [ -n "${g_fast}${AUTOMAKE}" ]; then
if ! uptodate ${VARDIR}/firewall; then
if ! uptodate $g_firewall; then
g_fast=
AUTOMAKE=
fi
fi
if [ -n "$AUTOMAKE" ]; then
[ -n "$nolock" ] || mutex_on
run_it ${VARDIR}/firewall $g_debugging start
[ -n "$g_nolock" ] || mutex_on
run_it $g_firewall $g_debugging start
rc=$?
[ -n "$nolock" ] || mutex_off
[ -n "$g_nolock" ] || mutex_off
else
g_file="${VARDIR}/.start"
if compiler $g_debugging $nolock compile "$g_file"; then
[ -n "$nolock" ] || mutex_on
if compiler $g_debugging $g_nolock compile "$g_file"; then
[ -n "$g_nolock" ] || mutex_on
run_it ${VARDIR}/.start $g_debugging start
rc=$?
[ -n "$nolock" ] || mutex_off
[ -n "$g_nolock" ] || mutex_off
else
rc=$?
mylogger kern.err "ERROR:$g_product start failed"
@@ -724,7 +754,7 @@ compile_command() {
case $# in
0)
[ -n "$g_export" ] && g_file=firewall || g_file=${VARDIR}/firewall
[ -n "$g_export" ] && g_file=firewall || g_file=$g_firewall
;;
1)
g_file=$1
@@ -834,7 +864,7 @@ check_command() {
g_doing="Checking"
compiler $g_debugging $nolock check
compiler $g_debugging $g_nolock check
}
#
@@ -925,7 +955,7 @@ update_command() {
g_doing="Updating"
compiler $g_debugging $nolock check
compiler $g_debugging $g_nolock check
}
#
@@ -1021,32 +1051,67 @@ restart_command() {
[ -n "$STARTUP_ENABLED" ] || not_configured_error "Startup is disabled"
if [ -z "$g_fast" -a -n "$AUTOMAKE" ]; then
uptodate ${VARDIR}/firewall && g_fast=Yes
uptodate $g_firewall && g_fast=Yes
fi
g_file="${VARDIR}/.${COMMAND}"
if [ -z "$g_fast" ]; then
if compiler $g_debugging $nolock compile "$g_file"; then
[ -n "$nolock" ] || mutex_on
if compiler $g_debugging $g_nolock compile "$g_file"; then
[ -n "$g_nolock" ] || mutex_on
run_it ${VARDIR}/.${COMMAND} $g_debugging ${COMMAND}
rc=$?
[ -n "$nolock" ] || mutex_off
[ -n "$g_nolock" ] || mutex_off
else
rc=$?
mylogger kern.err "ERROR:$g_product ${COMMAND} failed"
fi
else
[ -x ${VARDIR}/firewall ] || fatal_error "No ${VARDIR}/firewall file found"
[ -n "$nolock" ] || mutex_on
run_it ${VARDIR}/firewall $g_debugging $COMMAND
[ -x $g_firewall ] || fatal_error "No $g_firewall file found"
[ -n "$g_nolock" ] || mutex_on
run_it $g_firewall $g_debugging $COMMAND
rc=$?
[ -n "$nolock" ] || mutex_off
[ -n "$g_nolock" ] || mutex_off
fi
return $rc
}
read_yesno_with_timeout() {
local timeout
timeout=${1:-60}
case $timeout in
*s)
;;
*m)
timeout=$((${timeout%m} * 60))
;;
*h)
timeout=$((${timeout%h} * 3600))
;;
esac
read -t $timeout yn 2> /dev/null
if [ $? -eq 2 ]
then
# read doesn't support timeout
test -x /bin/bash || return 2 # bash is not installed so the feature is not available
/bin/bash -c "read -t $timeout yn ; if [ \"\$yn\" == \"y\" ] ; then exit 0 ; else exit 1 ; fi" # invoke bash and use its version of read
return $?
else
# read supports timeout
case "$yn" in
y|Y)
return 0
;;
*)
return 1
;;
esac
fi
}
#
# Safe-start/safe-reload/safe-restart Command Executor
#
@@ -1169,7 +1234,7 @@ safe_commands() {
;;
esac
[ -n "$nolock" ] || mutex_on
[ -n "$g_nolock" ] || mutex_on
if run_it ${VARDIR}/.$command $g_debugging $command; then
@@ -1184,7 +1249,7 @@ safe_commands() {
run_it ${VARDIR}/.$command clear
fi
[ -n "$nolock" ] || mutex_off
[ -n "$g_nolock" ] || mutex_off
echo "New configuration has been rejected and the old one restored"
exit 2
@@ -1192,7 +1257,7 @@ safe_commands() {
fi
[ -n "$nolock" ] || mutex_off
[ -n "$g_nolock" ] || mutex_off
}
#
@@ -1282,7 +1347,7 @@ try_command() {
g_file="${VARDIR}/.$command"
if ! compiler $g_debugging $nolock compile "$g_file"; then
if ! compiler $g_debugging $g_nolock compile "$g_file"; then
status=$?
exit $status
fi
@@ -1302,7 +1367,7 @@ try_command() {
;;
esac
[ -n "$nolock" ] || mutex_on
[ -n "$g_nolock" ] || mutex_on
if run_it ${VARDIR}/.$command $g_debugging $command && [ -n "$timeout" ]; then
sleep $timeout
@@ -1314,7 +1379,7 @@ try_command() {
fi
fi
[ -n "$nolock" ] || mutex_off
[ -n "$g_nolock" ] || mutex_off
return 0
}
@@ -1332,10 +1397,163 @@ rcp_command() {
eval $RCP_COMMAND
}
#
# Remote-{getcaps|getrc} command executer
#
remote_capture() # $* = original arguments less the command.
{
local verbose
verbose=$(make_verbose)
local finished
finished=0
local system
local getrc
getrc=
local getcaps
getcaps=
local remote_sw_dir_path
remote_sw_dir_path=
local root
root=root
local libexec
libexec=${LIBEXECDIR}
while [ $finished -eq 0 -a $# -gt 0 ]; do
option=$1
case $option in
-*)
option=${option#-}
while [ -n "$option" ]; do
case $option in
-)
finished=1
option=
;;
R*)
getrc=Yes
option=${option#R}
;;
c*)
getcaps=Yes
option=${option#c}
;;
r)
[ $# -gt 1 ] || fatal_error "Missing Root User name"
root=$2
option=
shift
;;
D)
[ $# -gt 1 ] || fatal_error "Missing directory name"
g_shorewalldir=$2
option=
shift
;;
p)
[ $# -gt 1 ] || fatal_error "Missing directory name"
remote_sw_dir_path=$2
option=
shift
;;
T*)
g_confess=Yes
option=${option#T}
;;
*)
option_error $option
;;
esac
done
shift
;;
*)
finished=1
;;
esac
done
case $# in
0)
[ -n "$g_shorewalldir" ] || g_shorewalldir='.'
;;
1)
g_shorewalldir="."
system=$1
;;
2)
g_shorewalldir=$1
system=$2
;;
*)
too_many_arguments $3
;;
esac
g_export=Yes
ensure_config_path
get_config Yes
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
case $COMMAND in
remote-getrc)
getrc=Yes
;;
remote-getcaps)
getcaps=Yes
;;
esac
[ -n "$getcaps" ] && getrc=Yes
if [ -n "$getrc" -o ! -s $g_shorewalldir/shorewallrc ]; then
progress_message2 "Getting shorewallrc file on system $system..."
if [ -n "$remote_sw_dir_path" ]; then
if ! rsh_command "/sbin/shorewall-lite show rc $remote_sw_dir_path" > $g_shorewalldir/shorewallrc; then
fatal_error "Capturing RC file on system $system failed"
fi
elif ! rsh_command "/sbin/shorewall-lite show rc" > $g_shorewalldir/shorewallrc; then
fatal_error "Capturing RC file on system $system failed"
fi
fi
remote_sw_dir_path=
if [ -n "$getcaps" -o ! -s $g_shorewalldir/capabilities ]; then
if [ -f $g_shorewalldir/shorewallrc -a -s $g_shorewalldir/shorewallrc ]; then
. $g_shorewalldir/shorewallrc
libexec="$LIBEXECDIR"
[ -n "$DONT_LOAD" ] && DONT_LOAD="$(echo $DONT_LOAD | tr ',' ' ')"
progress_message2 "Getting Capabilities on system $system..."
if [ $g_family -eq 4 ]; then
if ! rsh_command "MODULESDIR=$MODULESDIR IPTABLES=$IPTABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall-lite/shorecap" > $g_shorewalldir/capabilities; then
fatal_error "Capturing capabilities on system $system failed"
fi
elif ! rsh_command "MODULESDIR=$MODULESDIR IP6TABLES=$IP6TABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall6-lite/shorecap" > $g_shorewalldir/capabilities; then
fatal_error "Capturing capabilities on system $system failed"
fi
else
fatal_error "$g_shorewalldir/shorewallrc is not present."
fi
fi
}
#
# Remote-{start|reload|restart} command executor
#
remote_reload_command() # $* = original arguments less the command.
remote_commands() # $* = original arguments less the command.
{
local verbose
verbose=$(make_verbose)
@@ -1448,34 +1666,26 @@ remote_reload_command() # $* = original arguments less the command.
g_export=Yes
if [ -f $g_shorewalldir/${PRODUCT}.conf ]; then
if [ -f $g_shorewalldir/params ]; then
. $g_shorewalldir/params
fi
ensure_config_path
ensure_config_path
get_config Yes
get_config No
g_haveconfig=Yes
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/$PRODUCT.conf does not exist"
if [ -z "$system" ]; then
system=$FIREWALL
[ -n "$system" ] || fatal_error "No system name given and the FIREWALL option is not set"
fi
if [ -z "$getcaps" ]; then
capabilities=$(find_file capabilities)
[ -f $capabilities ] || getcaps=Yes
[ ! -f $capabilities -o ! -s $capabilities ] && getcaps=Yes
fi
if [ -n "$getcaps" ]; then
[ -n "$DONT_LOAD" ] && DONT_LOAD="$(echo $DONT_LOAD | tr ',' ' ')"
progress_message "Getting Capabilities on system $system..."
progress_message2 "Getting Capabilities on system $system..."
if [ $g_family -eq 4 ]; then
if ! rsh_command "MODULESDIR=$MODULESDIR IPTABLES=$IPTABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall-lite/shorecap" > $g_shorewalldir/capabilities; then
fatal_error "Capturing capabilities on system $system failed"
@@ -1491,6 +1701,7 @@ remote_reload_command() # $* = original arguments less the command.
#
# Handle nonstandard remote VARDIR
#
progress_message3 "Getting VARDIR on system $system..."
temp=$(rsh_command $program show config 2> /dev/null | grep ^LITEDIR | sed 's/LITEDIR is //')
[ -n "$temp" ] && litedir="$temp"
@@ -1631,11 +1842,11 @@ export_command() # $* = original arguments less the command.
}
run_command() {
if [ -x ${VARDIR}/firewall ] ; then
uptodate ${VARDIR}/firewall || echo " WARNING: ${VARDIR}/firewall is not up to date" >&2
run_it ${VARDIR}/firewall $g_debugging $@
if [ -x $g_firewall ] ; then
uptodate $g_firewall || echo " WARNING: $g_firewall is not up to date" >&2
run_it $g_firewall $g_debugging $@
else
fatal_error "${VARDIR}/firewall does not exist or is not executable"
fatal_error "$g_firewall does not exist or is not executable"
fi
}
@@ -1656,7 +1867,7 @@ compiler_command() {
;;
remote-start|remote-reload|remote-restart)
shift
remote_reload_command $@
remote_commands $@
;;
export)
shift
@@ -1674,6 +1885,10 @@ compiler_command() {
shift
safe_commands $@
;;
remote-getrc|remote-getcaps)
shift
remote_capture $@
;;
*)
fatal_error "Invalid command: $COMMAND"
;;

View File

@@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<refentry>
<refmeta>
<refentrytitle>shorewall-addresses</refentrytitle>
<manvolnum>5</manvolnum>
<refmiscinfo>Configuration Files</refmiscinfo>
</refmeta>
<refnamediv>
<refname>addresses</refname>
<refpurpose>Specifying addresses within a Shorewall
configuration</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<para>In both Shorewall and Shorewall6, there are two basic types of
addresses:</para>
<variablelist>
<varlistentry>
<term>Host Address</term>
<listitem>
<para>This address type refers to a single host.</para>
<para>In IPv4, the format is <emphasis>i.j.k.l</emphasis> where
<emphasis>i</emphasis> through <emphasis>l</emphasis> are decimal
numbers between 1 and 255.</para>
<para>In IPv6, the format is <emphasis>a:b:c:d:e:f:g:h</emphasis>
where <emphasis>a</emphasis> through <emphasis>h</emphasis> consist
of 1 to 4 hexadecimal digits (leading zeros may be omitted). a
single series of 0 addresses may be omitted. For example
2001:227:e857:1:0:0:0:0:1 may be written 2001:227:e857:1::1.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Network Address</term>
<listitem>
<para>A network address refers to 1 or more hosts and consists of a
host address followed by a slash ("/") and a <firstterm>Variable
Length Subnet Mask</firstterm> (VLSM). This is known as
<firstterm>Classless Internet Domain Routing</firstterm> (CIDR)
notation.</para>
<para>The VLSM is a decimal number. For IPv4, it is in the range 0
through 32. For IPv6, the range is 0 through 128. The number
represents the number of leading bits in the address that represent
the network address; the remainder of the bits are a host address
and are generally given as zero.</para>
<para>Examples:</para>
<para>IPv4: 192.168.1.0/24</para>
<para>IPv6: 2001:227:e857:1:0:0:0:0:1/64</para>
</listitem>
</varlistentry>
</variablelist>
<para>In the Shorewall documentation and manpages, we have tried to make
it clear which type of address is accepted in each specific case.</para>
<para>Because Shorewall uses a colon (":") as a separator in many
contexts, IPv6 addresses are best written using the standard convention in
which the address itself is enclosed in square brackets:</para>
<simplelist>
<member>[2001:227:e857:1::1]</member>
<member>[2001:227:e857:1::]/64</member>
</simplelist>
</refsect1>
<refsect1>
<title>Specifying SOURCE and DEST</title>
<para>Entries in Shorewall configuration files often deal with the source
(SOURCE) and destination (DEST) of connections and Shorewall implements a
uniform way for specifying them.</para>
<para>A SOURCE or DEST consists of one to three parts separated by colons
(":"):</para>
<orderedlist>
<listitem>
<para>ZONE — The name of a zone declared in
<filename>/etc/shorewall/zones</filename> or
<filename>/etc/shorewall6/zones</filename>. This part is only
available in the rules file
(<filename>/etc/shorewall/rules</filename>,
<filename>/etc/shorewall/blrules</filename>,<filename>
/etc/shorewall6/rules</filename> and
<filename>/etc/shorewall6/blrules</filename>).</para>
</listitem>
<listitem>
<para>INTERFACE — The name of an interface that matches an entry in
<filename>/etc/shorewall/interfaces</filename>
(<filename>/etc/shorewall6/interfaces</filename>).</para>
<para>Beginning with Shorweall 5.2.1, the
<replaceable>interface</replaceable> may be preceded with '!' which
matches all interfaces except the one specified.</para>
</listitem>
<listitem>
<para>ADDRESS LIST — A list of one or more addresses (host or network)
or address ranges, separated by commas. In an IPv6 configuration, this
list must be included in square or angled brackets ("[...]" or
"&lt;...&gt;"). The list may have exclusion.</para>
</listitem>
</orderedlist>
<para>Examples.</para>
<orderedlist>
<listitem>
<para>All hosts in the <emphasis role="bold">net</emphasis> zone —
<emphasis role="bold">net</emphasis></para>
</listitem>
<listitem>
<para>Subnet 192.168.1.0/29 in the <emphasis
role="bold">loc</emphasis> zone — <emphasis
role="bold">loc:192.168.1.0/29</emphasis></para>
</listitem>
<listitem>
<para>All hosts in the net zone connecting through <filename
class="devicefile">ppp0</filename><emphasis
role="bold">net:ppp0</emphasis></para>
</listitem>
<listitem>
<para>All hosts interfaced by <filename
class="devicefile">eth3</filename><emphasis
role="bold">eth3</emphasis></para>
</listitem>
<listitem>
<para>Subnet 10.0.1.0/24 interfacing through <filename><filename
class="devicefile">eth2</filename></filename><emphasis
role="bold">eth2:10.0.1.0/24</emphasis></para>
</listitem>
<listitem>
<para>Host 2002:ce7c:92b4:1:a00:27ff:feb1:46a9 in the <emphasis
role="bold">loc</emphasis> zone — <emphasis
role="bold">loc:[2002:ce7c:92b4:1:a00:27ff:feb1:46a9]</emphasis></para>
</listitem>
<listitem>
<para>The primary IP address of eth0 in the $FW zone - <emphasis
role="bold">$FW:&amp;eth0</emphasis></para>
</listitem>
<listitem>
<para>All hosts in Vatican City - <emphasis
role="bold">net:^VA</emphasis> (Requires the <emphasis>GeoIP
Match</emphasis> capability).</para>
</listitem>
</orderedlist>
</refsect1>
<refsect1>
<title>IP Address Ranges</title>
<para>If you kernel and iptables have <emphasis>IP Range match
support</emphasis>, you may use IP address ranges in Shorewall
configuration file entries; IP address ranges have the syntax
&lt;<emphasis>low IP address</emphasis>&gt;-&lt;<emphasis>high IP
address</emphasis>&gt;.</para>
<para>Example: 192.168.1.5-192.168.1.12.</para>
</refsect1>
<refsect1>
<title/>
<para/>
</refsect1>
<refsect1>
<title>See ALSO</title>
<para>For more information about addressing, see the<ulink
url="shorewall_setup_guide.htm#Addressing"> Setup Guide</ulink>.</para>
</refsect1>
</refentry>

View File

@@ -280,9 +280,9 @@
<term>IPv4 Example 1:</term>
<listitem>
<para>Drop Teredo packets from the net.</para>
<para>Drop 6to4 packets from the net.</para>
<programlisting>DROP net:[2001::/32] all</programlisting>
<programlisting>DROP net:192.88.99.1 all</programlisting>
</listitem>
</varlistentry>
@@ -290,10 +290,10 @@
<term>IPv4 Example 2:</term>
<listitem>
<para>Don't subject packets from 2001:DB8::/64 to the remaining
<para>Don't subject packets from 70.90.191.120/29 to the remaining
rules in the file.</para>
<programlisting>WHITELIST net:[2001:DB8::/64] all</programlisting>
<programlisting>WHITELIST net:70.90.191.120/29 all</programlisting>
</listitem>
</varlistentry>

View File

@@ -84,7 +84,7 @@
role="bold">CT</emphasis>:<emphasis
role="bold">helper</emphasis>:<replaceable>name</replaceable>[(<replaceable>arg</replaceable>=<replaceable>val</replaceable>[,...])|<emphasis
role="bold">CT:ctevents:<replaceable>event</replaceable>[,...]|CT:expevents:new</emphasis><emphasis
role="bold">|CT:notrack</emphasis>|DROP|LOG|ULOG(<replaceable>ulog-parameters</replaceable>):NFLOG(<replaceable>nflog-parameters</replaceable>)|IPTABLES(<replaceable>target</replaceable>)}[<replaceable>log-level</replaceable>[:<replaceable>log-tag</replaceable>]][:<replaceable>chain-designator</replaceable>]</term>
role="bold">|CT:notrack</emphasis>|DROP|LOG|ULOG(<replaceable>ulog-parameters</replaceable>):NFLOG(<replaceable>nflog-parameters</replaceable>)|IP[6]TABLES(<replaceable>target</replaceable>)}[<replaceable>log-level</replaceable>[:<replaceable>log-tag</replaceable>]][:<replaceable>chain-designator</replaceable>]</term>
<listitem>
<para>This column is only present when FORMAT &gt;= 2. Values other
@@ -272,9 +272,32 @@
will also be logged at that level.</para>
</listitem>
<listitem>
<para><option>IP6TABLES</option>(<replaceable>target</replaceable>)</para>
<para>IPv6 only.</para>
<para>Added in Shorewall 4.6.0. Allows you to specify any
iptables <replaceable>target</replaceable> with target options
(e.g., "IP6TABLES(AUDIT --type drop)"). If the target is not one
recognized by Shorewall, the following error message will be
issued:</para>
<simplelist>
<member>ERROR: Unknown target
(<replaceable>target</replaceable>)</member>
</simplelist>
<para>This error message may be eliminated by adding
<replaceable>target</replaceable> as a builtin action in <ulink
url="/manpages/shorewall-actions.html">shorewall-actions</ulink>(5).</para>
</listitem>
<listitem>
<para><option>IPTABLES</option>(<replaceable>target</replaceable>)</para>
<para>IPv4 only.</para>
<para>Added in Shorewall 4.6.0. Allows you to specify any
iptables <replaceable>target</replaceable> with target options
(e.g., "IPTABLES(AUDIT --type drop)"). If the target is not one

View File

@@ -0,0 +1,967 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<refentry>
<refmeta>
<refentrytitle>shorewall-files</refentrytitle>
<manvolnum>5</manvolnum>
<refmiscinfo>Configuration Files</refmiscinfo>
</refmeta>
<refnamediv>
<refname>files</refname>
<refpurpose>Shorewall Configuration Files</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>/etc/shorewall[6]/*</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>The following are the Shorewall[6] configuration files:</para>
<itemizedlist>
<listitem>
<para><ulink
url="shorewall.conf.html"><filename>/etc/shorewall/shorewall.conf</filename>
and <filename>/etc/shorewall6/shorewall6.conf</filename></ulink> -
used to set global firewall parameters.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-params.html">/etc/shorewall[6]/params</ulink></filename>
- use this file to set shell variables that you will expand in other
files. It is always processed by /bin/sh or by the shell specified
through SHOREWALL_SHELL in
<filename>/etc/shorewall/shorewall.conf.</filename></para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-zones.html">/etc/shorewall[6]/zones</ulink></filename>
- partition the firewall's view of the world into zones.</para>
</listitem>
<listitem>
<para><ulink
url="shorewall-policy.html"><filename>/etc/shorewall[6]/policy</filename></ulink>
- establishes firewall high-level policy.</para>
</listitem>
<listitem>
<para><filename>/etc/shorewall[6]/initdone</filename> - An optional
Perl script that will be invoked by the Shorewall rules compiler when
the compiler has finished it's initialization.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-interfaces.html">/etc/shorewall[6]/interfaces</ulink></filename>
- describes the interfaces on the firewall system.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-hosts.html">/etc/shorewall[6]/hosts</ulink></filename>
- allows defining zones in terms of individual hosts and
subnetworks.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-masq.html">/etc/shorewall[6]/masq</ulink></filename> -
directs the firewall where to use many-to-one (dynamic) Network
Address Translation (a.k.a. Masquerading) and Source Network Address
Translation (SNAT). Superseded by /etc/shorewall[6]/snat in Shorewall
5.0.14 and not supported in Shorewall 5.1.0 and later versions.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-mangle.html">/etc/shorewall[6]/mangle</ulink></filename>
- supersedes <filename>/etc/shorewall/tcrules</filename> in Shorewall
4.6.0. Contains rules for packet marking, TTL, TPROXY, etc.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-rules.html">/etc/shorewall[6]/rules</ulink></filename>
- defines rules that are exceptions to the overall policies
established in /etc/shorewall/policy.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-nat.html">/etc/shorewall[6]/nat</ulink></filename> -
defines one-to-one NAT rules.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-proxyarp.html">/etc/shorewall6/proxyarp</ulink></filename>
- defines use of Proxy ARP.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-proxyndp.html">/etc/shorewall6/proxyndp</ulink></filename>
- defines use of Proxy NDP.</para>
</listitem>
<listitem>
<para><filename>/etc/shorewall[6]/routestopped</filename> - defines
hosts accessible when Shorewall is stopped. Superseded in Shorewall
4.6.8 by <filename>/etc/shorewall/stoppedrules</filename>. Not
supported in Shorewall 5.0.0 and later versions.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-tcrules.html">/etc/shorewall[6]/tcrules</ulink>
</filename>- The file has a rather unfortunate name because it is used
to define marking of packets for later use by both traffic
control/shaping and policy routing. This file is superseded by
<filename>/etc/shorewall/mangle</filename> in Shorewall 4.6.0. Not
supported in Shorewall 5.0.0 and later releases.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-tos.html">/etc/shorewall[6]/tos</ulink></filename> -
defines rules for setting the TOS field in packet headers. Superseded
in Shorewall 4.5.1 by the TOS target in
<filename>/etc/shorewall/tcrules</filename> (which file has since been
superseded by <filename>/etc/shorewall/mangle</filename>). Not
supported in Shorewall 5.0.0 and later versions.</para>
</listitem>
<listitem>
<para><ulink
url="shorewall-tunnels.html"><filename>/etc/shorewall[6]/tunnels</filename></ulink>
- defines tunnels (VPN) with end-points on the firewall system.</para>
</listitem>
<listitem>
<para><ulink
url="shorewall-blacklist.html"><filename>/etc/shorewall[6]/blacklist</filename></ulink>
- Deprecated in favor of <filename>/etc/shorewall/blrules</filename>.
Lists blacklisted IP/subnet/MAC addresses. Not supported in Shorewall
5.0.0 and later releases.</para>
</listitem>
<listitem>
<para><filename>/etc/shorewall[6]/blrules</filename> — Added in
Shorewall 4.5.0. Define blacklisting and whitelisting. Supersedes
<filename>/etc/shorewall/blacklist</filename>.</para>
</listitem>
<listitem>
<para><filename>/etc/shorewall[6]/init</filename> - shell commands
that you wish to execute at the beginning of a <quote>shorewall
start</quote>, "shorewall reload" or <quote>shorewall
restart</quote>.</para>
</listitem>
<listitem>
<para><filename>/etc/shorewall[6]/start</filename> - shell commands
that you wish to execute near the completion of a <quote>shorewall
start</quote>, "shorewall reload" or <quote>shorewall
restart</quote></para>
</listitem>
<listitem>
<para><filename>/etc/shorewall[6]/started</filename> - shell commands
that you wish to execute after the completion of a <quote>shorewall
start</quote>, "shorewall reload" or <quote>shorewall
restart</quote></para>
</listitem>
<listitem>
<para><filename>/etc/shorewall[6]/stop </filename>- commands that you
wish to execute at the beginning of a <quote>shorewall
stop</quote>.</para>
</listitem>
<listitem>
<para><filename>/etc/shorewall[6]/stopped</filename> - shell commands
that you wish to execute at the completion of a <quote>shorewall
stop</quote>.</para>
</listitem>
<listitem>
<para><ulink url="shorewall-ecn.html">/etc/shorewall/ecn</ulink> -
disable Explicit Congestion Notification (ECN - RFC 3168) to remote
hosts or networks. Superseded by ECN entries in
<filename>/etc/shorewall/mangle</filename> in Shorewall 5.0.6.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-accounting.html">/etc/shorewall/accounting</ulink></filename>
- define IP traffic accounting rules</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-actions.html">/etc/shorewall[6]/actions</ulink></filename>
and <filename>/usr/share/shorewall[6]/action.template</filename> allow
user-defined actions.</para>
</listitem>
<listitem>
<para><filename><ulink
url="???">/etc/shorewall[6]/providers</ulink></filename> - defines
alternate routing tables.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-rtrules.html">/etc/shorewall[6]/rtrules</ulink></filename>
- Defines routing rules to be used in conjunction with the routing
tables defined in
<filename>/etc/shorewall/providers</filename>.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-tcdevices.html">/etc/shorewall[6]/tcdevices</ulink></filename>,
<filename><ulink
url="shorewall-tcclasses.html">/etc/shorewall[6]/tcclasses</ulink></filename>,
<filename><ulink
url="shorewall-tcfilters.html">/etc/shorewall[6]/tcfilters</ulink></filename>
- Define complex traffic shaping.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-tcrules.html">/etc/shorewall[6]/tcrules</ulink></filename>
- Mark or classify traffic for traffic shaping or multiple providers.
Deprecated in Shorewall 4.6.0 in favor of
<filename>/etc/shorewall/mangle</filename>. Not supported in Shorewall
5.0.0 and later releases.</para>
</listitem>
<listitem>
<para><ulink
url="shorewall-tcinterfaces.html"><filename>/etc/shorewall[6]/tcinterfaces</filename></ulink>
and <filename><ulink
url="shorewall-tcpri.html">/etc/shorewall[6]/tcpri</ulink></filename>
- Define simple traffic shaping.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-secmarks.html">/etc/shorewall[6]/secmarks</ulink></filename>
- Added in Shorewall 4.4.13. Attach an SELinux context to selected
packets.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-vardir.html">/etc/shorewall[6]/vardir</ulink></filename>
- Determines the directory where Shorewall maintains its state.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-arprules.html">/etc/shorewall/arprules</ulink></filename>
— Added in Shorewall 4.5.12. Allows specification of arptables
rules.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-mangle.html">/etc/shorewall/mangle</ulink></filename>
-- Added in Shorewall 4.6.0. Supersedes<filename>
/etc/shorewall/tcrules</filename>.</para>
</listitem>
<listitem>
<para><filename><ulink
url="shorewall-snat.html">/etc/shorewall[6]/snat</ulink></filename> -
directs the firewall where to use many-to-one (dynamic) Network
Address Translation (a.k.a. Masquerading) and Source Network Address
Translation (SNAT). Superseded /etc/shorewall[6]/masq in Shorewall
5.0.14</para>
</listitem>
<listitem>
<para><filename>/usr/share/shorewall[6]/actions.std</filename> -
Actions defined by Shorewall.</para>
</listitem>
<listitem>
<para><filename>/usr/share/shorewall[6]/action.*</filename> - Details
of actions defined by Shorewall.</para>
</listitem>
<listitem>
<para><filename>/usr/share/shorewall[6]/macro.*</filename> - Details
of macros defined by Shorewall.</para>
</listitem>
<listitem>
<para><filename>/usr/share/shorewall[6]/modules</filename> — Specifies
the kernel modules to be loaded during shorewall start/restart.</para>
</listitem>
<listitem>
<para><filename>/usr/share/shorewall[6]/helpers</filename> — Added in
Shorewall 4.4.7. Specifies the kernel modules to be loaded during
shorewall start/restart when LOAD_HELPERS_ONLY=Yes in
<filename>shorewall.conf</filename>.</para>
</listitem>
</itemizedlist>
</refsect1>
<refsect1>
<title>CONFIG_PATH</title>
<para>The CONFIG_PATH option in <ulink
url="???">shorewall[6].conf(5)</ulink> determines where the compiler
searches for configuration files. The default setting is
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall which means that the
compiler first looks in /etc/shorewall and if it doesn't find the file, it
then looks in /usr/share/shorewall.</para>
<para>You can change this setting to have the compiler look in different
places. For example, if you want to put your own versions of standard
macros in /etc/shorewall/Macros, then you could set
CONFIG_PATH=/etc/shorewall:/etc/shorewall/Macros:/usr/share/shorewall and
the compiler will use your versions rather than the standard ones.</para>
</refsect1>
<refsect1>
<title>Comments</title>
<para>You may place comments in configuration files by making the first
non-whitespace character a pound sign (<quote>#</quote>). You may also
place comments at the end of any line, again by delimiting the comment
from the rest of the line with a pound sign.</para>
<example id="comment">
<title>Comments in a Configuration File</title>
<programlisting># This is a comment
ACCEPT net $FW tcp www #This is an end-of-line comment</programlisting>
</example>
<important>
<para>Except in <ulink
url="shorewall.conf.html">shorewall.conf(5)</ulink> and <ulink
url="shorewall-params.html">params(5)</ulink>, if a comment ends with a
backslash ("\"), the next line will also be treated as a comment. See
<link linkend="Continuation">Line Continuation</link> below.</para>
</important>
</refsect1>
<refsect1>
<title>Blank Lines</title>
<para>Most of the configuration files are organized into space-separated
columns. If you don't want to supply a value in a column but want to
supply a value in a following column, simply enter '-' to make the column
appear empty.</para>
<para>Example:<programlisting>#INTERFACE BROADCAST OPTIONS
br0 - routeback</programlisting></para>
</refsect1>
<refsect1>
<title id="Continuation">Line Continuation</title>
<para>Lines may be continued using the usual backslash (<quote>\</quote>)
followed immediately by a new line character (Enter key).</para>
<programlisting>ACCEPT net $FW tcp \↵
smtp,www,pop3,imap #Services running on the firewall</programlisting>
<important>
<para>What follows does NOT apply to <ulink
url="manpages/shorewall-params.html">shorewall-params(5)</ulink> and
<ulink url="shorewall.conf.html">shorewall.conf(5)</ulink>.</para>
</important>
<para>In certain cases, leading white space is ignored in continuation
lines:</para>
<orderedlist>
<listitem>
<para>The continued line ends with a colon (":")</para>
</listitem>
<listitem>
<para>The continued line ends with a comma (",")</para>
</listitem>
</orderedlist>
<para>Example (<filename>/etc/shorewall/rules</filename>):</para>
<programlisting>#ACTION SOURCE DEST PROTO DPORT
ACCEPT net:\
206.124.146.177,\
206.124.146.178,\
206.124.146.180\
dmz tcp 873</programlisting>
<para>The leading white space on the first through third continuation
lines is ignored so the SOURCE column effectively contains
"net:206.124.146.177,206.124.147.178,206.124.146.180". Because the third
continuation line does not end with a comma or colon, the leading white
space in the last line is not ignored.</para>
<important>
<para>A trailing backslash is not ignored in a comment. So the continued
rule above can be commented out with a single '#' as follows:</para>
<programlisting>#ACTION SOURCE DEST PROTO DPORT
<emphasis role="bold">#</emphasis>ACCEPT net:\
206.124.146.177,\
206.124.146.178,\
206.124.146.180\
dmz tcp 873</programlisting>
</important>
</refsect1>
<refsect1>
<title>Alternative Specification of Column Values</title>
<para>Some of the configuration files now have a large number of columns.
That makes it awkward to specify a value for one of the right-most columns
as you must have the correct number of intervening '-' columns.</para>
<para>This problem is addressed by allowing column values to be specified
as <replaceable>column-name</replaceable>/<replaceable>value</replaceable>
pairs.</para>
<para>There is considerable flexibility in how you specify the
pairs:</para>
<itemizedlist>
<listitem>
<para>At any point, you can enter a left curly bracket ('{') followed
by one or more specifications of the following forms:</para>
<simplelist>
<member><replaceable>column-name</replaceable>=<replaceable>value</replaceable></member>
<member><replaceable>column-name</replaceable>=<replaceable>&gt;value</replaceable></member>
<member><replaceable>column-name</replaceable>:<replaceable>value</replaceable></member>
</simplelist>
<para>The pairs must be followed by a right curly bracket
("}").</para>
<para>The value may optionally be enclosed in double quotes.</para>
<para>The pairs must be separated by white space, but you can add a
comma adjacent to the <replaceable>values</replaceable> for
readability as in:</para>
<simplelist>
<member><emphasis role="bold">{ proto=&gt;udp, port=1024
}</emphasis></member>
</simplelist>
</listitem>
<listitem>
<para>You can also separate the pairs from columns by using a
semicolon:</para>
<simplelist>
<member><emphasis role="bold">; proto:udp,
port:1024</emphasis></member>
</simplelist>
</listitem>
</itemizedlist>
<para>In Shorewall 5.0.3, the sample configuration files and the man pages
were updated to use the same column names in both the column headings and
in the alternate specification format. The following table shows the
column names for each of the table-oriented configuration files.</para>
<note>
<para>Column names are <emphasis
role="bold">case-insensitive</emphasis>.</para>
</note>
<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry><emphasis role="bold">File</emphasis></entry>
<entry><emphasis role="bold">Column names</emphasis></entry>
</row>
<row>
<entry>accounting</entry>
<entry>action,chain, source, dest, proto, dport, sport, user,
mark, ipsec, headers</entry>
</row>
<row>
<entry>conntrack</entry>
<entry>action,source,dest,proto,dport,sport,user,switch</entry>
</row>
<row>
<entry>blacklist</entry>
<entry>networks,proto,port,options</entry>
</row>
<row>
<entry>blrules</entry>
<entry>action,source,dest,proto,dport,sport,origdest,rate,user,mark,connlimit,time,headers,switch,helper</entry>
</row>
<row>
<entry>ecn</entry>
<entry>interface,hosts. Beginning with Shorewall 4.5.4, 'host' is
a synonym for 'hosts'.</entry>
</row>
<row>
<entry>hosts</entry>
<entry>zone,hosts,options. Beginning with Shorewall 4.5.4, 'host'
is a synonym for 'hosts'.</entry>
</row>
<row>
<entry>interfaces</entry>
<entry>zone,interface,broadcast,options</entry>
</row>
<row>
<entry>maclist</entry>
<entry>disposition,interface,mac,addresses</entry>
</row>
<row>
<entry>mangle</entry>
<entry>action,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headers</entry>
</row>
<row>
<entry>masq</entry>
<entry>interface,source,address,proto,port,ipsec,mark,user,switch</entry>
</row>
<row>
<entry>nat</entry>
<entry>external,interface,internal,allints,local</entry>
</row>
<row>
<entry>netmap</entry>
<entry>type,net1,interface,net2,net3,proto,dport,sport</entry>
</row>
<row>
<entry>notrack</entry>
<entry>source,dest,proto,dport,sport,user</entry>
</row>
<row>
<entry>policy</entry>
<entry>source,dest,policy,loglevel,limit,connlimit</entry>
</row>
<row>
<entry>providers</entry>
<entry>table,number,mark,duplicate,interface,gateway,options,copy</entry>
</row>
<row>
<entry>proxyarp and proxyndp</entry>
<entry>address,interface,external,haveroute,persistent</entry>
</row>
<row>
<entry>rtrules</entry>
<entry>source,dest,provider,priority</entry>
</row>
<row>
<entry>routes</entry>
<entry>provider,dest,gateway,device</entry>
</row>
<row>
<entry>routestopped</entry>
<entry>interface,hosts,options,proto,dport,sport</entry>
</row>
<row>
<entry>rules</entry>
<entry>action,source,dest,proto,dport,sport,origdest,rate,user,mark,connlimit,time,headers,switch,helper</entry>
</row>
<row>
<entry>secmarks</entry>
<entry>secmark,chain,source,dest,proto,dport,sport,user,mark</entry>
</row>
<row>
<entry>tcclasses</entry>
<entry>interface,mark,rate,ceil,prio,options</entry>
</row>
<row>
<entry>tcdevices</entry>
<entry>interface,in_bandwidth,out_bandwidth,options,redirect</entry>
</row>
<row>
<entry>tcfilters</entry>
<entry>class,source,dest,proto,dport,sport,tos,length</entry>
</row>
<row>
<entry>tcinterfaces</entry>
<entry>interface,type,in_bandwidth,out_bandwidth</entry>
</row>
<row>
<entry>tcpri</entry>
<entry>band,proto,port,address,interface,helper</entry>
</row>
<row>
<entry>tcrules</entry>
<entry>mark,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headers.
Beginning with Shorewall 4.5.3, 'action' is a synonym for
'mark'.</entry>
</row>
<row>
<entry>tos</entry>
<entry>source,dest,proto,dport,sport,tos,mark</entry>
</row>
<row>
<entry>tunnels</entry>
<entry>type,zone,gateway,gateway_zone. Beginning with Shorewall
4.5.3, 'gateways' is a synonym for 'gateway'. Beginning with
Shorewall 4.5.4, 'gateway_zones' is a synonym for
'gateway_zone'.</entry>
</row>
<row>
<entry>zones</entry>
<entry>zone,type,options,in_options,out_options</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>Example (rules file):</para>
<programlisting>#ACTION SOURCE DEST PROTO DPORT
DNAT net loc:10.0.0.1 tcp 80 ; mark="88"</programlisting>
<para>Here's the same line in several equivalent formats:</para>
<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>
</refsect1>
<refsect1>
<title>Time Columns</title>
<para>Several of the files include a TIME column 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>
</refsect1>
<refsect1>
<title>Switches</title>
<para>here are times when you would like to enable or disable one or more
rules in the configuration without having to do a <command>shorewall
reload</command> or <command>shorewall restart</command>. This may be
accomplished using the SWITCH column in <ulink
url="manpages/shorewall-rules.html">shorewall-rules</ulink> (5) or <ulink
url="manpages6/shorewall6-rules.html">shorewall6-rules</ulink> (5). Using
this column requires that your kernel and iptables include
<firstterm>Condition Match Support</firstterm> and you must be running
Shorewall 4.4.24 or later. See the output of <command>shorewall show
capabilities</command> and <command>shorewall version</command> to
determine if you can use this feature.</para>
<para>The SWITCH column contains the name of a
<firstterm>switch.</firstterm> Each switch is initially in the <emphasis
role="bold">off</emphasis> position. You can turn on the switch named
<emphasis>switch1</emphasis> by:</para>
<simplelist>
<member><command>echo 1 &gt;
/proc/net/nf_condition/switch1</command></member>
</simplelist>
<para>You can turn it off again by:</para>
<simplelist>
<member><command>echo 0 &gt;
/proc/net/nf_condition/switch1</command></member>
</simplelist>
<para>If you simply include the switch name in the SWITCH column, then the
rule is enabled only when the switch is <emphasis
role="bold">on</emphasis>. If you precede the switch name with ! (e.g.,
!switch1), then the rule is enabled only when the switch is <emphasis
role="bold">off</emphasis>. Switch settings are retained over
<command>shorewall restart</command>.</para>
<para>Shorewall requires that switch names:</para>
<itemizedlist>
<listitem>
<para>begin with a letter and be composed of letters, digits,
underscore ('_') or hyphen ('-'); and</para>
</listitem>
<listitem>
<para>be 30 characters or less in length.</para>
</listitem>
</itemizedlist>
<para>Multiple rules can be controlled by the same switch.</para>
<para>Example:</para>
<blockquote>
<para>Forward port 80 to dmz host $BACKUP if switch 'primary_down' is
on.</para>
<programlisting>#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH
DNAT net dmz:$BACKUP tcp 80 - - - - - - - - <emphasis
role="bold">primary_down</emphasis> </programlisting>
</blockquote>
</refsect1>
<refsect1>
<title>FILES</title>
<para>/etc/shorewall[6]/*</para>
</refsect1>
</refentry>

View File

@@ -90,8 +90,44 @@
<para>INPUT chain.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>NP</term>
<listitem>
<para>PREROUTING chain in the nat table.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>NI</term>
<listitem>
<para>INPUT chain in the nat table.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>NO</term>
<listitem>
<para>OUTPUT chain in the nat table.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>NT</term>
<listitem>
<para>POSTROUTING chain in the nat table.</para>
</listitem>
</varlistentry>
</variablelist>
<para>The nat table designators were added in Shorewall 5.2.1. When
a nat table designator is given, only the CONNMARK, MARK, SAVE and
RESTORE commands may be used.</para>
<para>Unless otherwise specified for the particular
<replaceable>command</replaceable>, the default chain is PREROUTING
when MARK_IN_FORWARD_CHAIN=No in <ulink
@@ -396,12 +432,6 @@ INLINE(MARK(2)):P eth0 - ;; -p tcp
INLINE eth0 - tcp 22 ;; -j MARK --set-mark 2
INLINE eth0 - ;; -p tcp -j MARK --set-mark 2
</programlisting>
<para>If INLINE_MATCHES=Yes in <ulink
url="/manpages/shorewall.conf.html">shorewall6.conf(5)</ulink>
then the third rule above can be specified as follows:</para>
<programlisting>MARK(2):P eth0 - ;; -p tcp</programlisting>
</listitem>
</varlistentry>
@@ -513,12 +543,39 @@ INLINE eth0 - ;; -p tcp -j MARK --se
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">IP6TABLES({<replaceable>target</replaceable>
[<replaceable>option</replaceable> ...])</emphasis></term>
<listitem>
<para>IPv6 only.</para>
<para>This action allows you to specify an iptables target
with options (e.g., 'IP6TABLES(MARK --set-xmark 0x01/0xff)'.
If the target is not one recognized by Shorewall, the
following error message will be issued:</para>
<simplelist>
<member>ERROR: Unknown target
(<replaceable>target</replaceable>)</member>
</simplelist>
<para>This error message may be eliminated by adding the
<replaceable>target</replaceable> as a builtin action in
<ulink
url="/manpages/shorewall-actions.html">shorewall-actions(5)</ulink>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">IPTABLES({<replaceable>target</replaceable>
[<replaceable>option</replaceable> ...])</emphasis></term>
<listitem>
<para>IPv4 only.</para>
<para>This action allows you to specify an iptables target
with options (e.g., 'IPTABLES(MARK --set-xmark 0x01/0xff)'. If
the target is not one recognized by Shorewall, the following
@@ -800,15 +857,20 @@ Normal-Service =&gt; 0x00</programlisting>
<variablelist>
<varlistentry>
<term><replaceable>interface</replaceable></term>
<term>[!]<replaceable>interface</replaceable></term>
<listitem>
<para>where <replaceable>interface</replaceable> is the
logical name of an interface defined in <ulink
logical name of an <replaceable>interface</replaceable>
defined in <ulink
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>(5).
Matches packets entering the firewall from the named
interface. May not be used in CLASSIFY rules or in rules using
the :T chain qualifier.</para>
<para>Beginning with Shorweall 5.2.1, the
<replaceable>interface</replaceable> may be preceded with '!'
which matches all interfaces except the one specified.</para>
</listitem>
</varlistentry>
@@ -842,23 +904,31 @@ Normal-Service =&gt; 0x00</programlisting>
</varlistentry>
<varlistentry>
<term><replaceable>interface</replaceable>:<replaceable>address</replaceable>,[...][<replaceable>exclusion</replaceable>]</term>
<term>[!]<replaceable>interface</replaceable>:<replaceable>address</replaceable>,[...][<replaceable>exclusion</replaceable>]</term>
<listitem>
<para>This form combines the preceding two forms and matches
when both the incoming interface and source IP address
match.</para>
<para>Beginning with Shorweall 5.2.1, the
<replaceable>interface</replaceable> may be preceded with '!'
which matches all interfaces except the one specified.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>interface</replaceable>:<replaceable>exclusion</replaceable></term>
<term>[!]<replaceable>interface</replaceable>:<replaceable>exclusion</replaceable></term>
<listitem>
<para>This form matches packets arriving through the named
<replaceable>interface</replaceable> and whose source IP
address does not match any of the addresses in the
<replaceable>exclusion</replaceable>.</para>
<para>Beginning with Shorweall 5.2.1, the
<replaceable>interface</replaceable> may be preceded with '!'
which matches all interfaces except the one specified.</para>
</listitem>
</varlistentry>

View File

@@ -1,781 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<refentry>
<refmeta>
<refentrytitle>shorewall-masq</refentrytitle>
<manvolnum>5</manvolnum>
<refmiscinfo>Configuration Files</refmiscinfo>
</refmeta>
<refnamediv>
<refname>masq</refname>
<refpurpose>Shorewall Masquerade/SNAT definition file</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>/etc/shorewall[6]/masq</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>This file is used to define dynamic NAT (Masquerading) and to define
Source NAT (SNAT). While still supported, its use is deprecated in favor
of <ulink url="shorewall-snat.html">shorewall-snat</ulink>(5) which was
introduced in Shorewall 5.0.14.</para>
<warning>
<para>The entries in this file are order-sensitive. The first entry that
matches a particular connection will be the one that is used.</para>
</warning>
<warning>
<para>If you have more than one ISP link, adding entries to this file
will <emphasis role="bold">not</emphasis> force connections to go out
through a particular link. You must use entries in <ulink
url="/manpages/shorewall-rtrules.html">shorewall-rtrules</ulink>(5) or
PREROUTING entries in <ulink
url="/manpages/shorewall-mangle.html">shorewall-mangle</ulink>(5) to do
that.</para>
</warning>
<para>The columns in the file are as follows.</para>
<variablelist>
<varlistentry>
<term><emphasis role="bold">INTERFACE:DEST</emphasis> - {[<emphasis
role="bold">+</emphasis>]<emphasis>interfacelist</emphasis>[<emphasis
role="bold">:</emphasis>[<emphasis>digit</emphasis>]][<emphasis
role="bold">:</emphasis>[<emphasis>dest-address</emphasis>[<emphasis
role="bold">,</emphasis><emphasis>dest-address</emphasis>]...[<emphasis>exclusion</emphasis>]]|?COMMENT}</term>
<listitem>
<para>Outgoing <emphasis>interfacelist</emphasis>. This may be a
comma-separated list of interface names. This is usually your
internet interface. If ADD_SNAT_ALIASES=Yes in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5), you
may add ":" and a <emphasis>digit</emphasis> to indicate that you
want the alias added with that name (e.g., eth0:0). This will allow
the alias to be displayed with ifconfig. <emphasis role="bold">That
is the only use for the alias name; it may not appear in any other
place in your Shorewall configuration.</emphasis></para>
<para>Each interface must match an entry in <ulink
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>(5).
Shorewall allows loose matches to wildcard entries in <ulink
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>(5).
For example, <filename class="devicefile">ppp0</filename> in this
file will match a <ulink
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>(5)
entry that defines <filename
class="devicefile">ppp+</filename>.</para>
<para>Where <ulink url="/4.4/MultiISP.html#Shared">more that one
internet provider share a single interface</ulink>, the provider is
specified by including the provider name or number in
parentheses:</para>
<programlisting> eth0(Avvanta)</programlisting>
<para>In that case, you will want to specify the interface's address
for that provider in the ADDRESS column.</para>
<para>The interface may be qualified by adding the character ":"
followed by a comma-separated list of destination host or subnet
addresses to indicate that you only want to change the source IP
address for packets being sent to those particular destinations.
Exclusion is allowed (see <ulink
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5))
as are ipset names preceded by a plus sign '+';</para>
<para>If you wish to inhibit the action of ADD_SNAT_ALIASES for this
entry then include the ":" but omit the digit:</para>
<programlisting> eth0(Avvanta):
eth2::192.0.2.32/27</programlisting>
<para>Normally Masq/SNAT rules are evaluated after those for
one-to-one NAT (defined in <ulink
url="/manpages/shorewall-nat.html">shorewall-nat</ulink>(5)). If you
want the rule to be applied before one-to-one NAT rules, prefix the
interface name with "+":</para>
<programlisting> +eth0
+eth0:192.0.2.32/27
+eth0:2</programlisting>
<para>This feature should only be required if you need to insert
rules in this file that preempt entries in <ulink
url="/manpages/shorewall-nat.html">shorewall-nat</ulink>(5).</para>
<para>Comments may be attached to Netfilter rules generated from
entries in this file through the use of ?COMMENT lines. These lines
begin with ?COMMENT; the remainder of the line is treated as a
comment which is attached to subsequent rules until another ?COMMENT
line is found or until the end of the file is reached. To stop
adding comments to rules, use a line containing only
?COMMENT.</para>
<para>Beginning with Shorewall 4.6.0, a new syntax is also accepted.
With the exception of the leading '+', the interfacelist and
qualifiers may appear within the parentheses of <emphasis
role="bold">INLINE</emphasis>(...).</para>
<para>Example:</para>
<programlisting> +INLINE(eth0)</programlisting>
<para>When this is done, you may augment the rule generated by
Shorewall with iptables matches of your own. These matches appear
after a semicolon (';') at the end of the line.</para>
<para>See example 8 below.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">SOURCE</emphasis> (Formerly called SUBNET
- Optional) -
[<emphasis>interface</emphasis>|<emphasis>address</emphasis>[<emphasis
role="bold">,</emphasis><emphasis>address</emphasis>][<emphasis>exclusion</emphasis>]]</term>
<listitem>
<para>Set of hosts that you wish to masquerade. You can specify this
as an <emphasis>address</emphasis> (net or host) or as an
<emphasis>interface</emphasis> (use of an
<emphasis>interface</emphasis> is deprecated). If you give the name
of an interface, the interface must be up before you start the
firewall and the Shorewall rules compiler will warn you of that
fact. (Shorewall will use your main routing table to determine the
appropriate addresses to masquerade).</para>
<para>The preferred way to specify the SOURCE is to supply one or
more host or network addresses separated by comma. You may use ipset
names preceded by a plus sign (+) to specify a set of hosts.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">ADDRESS</emphasis> (Optional) - [<emphasis
role="bold">-</emphasis>|<emphasis
role="bold">NONAT</emphasis>|[<emphasis>address-or-address-range</emphasis>][:<emphasis>lowport</emphasis><emphasis
role="bold">-</emphasis><emphasis>highport</emphasis>][<emphasis
role="bold">:random</emphasis>][:persistent]|<emphasis
role="bold">detect</emphasis>|<emphasis
role="bold">random</emphasis>]</term>
<listitem>
<para>If you specify an address here, SNAT will be used and this
will be the source address. If ADD_SNAT_ALIASES is set to Yes or yes
in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5) then
Shorewall will automatically add this address to the INTERFACE named
in the first column.</para>
<para>You may also specify a range of up to 256 IP addresses if you
want the SNAT address to be assigned from that range in a
round-robin fashion by connection. The range is specified by
<emphasis>first.ip.in.range</emphasis>-<emphasis>last.ip.in.range</emphasis>.
You may follow the port range with<emphasis role="bold">
:random</emphasis> in which case assignment of ports from the list
will be random. <emphasis role="bold">random</emphasis> may also be
specified by itself in this column in which case random local port
assignments are made for the outgoing connections.</para>
<para>Example: 206.124.146.177-206.124.146.180</para>
<para>You may follow the port range (or <emphasis
role="bold">:random</emphasis>) with <emphasis
role="bold">:persistent</emphasis>. This is only useful when an
address range is specified and causes a client to be given the same
source/destination IP pair. This feature replaces the SAME modifier
which was removed from Shorewall in version 4.4.0. Unlike <emphasis
role="bold">random</emphasis>, <emphasis
role="bold">persistent</emphasis> may not be used by itself.</para>
<para>You may also use the special value "detect" which causes
Shorewall to determine the IP addresses configured on the interface
named in the INTERFACES column and substitute them in this
column.</para>
<para>Finally, you may also specify a comma-separated list of ranges
and/or addresses in this column.</para>
<para>This column may not contain DNS Names.</para>
<para>Normally, Netfilter will attempt to retain the source port
number. You may cause netfilter to remap the source port by
following an address or range (if any) by ":" and a port range with
the format
<emphasis>lowport</emphasis>-<emphasis>highport</emphasis>. If this
is done, you must specify "tcp" or "udp" in the PROTO column.</para>
<para>Examples:</para>
<programlisting> 192.0.2.4:5000-6000
:4000-5000</programlisting>
<para>If you simply place <emphasis role="bold">NONAT</emphasis> in
this column, no rewriting of the source IP address or port number
will be performed. This is useful if you want particular traffic to
be exempt from the entries that follow in the file.</para>
<para>If you want to leave this column empty but you need to specify
the next column then place a hyphen ("-") here.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">PROTO</emphasis> (Optional) - {<emphasis
role="bold">-</emphasis>|[!]{<emphasis>protocol-name</emphasis>|<emphasis>protocol-number</emphasis>}[,...]|+<replaceable>ipset</replaceable>}</term>
<listitem>
<para>If you wish to restrict this entry to a particular protocol
then enter the protocol name (from protocols(5)) or number
here.</para>
<para>Beginning with Shorewall 4.5.12, this column can accept a
comma-separated list of protocols.</para>
<para>Beginning with Shorewall 4.6.0, an
<replaceable>ipset</replaceable> name can be specified in this
column. This is intended to be used with
<firstterm>bitmap:port</firstterm> ipsets.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">PORT</emphasis> (Optional) -
{-|[!]<emphasis>port-name-or-number</emphasis>[,<emphasis>port-name-or-number</emphasis>]...|+<replaceable>ipset</replaceable>}</term>
<listitem>
<para>If the PROTO column specifies TCP (6), UDP (17), DCCP (33),
SCTP (132) or UDPLITE (136) then you may list one or more port
numbers (or names from services(5)) or port ranges separated by
commas.</para>
<para>Port ranges are of the form
<emphasis>lowport</emphasis>:<emphasis>highport</emphasis>.</para>
<para>Beginning with Shorewall 4.6.0, an
<replaceable>ipset</replaceable> name can be specified in this
column. This is intended to be used with
<firstterm>bitmap:port</firstterm> ipsets.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">IPSEC</emphasis> (Optional) -
[<emphasis>option</emphasis>[<emphasis
role="bold">,</emphasis><emphasis>option</emphasis>]...]</term>
<listitem>
<para>If you specify a value other than "-" in this column, you must
be running kernel 2.6 and your kernel and iptables must include
policy match support.</para>
<para>Comma-separated list of options from the following. Only
packets that will be encrypted via an SA that matches these options
will have their source address changed.</para>
<variablelist>
<varlistentry>
<term><emphasis
role="bold">reqid=</emphasis><emphasis>number</emphasis></term>
<listitem>
<para>where <emphasis>number</emphasis> is specified using
setkey(8) using the 'unique:<emphasis>number</emphasis> option
for the SPD level.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">spi=</emphasis>&lt;number&gt;</term>
<listitem>
<para>where <emphasis>number</emphasis> is the SPI of the SA
used to encrypt/decrypt packets.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">proto=</emphasis><emphasis
role="bold">ah</emphasis>|<emphasis
role="bold">esp</emphasis>|<emphasis
role="bold">ipcomp</emphasis></term>
<listitem>
<para>IPSEC Encapsulation Protocol</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">mss=</emphasis><emphasis>number</emphasis></term>
<listitem>
<para>sets the MSS field in TCP packets</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">mode=</emphasis><emphasis
role="bold">transport</emphasis>|<emphasis
role="bold">tunnel</emphasis></term>
<listitem>
<para>IPSEC mode</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">tunnel-src=</emphasis><emphasis>address</emphasis>[/<emphasis>mask</emphasis>]</term>
<listitem>
<para>only available with mode=tunnel</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">tunnel-dst=</emphasis><emphasis>address</emphasis>[/<emphasis>mask</emphasis>]</term>
<listitem>
<para>only available with mode=tunnel</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">strict</emphasis></term>
<listitem>
<para>Means that packets must match all rules.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">next</emphasis></term>
<listitem>
<para>Separates rules; can only be used with strict</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">yes</emphasis></term>
<listitem>
<para>When used by itself, causes all traffic that will be
encrypted/encapsulated to match the rule.</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">MARK</emphasis> - [<emphasis
role="bold">!</emphasis>]<emphasis>value</emphasis>[/<emphasis>mask</emphasis>][<emphasis
role="bold">:C</emphasis>]</term>
<listitem>
<para>Defines a test on the existing packet or connection mark. The
rule will match only if the test returns true.</para>
<para>If you don't want to define a test but need to specify
anything in the following columns, place a "-" in this field.</para>
<variablelist>
<varlistentry>
<term>!</term>
<listitem>
<para>Inverts the test (not equal)</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis>value</emphasis></term>
<listitem>
<para>Value of the packet or connection mark.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis>mask</emphasis></term>
<listitem>
<para>A mask to be applied to the mark before testing.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">:C</emphasis></term>
<listitem>
<para>Designates a connection mark. If omitted, the packet
mark's value is tested.</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">USER</emphasis> (Optional) - [<emphasis
role="bold">!</emphasis>][<emphasis>user-name-or-number</emphasis>][<emphasis
role="bold">:</emphasis><emphasis>group-name-or-number</emphasis>][<emphasis
role="bold">+</emphasis><emphasis>program-name</emphasis>]</term>
<listitem>
<para>This column was formerly labelled USER/GROUP.</para>
<para>Only locally-generated connections will match if this column
is non-empty.</para>
<para>When this column is non-empty, the rule matches only if the
program generating the output is running under the effective
<emphasis>user</emphasis> and/or <emphasis>group</emphasis>
specified (or is NOT running under that id if "!" is given).</para>
<para>Examples:</para>
<variablelist>
<varlistentry>
<term>joe</term>
<listitem>
<para>program must be run by joe</para>
</listitem>
</varlistentry>
<varlistentry>
<term>:kids</term>
<listitem>
<para>program must be run by a member of the 'kids'
group</para>
</listitem>
</varlistentry>
<varlistentry>
<term>!:kids</term>
<listitem>
<para>program must not be run by a member of the 'kids'
group</para>
</listitem>
</varlistentry>
<varlistentry>
<term>+upnpd</term>
<listitem>
<para>#program named upnpd</para>
<important>
<para>The ability to specify a program name was removed from
Netfilter in kernel version 2.6.14.</para>
</important>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">SWITCH -
[!]<replaceable>switch-name</replaceable>[={0|1}]</emphasis></term>
<listitem>
<para>Added in Shorewall 4.5.1 and allows enabling and disabling the
rule without requiring <command>shorewall restart</command>.</para>
<para>The rule is enabled if the value stored in
<filename>/proc/net/nf_condition/<replaceable>switch-name</replaceable></filename>
is 1. The rule is disabled if that file contains 0 (the default). If
'!' is supplied, the test is inverted such that the rule is enabled
if the file contains 0.</para>
<para>Within the <replaceable>switch-name</replaceable>, '@0' and
'@{0}' are replaced by the name of the chain to which the rule is a
added. The <replaceable>switch-name</replaceable> (after '@...'
expansion) must begin with a letter and be composed of letters,
decimal digits, underscores or hyphens. Switch names must be 30
characters or less in length.</para>
<para>Switches are normally <emphasis role="bold">off</emphasis>. To
turn a switch <emphasis role="bold">on</emphasis>:</para>
<simplelist>
<member><command>echo 1 &gt;
/proc/net/nf_condition/<replaceable>switch-name</replaceable></command></member>
</simplelist>
<para>To turn it <emphasis role="bold">off</emphasis> again:</para>
<simplelist>
<member><command>echo 0 &gt;
/proc/net/nf_condition/<replaceable>switch-name</replaceable></command></member>
</simplelist>
<para>Switch settings are retained over <command>shorewall
restart</command>.</para>
<para>Beginning with Shorewall 4.5.10, when the
<replaceable>switch-name</replaceable> is followed by
<option>=0</option> or <option>=1</option>, then the switch is
initialized to off or on respectively by the
<command>start</command> command. Other commands do not affect the
switch setting.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">ORIGDEST</emphasis> - [<emphasis
role="bold">-</emphasis>|<emphasis>address</emphasis>[,<emphasis>address</emphasis>]...[<emphasis>exclusion</emphasis>]|<emphasis>exclusion</emphasis>]</term>
<listitem>
<para>(Optional) Added in Shorewall 4.5.6. This column may be
included and may contain one or more addresses (host or network)
separated by commas. Address ranges are not allowed. When this
column is supplied, rules are generated that require that the
original destination address matches one of the listed addresses. It
is useful for specifying that SNAT should occur only for connections
that were acted on by a DNAT when they entered the firewall.</para>
<para>This column was formerly labelled ORIGINAL DEST.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">PROBABILITY</emphasis> -
[<replaceable>probability</replaceable>]</term>
<listitem>
<para>Added in Shorewall 5.0.0. When non-empty, requires the
<firstterm>Statistics Match</firstterm> capability in your kernel
and ip6tables and causes the rule to match randomly but with the
given <replaceable>probability</replaceable>. The
<replaceable>probability</replaceable> is a number 0 &lt;
<replaceable>probability</replaceable> &lt;= 1 and may be expressed
at up to 8 decimal points of precision.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Examples</title>
<variablelist>
<varlistentry>
<term>IPv4 Example 1:</term>
<listitem>
<para>You have a simple masquerading setup where eth0 connects to a
DSL or cable modem and eth1 connects to your local network with
subnet 192.168.0.0/24.</para>
<para>Your entry in the file will be:</para>
<programlisting> #INTERFACE SOURCE
eth0 192.168.0.0/24</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>IPv4 Example 2:</term>
<listitem>
<para>You add a router to your local network to connect subnet
192.168.1.0/24 which you also want to masquerade. You then add a
second entry for eth0 to this file:</para>
<programlisting> #INTERFACE SOURCE
eth0 192.168.1.0/24</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>IPv4 Example 3:</term>
<listitem>
<para>You have an IPSEC tunnel through ipsec0 and you want to
masquerade packets coming from 192.168.1.0/24 but only if these
packets are destined for hosts in 10.1.1.0/24:</para>
<programlisting> #INTERFACE SOURCE
ipsec0:10.1.1.0/24 196.168.1.0/24</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>IPv4 Example 4:</term>
<listitem>
<para>You want all outgoing traffic from 192.168.1.0/24 through eth0
to use source address 206.124.146.176 which is NOT the primary
address of eth0. You want 206.124.146.176 to be added to eth0 with
name eth0:0.</para>
<programlisting> #INTERFACE SOURCE ADDRESS
eth0:0 192.168.1.0/24 206.124.146.176</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>IPv4 Example 5:</term>
<listitem>
<para>You want all outgoing SMTP traffic entering the firewall from
172.20.1.0/29 to be sent from eth0 with source IP address
206.124.146.177. You want all other outgoing traffic from
172.20.1.0/29 to be sent from eth0 with source IP address
206.124.146.176.</para>
<programlisting> #INTERFACE SOURCE ADDRESS PROTO DPORT
eth0 172.20.1.0/29 206.124.146.177 tcp smtp
eth0 172.20.1.0/29 206.124.146.176</programlisting>
<warning>
<para>The order of the above two rules is significant!</para>
</warning>
</listitem>
</varlistentry>
<varlistentry>
<term>IPv4 Example 6:</term>
<listitem>
<para>Connections leaving on eth0 and destined to any host defined
in the ipset <emphasis>myset</emphasis> should have the source IP
address changed to 206.124.146.177.</para>
<programlisting> #INTERFACE SOURCE ADDRESS
eth0:+myset[dst] - 206.124.146.177</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>IPv4 Example 7:</term>
<listitem>
<para>SNAT outgoing connections on eth0 from 192.168.1.0/24 in
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:
#ACTION SOURCE DEST PROTO DPORT SPORT USER TEST
1-3:CF 192.168.1.0/24 eth0 ; state=NEW
/etc/shorewall/masq:
#INTERFACE SOURCE ADDRESS ...
eth0 192.168.1.0/24 1.1.1.1 ; mark=1:C
eth0 192.168.1.0/24 1.1.1.3 ; mark=2:C
eth0 192.168.1.0/24 1.1.1.9 ; mark=3:C</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>IPv4 Example 8:</term>
<listitem>
<para>Your eth1 has two public IP addresses: 70.90.191.121 and
70.90.191.123. You want to use the iptables statistics match to
masquerade outgoing connections evenly between these two
addresses.</para>
<programlisting>/etc/shorewall/masq:
#INTERFACE SOURCE ADDRESS
INLINE(eth1) 0.0.0.0/0 70.90.191.121 ;; -m statistic --mode random --probability 0.50
eth1 0.0.0.0/0 70.90.191.123
</programlisting>
<para>If INLINE_MATCHES=Yes in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf(5)</ulink>, then
these rules may be specified as follows:</para>
<programlisting>/etc/shorewall/masq:
#INTERFACE SOURCE ADDRESS
eth1 0.0.0.0/0 70.90.191.121 ; -m statistic --mode random --probability 0.50
eth1 0.0.0.0/0 70.90.191.123
</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>IPv6 Example 1:</term>
<listitem>
<para>You have a simple 'masquerading' setup where eth0 connects to
a DSL or cable modem and eth1 connects to your local network with
subnet 2001:470:b:787::0/64</para>
<para>Your entry in the file will be:</para>
<programlisting> #INTERFACE SOURCE ADDRESS
eth0 2001:470:b:787::0/64 -</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>IPv6 Example 2:</term>
<listitem>
<para>Your sit1 interface has two public IP addresses:
2001:470:a:227::1 and 2001:470:b:227::1. You want to use the
iptables statistics match to masquerade outgoing connections evenly
between these two addresses.</para>
<programlisting>/etc/shorewall/masq:
#INTERFACE SOURCE ADDRESS
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
url="/manpages6/shorewall6.conf.html">shorewall6.conf</ulink>(5),
then these rules may be specified as follows:</para>
<programlisting>/etc/shorewall/masq:
#INTERFACE SOURCE ADDRESS
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>
</refsect1>
<refsect1>
<title>FILES</title>
<para>/etc/shorewall/masq</para>
<para>/etc/shorewall6/masq</para>
</refsect1>
<refsect1>
<title>See ALSO</title>
<para><ulink
url="/configuration_file_basics.htm#Pairs">http://www.shorewall.net/configuration_file_basics.htm#Pairs</ulink></para>
<para>shorewall(8)</para>
</refsect1>
</refentry>

View File

@@ -0,0 +1,310 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<refentry>
<refmeta>
<refentrytitle>shorewall-names</refentrytitle>
<manvolnum>5</manvolnum>
<refmiscinfo>Configuration Files</refmiscinfo>
</refmeta>
<refnamediv>
<refname>names</refname>
<refpurpose>Shorewall object names</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<para>When you define an object in Shorewall (<ulink
url="manpages/shorewall-zones.html">Zone</ulink>, <link
linkend="Logical">Logical Interface</link>, <ulink
url="ipsets.html">ipsets</ulink>, <ulink
url="Actions.html">Actions</ulink>, etc., you give it a name. Shorewall
names start with a letter and consist of letters, digits or underscores
("_"). Except for Zone names, Shorewall does not impose a limit on name
length.</para>
<para>When an ipset is referenced, the name must be preceded by a plus
sign ("+").</para>
<para>The last character of an interface may also be a plus sign to
indicate a wildcard name.</para>
<para>Physical interface names match names shown by 'ip link ls'; if the
name includes an at sign ("@"), do not include that character or any
character that follows. For example, "sit1@NONE" is referred to as simply
'sit1".</para>
</refsect1>
<refsect1>
<title>Zone and Chain Names</title>
<para>For a pair of zones, Shorewall creates two Netfilter chains; one for
connections in each direction. The names of these chains are formed by
separating the names of the two zones by either "2" or "-".</para>
<para>Example: Traffic from zone A to zone B would go through chain A2B
(think "A to B") or "A-B".</para>
<para>In Shorewall 4.6, the default separator is "-" but you can override
that by setting ZONE_SEPARATOR="2" in <ulink
url="manpages/shorewall.conf.html">shorewall.conf</ulink> (5).</para>
<note>
<para>Prior to Shorewall 4.6, the default separator was "2".</para>
</note>
<para>Zones themselves have names that begin with a letter and are
composed of letters, numerals, and "_". The maximum length of a name is
dependent on the setting of LOGFORMAT in <ulink
url="manpages/shorewall.conf.html">shorewall.conf</ulink> (5). See <ulink
url="manpages/shorewall-zones.html">shorewall-zones</ulink> (5) for
details.</para>
</refsect1>
<refsect1>
<title>Using DNS Names</title>
<caution>
<para>I personally recommend strongly against using DNS names in
Shorewall configuration files. If you use DNS names and you are called
out of bed at 2:00AM because Shorewall won't start as a result of DNS
problems then don't say that you were not forewarned.</para>
</caution>
<para>Host addresses in Shorewall configuration files may be specified as
either IP addresses or DNS Names.</para>
<para>DNS names in iptables rules aren't nearly as useful as they first
appear. When a DNS name appears in a rule, the iptables utility resolves
the name to one or more IP addresses and inserts those addresses into the
rule. So changes in the DNS-&gt;IP address relationship that occur after
the firewall has started have absolutely no effect on the firewall's rule
set.</para>
<para>For some sites, using DNS names is very risky. Here's an
example:</para>
<programlisting>teastep@ursa:~$ dig pop.gmail.com
; &lt;&lt;&gt;&gt; DiG 9.4.2-P1 &lt;&lt;&gt;&gt; pop.gmail.com
;; global options: printcmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 1774
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 7, ADDITIONAL: 0
;; QUESTION SECTION:
;pop.gmail.com. IN A
;; ANSWER SECTION:
pop.gmail.com. <emphasis role="bold">300</emphasis> IN CNAME gmail-pop.l.google.com.
gmail-pop.l.google.com. <emphasis role="bold">300</emphasis> IN A 209.85.201.109
gmail-pop.l.google.com. <emphasis role="bold">300</emphasis> IN A 209.85.201.111</programlisting>
<para>Note that the TTL is 300 -- 300 seconds is only 5 minutes. So five
minutes later, the answer may change!</para>
<para>So this rule may work for five minutes then suddently stop
working:</para>
<programlisting>#ACTION SOURCE DEST PROTO DPORT
POP(ACCEPT) loc net:pop.gmail.com</programlisting>
<para>There are two options in <ulink
url="manpages/shorewall.conf.html">shorewall[6].conf(5)</ulink> that
affect the use of DNS names in Shorewall[6] config files:</para>
<itemizedlist>
<listitem>
<para>DEFER_DNS_RESOLUTION - When set to No, DNS names are resolved at
compile time; when set to Yes, DNS Names are resolved at
runtime.</para>
</listitem>
<listitem>
<para>AUTOMAKE - When set to Yes, <command>start</command>,
<command>restart</command> and <command>reload</command> only result
in compilation if one of the files on the CONFIG_PATH has changed
since the the last compilation.</para>
</listitem>
</itemizedlist>
<para>So by setting AUTOMAKE=Yes, and DEFER_DNS_RESOLUTION=No, compilation
will only take place at boot time if a change had been make to the config
but no <command>restart</command> or <command>reload</command> had taken
place. This is clearly spelled out in the shorewall.conf manpage. So with
these settings, so long as a 'reload' or 'restart' takes place after the
Shorewall configuration is changes, there should be no DNS-related
problems at boot time.</para>
<important>
<para>When DEFER_DNS_RESOLUTION=No and AUTOMAKE=Yes and a DNS change
makes it necessary to recompile an existing firewall script, the
<option>-c</option> option must be used with the
<command>reload</command> or <command>restart</command> command to force
recompilation.</para>
</important>
<para>If your firewall rules include DNS names then, even if
DEFER_DNS_RESOLUTION=No and AUTOMAKE=Yes:</para>
<itemizedlist>
<listitem>
<para>If your <filename>/etc/resolv.conf </filename>is wrong then your
firewall may not start.</para>
</listitem>
<listitem>
<para>If your <filename>/etc/nsswitch.conf</filename> is wrong then
your firewall may not start.</para>
</listitem>
<listitem>
<para>If your Name Server(s) is(are) down then your firewall may not
start.</para>
</listitem>
<listitem>
<para>If your startup scripts try to start your firewall before
starting your DNS server then your firewall may not start.</para>
</listitem>
<listitem>
<para>Factors totally outside your control (your ISP's router is down
for example), can prevent your firewall from starting.</para>
</listitem>
<listitem>
<para>You must bring up your network interfaces prior to starting your
firewall, or the firewall may not start.</para>
</listitem>
</itemizedlist>
<para>Each DNS name must be fully qualified and include a minimum of two
periods (although one may be trailing). This restriction is imposed by
Shorewall to insure backward compatibility with existing configuration
files.</para>
<example id="validdns">
<title>Valid DNS Names</title>
<itemizedlist>
<listitem>
<para>mail.shorewall.net</para>
</listitem>
<listitem>
<para>shorewall.net. (note the trailing period).</para>
</listitem>
</itemizedlist>
</example>
<example id="invaliddns">
<title>Invalid DNS Names</title>
<itemizedlist>
<listitem>
<para>mail (not fully qualified)</para>
</listitem>
<listitem>
<para>shorewall.net (only one period)</para>
</listitem>
</itemizedlist>
</example>
<para>DNS names may not be used as:</para>
<itemizedlist>
<listitem>
<para>The server address in a DNAT rule (/etc/shorewall/rules
file)</para>
</listitem>
<listitem>
<para>In the ADDRESS column of an entry in /etc/shorewall/masq.</para>
</listitem>
<listitem>
<para/>
</listitem>
<listitem>
<para>In the <filename>/etc/shorewall/nat</filename> file.</para>
</listitem>
</itemizedlist>
<para>These restrictions are imposed by Netfilter and not by
Shorewall.</para>
</refsect1>
<refsect1>
<title id="Logical">Logical Interface Names</title>
<para>When dealing with a complex configuration, it is often awkward to
use physical interface names in the Shorewall configuration.</para>
<itemizedlist>
<listitem>
<para>You need to remember which interface is which.</para>
</listitem>
<listitem>
<para>If you move the configuration to another firewall, the interface
names might not be the same.</para>
</listitem>
</itemizedlist>
<para>Beginning with Shorewall 4.4.4, you can use logical interface names
which are mapped to the actual interface using the
<option>physical</option> option in <ulink
url="manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>
(5).</para>
<para>Here is an example:</para>
<programlisting>#ZONE INTERFACE OPTIONS
net <emphasis role="bold">COM_IF </emphasis> dhcp,blacklist,tcpflags,optional,upnp,routefilter=0,nosmurfs,logmartians=0,<emphasis
role="bold">physical=eth0</emphasis>
net <emphasis role="bold">EXT_IF</emphasis> dhcp,blacklist,tcpflags,optional,routefilter=0,nosmurfs,logmartians=0,proxyarp=1,<emphasis
role="bold">physical=eth2</emphasis>
loc <emphasis role="bold">INT_IF </emphasis> dhcp,logmartians=1,routefilter=1,tcpflags,nets=172.20.1.0/24,<emphasis
role="bold">physical=eth1</emphasis>
dmz <emphasis role="bold">VPS_IF </emphasis> logmartians=1,routefilter=0,routeback,<emphasis
role="bold">physical=venet0</emphasis>
loc <emphasis role="bold">TUN_IF</emphasis> <emphasis role="bold">physical=tun+</emphasis></programlisting>
<para>In this example, COM_IF is a logical interface name that refers to
Ethernet interface <filename class="devicefile">eth0</filename>, EXT_IF is
a logical interface name that refers to Ethernet interface <filename
class="devicefile">eth2</filename>, and so on.</para>
<para>Here are a couple of more files from the same configuration:</para>
<para><ulink url="manpages/shorewall-masq.html">shorewall-masq</ulink>
(5):</para>
<programlisting>#INTERFACE SOURCE ADDRESS
COMMENT Masquerade Local Network
<emphasis role="bold">COM_IF</emphasis> 0.0.0.0/0
<emphasis role="bold">EXT_IF </emphasis> !206.124.146.0/24 206.124.146.179:persistent</programlisting>
<para><ulink
url="manpages/shorewall-providers.html">shorewall-providers</ulink>
(5)</para>
<programlisting>#NAME NUMBER MARK DUPLICATE INTERFACE GATEWAY OPTIONS COPY
Avvanta 1 0x10000 main <emphasis role="bold">EXT_IF </emphasis> 206.124.146.254 loose,fallback <emphasis
role="bold">INT_IF,VPS_IF,TUN_IF</emphasis>
Comcast 2 0x20000 main <emphasis role="bold">COM_IF</emphasis> detect balance <emphasis
role="bold">INT_IF,VPS_IF,TUN_IF</emphasis></programlisting>
<para>Note in particular that Shorewall translates TUN_IF to <filename
class="devicefile">tun*</filename> in the COPY column.</para>
</refsect1>
</refentry>

View File

@@ -26,10 +26,8 @@
<title>Description</title>
<para>Assign any shell variables that you need in this file. The file is
always processed by <filename>/bin/sh</filename> or by the shell specified
through SHOREWALL_SHELL in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink> (5) so the full
range of shell capabilities may be used.</para>
always processed by <filename>/bin/sh</filename> so the full range of
shell capabilities may be used.</para>
<para>It is suggested that variable names begin with an upper case letter
to distinguish them from variables used internally within the Shorewall

View File

@@ -295,21 +295,21 @@
<para>where limit is one of:</para>
<simplelist>
<member>[<emphasis
role="bold">-</emphasis>|[{<emphasis>s</emphasis>|<emphasis
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
<member>[<emphasis role="bold">-</emphasis>|[{<emphasis
role="bold">s</emphasis>|<emphasis
role="bold">d</emphasis>}[/<replaceable>vlsm</replaceable>]:[[<replaceable>name</replaceable>][(ht-buckets,ht-max)]:]]]<emphasis>rate</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</member>
<member>[<replaceable>name</replaceable>1]:<emphasis>rate1</emphasis><emphasis
<member>[<replaceable>name</replaceable>1:]<emphasis>rate1</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<replaceable>name</replaceable>2]:<emphasis>rate2</emphasis><emphasis
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<replaceable>name</replaceable>2:]<emphasis>rate2</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
@@ -331,7 +331,14 @@
role="bold">shorewall</emphasis> is assumed. Where more than one
POLICY or rule specifies the same name, the connections counts for
the policies are aggregated and the individual rates apply to the
aggregated count.</para>
aggregated count. Beginning with Shorewall 5.2.1, the <emphasis
role="bold">s</emphasis> or <emphasis role="bold">d</emphasis> may
be followed by a slash ("/") and an integer
<replaceable>vlsm</replaceable>. When a
<replaceable>vlsm</replaceable> is specified, all source or
destination addresses encountered will be grouped according to the
given prefix length and the so-created subnet will be subject to the
rate limit.</para>
<para>Beginning with Shorewall 4.6.5, two<replaceable>
limit</replaceable>s may be specified, separated by a comma. In this
@@ -342,6 +349,17 @@
<para>Example: <emphasis
role="bold">client:10/sec:20,:60/sec:100</emphasis></para>
<para>Beginning with Shorewall 5.2.1, the table name, if any, may be
followed by two integers separated by commas and enclosed in
parentheses. The first integer
(<replaceable>ht-buckets</replaceable>) specifies the number of
buckets in the generated hash table. The second integer
(<replaceable>ht-max</replaceable>) specifies the maximum number of
entries in the hash table.</para>
<para>Example: <emphasis
role="bold">s:client(1024,65536):10/sec</emphasis></para>
</listitem>
</varlistentry>

View File

@@ -84,8 +84,8 @@
<para>If PROVIDER_OFFSET is non-zero in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf(5)</ulink>, then
the value must be a multiple of 2^^PROVIDER_OFFSET. In all cases, the
number of significant bits may not exceed PROVIDER_OFFSET +
the value must be a multiple of 2^^PROVIDER_OFFSET. In all cases,
the number of significant bits may not exceed PROVIDER_OFFSET +
PROVIDER_BITS.</para>
</listitem>
</varlistentry>
@@ -117,6 +117,12 @@
specified unless <option>loose</option> is given in the OPTIONS
column of this entry.</para>
<important>
<para>For IPv6, if the interface is an Ethernet device and an IP
address is supplied, it should be the upstream router's link-level
address, not its global address.</para>
</important>
<para>Where more than one provider is serviced through a single
interface, the <emphasis>interface</emphasis> must be followed by a
colon and the IP <emphasis>address</emphasis> of the interface that
@@ -381,8 +387,10 @@
distributions but <emphasis role="bold">nohostroute</emphasis>
(below) is appropriate for recent distributions. <emphasis
role="bold">hostroute</emphasis> may interfere with Zebra's
ability to add routes on some distributions such as Debian
7.</para>
ability to add routes on some distributions such as Debian 7.
This option defaults to on when BALANCE_PROVIDERS=Yes, in
<ulink
url="/manpages/shorewall.conf.html">shorewall.conf(5)</ulink>.</para>
</listitem>
</varlistentry>
@@ -398,7 +406,9 @@
older distributions but is appropriate for recent
distributions. <emphasis role="bold">nohostroute</emphasis>
allows Zebra's to correctly add routes on some distributions
such as Debian 7.</para>
such as Debian 7. This option defaults to off when
BALANCE_PROVIDERS=Yes, in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf(5)</ulink>.</para>
</listitem>
</varlistentry>

View File

@@ -461,13 +461,12 @@
<listitem>
<para>Added in Shorewall 4.5.16. This action allows you to
construct most of the rule yourself using iptables syntax. The
part that you specify must follow a semicolon (';')
(deprecated) or two semicolons(';;') (preferred) and is
part that you specify must follow two semicolons (';;') and is
completely free-form. If the target of the rule (the part
following 'j') is something that Shorewall supports in the
ACTION column, then you may enclose it in parentheses (e.g.,
INLINE(ACCEPT)). Otherwise, you can include it after the
semicolon. In this case, you must declare the target as a
semicolon(s). In this case, you must declare the target as a
builtin action in <ulink
url="/manpages/shorewall-actions.html">shorewall-actions</ulink>(5).</para>
@@ -490,7 +489,7 @@
necessarily be at the end of the generated rule. For
example, if addresses are specified in the SOURCE and/or
DEST columns, their generated matches will appear after
those specified using ';;' (or ';').</para>
those specified using ';;' or ';'.</para>
</listitem>
</itemizedlist>
</listitem>
@@ -1046,7 +1045,7 @@
</varlistentry>
<varlistentry>
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable></term>
<term><replaceable>zone</replaceable>:[!]<replaceable>interface</replaceable></term>
<listitem>
<para>When this form is used,
@@ -1059,6 +1058,11 @@
Only packets from hosts in the <replaceable>zone</replaceable>
that arrive through the named interface will match the
rule.</para>
<para>Beginning with Shorweall 5.2.1, the
<replaceable>interface</replaceable> may be preceded with '!'
which matches all interfaces associated with the zone except
the one specified.</para>
</listitem>
</varlistentry>
@@ -1397,7 +1401,7 @@
</varlistentry>
<varlistentry>
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable></term>
<term><replaceable>zone</replaceable>:[!]<replaceable>interface</replaceable></term>
<listitem>
<para>When this form is used,
@@ -1410,6 +1414,11 @@
Only packets to hosts in the <replaceable>zone</replaceable>
that are sent through the named interface will match the
rule.</para>
<para>Beginning with Shorweall 5.2.1, the
<replaceable>interface</replaceable> may be preceded with '!'
which matches all interfaces associated with the zone except
the one specified.</para>
</listitem>
</varlistentry>
@@ -1463,12 +1472,17 @@
</varlistentry>
<varlistentry>
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable>:<replaceable>address</replaceable>[,...]</term>
<term><replaceable>zone</replaceable>:[!]<replaceable>interface</replaceable>:<replaceable>address</replaceable>[,...]</term>
<listitem>
<para>This form combines the preceding two and requires that
both the outgoing interface and destinationaddress
match.</para>
<para>Beginning with Shorweall 5.2.1, the
<replaceable>interface</replaceable> may be preceded with '!'
which matches all interfaces associated with the zone except
the one specified.</para>
</listitem>
</varlistentry>
@@ -1483,7 +1497,7 @@
</varlistentry>
<varlistentry>
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable>:<replaceable>exclusion</replaceable></term>
<term><replaceable>zone</replaceable>:[!]<replaceable>interface</replaceable>:<replaceable>exclusion</replaceable></term>
<listitem>
<para>This form matches packets to the named
@@ -1491,6 +1505,11 @@
<replaceable>interface</replaceable> where the destination
address does not match any entry in the
<replaceable>exclusion</replaceable>.</para>
<para>Beginning with Shorweall 5.2.1, the
<replaceable>interface</replaceable> may be preceded with '!'
which matches all interfaces associated with the zone except
the one specified.</para>
</listitem>
</varlistentry>
@@ -1881,19 +1900,21 @@
<simplelist>
<member>[<emphasis role="bold">-</emphasis>|[{<emphasis
role="bold">s</emphasis>|<emphasis
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
role="bold">d</emphasis>}[/<replaceable>vlsm</replaceable>]:[<replaceable>name</replaceable>[(<replaceable>ht-buckets</replaceable>,<replaceable>ht-max</replaceable>)]:]<emphasis>rate</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</member>
<member>[<replaceable>name</replaceable>1]:<emphasis>rate1</emphasis><emphasis
<member>[<emphasis
role="bold">s</emphasis>[/<replaceable>vlsm1</replaceable>]:][<replaceable>name</replaceable>1[(<replaceable>ht-buckets1</replaceable>,<replaceable>ht-max1</replaceable>)]:]<emphasis>rate1</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<replaceable>name</replaceable>2]:<emphasis>rate2</emphasis><emphasis
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<emphasis
role="bold">d</emphasis>[/<replaceable>vlsm2</replaceable>:][<replaceable>name</replaceable>2[(<replaceable>ht-buckets2</replaceable>,<replaceable>ht-max2</replaceable>)]:]<emphasis>rate2</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
@@ -1921,7 +1942,16 @@
role="bold">shorewallN</emphasis> (where N is a unique integer) is
assumed. Where more than one rule or POLICY specifies the same name,
the connections counts for the rules are aggregated and the
individual rates apply to the aggregated count.</para>
individual rates apply to the aggregated count. Beginning with
Shorewall 5.2.1, the <emphasis role="bold">s</emphasis> or <emphasis
role="bold">d</emphasis> may be followed by a slash ("/") and an
integer <replaceable>vlsm</replaceable>. When a
<replaceable>vlsm</replaceable> is specified, all source or
destination addresses encountered will be grouped according to the
given prefix length and the so-created subnet will be subject to the
rate limit.</para>
<para>Example: <emphasis role="bold">s/24::10/sec</emphasis></para>
<para>Beginning with Shorewall 4.6.5, two<replaceable>
limit</replaceable>s may be specified, separated by a comma. In this
@@ -1938,6 +1968,17 @@
name for the hash table that tracks the per-destination
limit.</para>
<para>Beginning with Shorewall 5.2.1, the table name, if any, may be
followed by two integers separated by commas and enclosed in
parentheses. The first integer
(<replaceable>ht-buckets</replaceable>) specifies the number of
buckets in the generated hash table. The second integer
(<replaceable>ht-max</replaceable>) specifies the maximum number of
entries in the hash table.</para>
<para>Example: <emphasis
role="bold">s:netfw(1024,65536):10/sec</emphasis></para>
<para>This column was formerly labelled RATE LIMIT.</para>
</listitem>
</varlistentry>

View File

@@ -463,7 +463,8 @@
<varlistentry>
<term><emphasis role="bold">AUTOMAKE=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
role="bold">Yes</emphasis>|<emphasis
role="bold">No</emphasis>|<option>recursive</option>|<replaceable>depth</replaceable>]</term>
<listitem>
<para>If set, the behavior of the <command>start</command>,
@@ -481,6 +482,27 @@
<command>restart</command> command includes a directory name
(e.g.,<command> shorewall restart
/etc/shorewall.new</command>).</para>
<para>When AUTOMAKE=Yes, each directory in the CONFIG_PATH was
originally searched recursively for files newer than the compiled
script. That was changed in Shorewall 5.1.10.2 such that only the
listed directories themselves were searched. That broke some
configurations that played tricks with embedded SHELL such as
"<command>SHELL cat /etc/shorewall/rules.d/loc/*.rules".</command>
Prior to 5.1.10.2, a change to a file in or adding a file to
/etc/shorewall/rules.d/loc/ would trigger recompilation. Beginning
with 5.1.10.2, such changes would not trigger recompilation.
Beginning with Shorewall 5.2.0, the pre-5.1.10.2 behavior can be
obtained by setting AUTOMAKE=recursive.</para>
<para>Also beginning with Shorewall 5.2.0, AUTOMAKE may be set to a
numeric <replaceable>depth</replaceable> which specifies how deeply
each listed directory is to be searched. AUTOMAKE=1 only searches
each directory itself and is equivalent to AUTOMAKE=Yes. AUTOMAKE=2
will search each directory and its immediate sub-directories;
AUTOMAKE=3 will search each directory, each of its immediate
sub-directories, and each of their immediate sub-directories,
etc.</para>
</listitem>
</varlistentry>
@@ -2447,6 +2469,20 @@ INLINE - - - ;; -j REJECT
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">RENAME_COMBINED=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
<listitem>
<para>Added in Shorewall 5.2.0. Traditionally, when OPTIMIZE
category 8 is enabled, identical chains are combined under a name
beginning with '~comb' or '~blacklist'. This behavior is maintained
under the default setting RENAME_COMBINED=Yes. If
RENAMED_COMBINED=No, the chains are combined under the original name
of one of the chains.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">REQUIRE_INTERFACE=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>

View File

@@ -151,7 +151,7 @@ fi
remove_file ${SBINDIR}/$PRODUCT
if [ -L ${SHAREDIR}/$PRODUCT/init ]; then
if [ -h ${SHAREDIR}/$PRODUCT/init ]; then
FIREWALL=$(readlink -m -q ${SHAREDIR}/$PRODUCT/init)
elif [ -n "$INITFILE" ]; then
FIREWALL=${INITDIR}/${INITFILE}

117
Shorewall6-lite/init.alt.sh Executable file
View File

@@ -0,0 +1,117 @@
#!/bin/sh
#
# Shorewall6-Lite init script
#
# chkconfig: - 28 90
# description: Packet filtering firewall
#
### BEGIN INIT INFO
# Provides: shorewall6
# Required-Start: $local_fs $remote_fs $syslog $network
# Should-Start: $time $named
# Required-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Packet filtering firewall
# Description: The Shoreline Firewall, more commonly known as "Shorewall", is a
# Netfilter (iptables) based firewall
### END INIT INFO
# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1
# Source function library.
. /etc/init.d/functions
#
# The installer may alter this
#
. /usr/share/shorewall/shorewallrc
NAME="Shorewall6-Lite firewall"
PROG="shorewall"
SHOREWALL="$SBINDIR/$PROG -6l"
LOGGER="logger -i -t $PROG"
# Get startup options (override default)
OPTIONS=
SourceIfNotEmpty $SYSCONFDIR/${PROG}6-lite
LOCKFILE="/var/lock/subsys/${PROG}6-lite"
RETVAL=0
start() {
action $"Applying $NAME rules:" "$SHOREWALL" "$OPTIONS" start "$STARTOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
return $RETVAL
}
stop() {
action $"Stoping $NAME :" "$SHOREWALL" "$OPTIONS" stop "$STOPOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
return $RETVAL
}
restart() {
action $"Restarting $NAME rules: " "$SHOREWALL" "$OPTIONS" restart "$RESTARTOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
return $RETVAL
}
reload() {
action $"Reloadinging $NAME rules: " "$SHOREWALL" "$OPTIONS" reload "$RELOADOPTIONS" 2>&1 | "$LOGGER"
RETVAL=$?
return $RETVAL
}
clear() {
action $"Clearing $NAME rules: " "$SHOREWALL" "$OPTIONS" clear 2>&1 | "$LOGGER"
RETVAL=$?
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
clear)
clear
;;
condrestart)
if [ -e "$LOCKFILE" ]; then
restart
fi
;;
condreload)
if [ -e "$LOCKFILE" ]; then
restart
fi
;;
condstop)
if [ -e "$LOCKFILE" ]; then
stop
fi
;;
status)
"$SHOREWALL" status
RETVAL=$?
;;
*)
echo $"Usage: ${0##*/} {start|stop|restart|reload|clear|condrestart|condstop|status}"
RETVAL=1
esac
exit $RETVAL

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