Compare commits

..

5 Commits

Author SHA1 Message Date
Tom Eastep
6b1d24f626 Add IP_FORWARDING=On to FAQ 1g 2010-05-07 08:48:26 -07:00
Tom Eastep
1de2e68bb7 Clarify that Mac support requires Shorewall 4.4.9) 2010-05-06 12:47:13 -07:00
Tom Eastep
c7af716920 Modify first attempts to allow installaton on a Mac
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2010-05-06 11:23:14 -07:00
Tom Eastep
2ab9cc3c58 Document OS X as an Administrative system
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2010-05-06 09:01:26 -07:00
Tom Eastep
a3b998d934 Allow OS X to be an Administrative System
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2010-05-06 08:17:17 -07:00
346 changed files with 15763 additions and 30700 deletions

View File

@@ -1,12 +0,0 @@
#
# Shorewall version 4 - Interfaces File
#
# For information about entries in this file, type "man shorewall-interfaces"
#
# The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-interfaces.html
#
###############################################################################
#ZONE INTERFACE BROADCAST OPTIONS
- lo - ignore
net all - dhcp,physical=+,routeback,optional

View File

@@ -1,13 +0,0 @@
#
# Shorewall version 4 - Policy File
#
# For information about entries in this file, type "man shorewall-policy"
#
# The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-policy.html
#
###############################################################################
#SOURCE DEST POLICY LOG LIMIT: CONNLIMIT:
# LEVEL BURST MASK
$FW net ACCEPT
net all DROP

View File

@@ -1,18 +0,0 @@
#
# Shorewall version 4 - Rules File
#
# For information on the settings in this file, type "man shorewall-rules"
#
# The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-rules.html
#
####################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME
# PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL
#SECTION ESTABLISHED
#SECTION RELATED
SECTION NEW
SSH(ACCEPT) net $FW
Ping(ACCEPT) net $FW

View File

@@ -1,216 +0,0 @@
###############################################################################
#
# Shorewall Version 4.4 -- /etc/shorewall/shorewall.conf
#
# For information about the settings in this file, type "man shorewall.conf"
#
# Manpage also online at http://www.shorewall.net/manpages/shorewall.conf.html
###############################################################################
# S T A R T U P E N A B L E D
###############################################################################
STARTUP_ENABLED=Yes
###############################################################################
# V E R B O S I T Y
###############################################################################
VERBOSITY=1
###############################################################################
# L O G G I N G
###############################################################################
BLACKLIST_LOGLEVEL=
LOG_MARTIANS=Yes
LOG_VERBOSITY=2
LOGALLNEW=
LOGFILE=/var/log/messages
LOGFORMAT="Shorewall:%s:%s:"
LOGTAGONLY=No
LOGLIMIT=
MACLIST_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info
SMURF_LOG_LEVEL=info
STARTUP_LOG=/var/log/shorewall-init.log
TCP_FLAGS_LOG_LEVEL=info
###############################################################################
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
IPTABLES=
IP=
IPSET=
MODULESDIR=
PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
RESTOREFILE=restore
SHOREWALL_SHELL=/bin/sh
SUBSYSLOCK=
TC=
###############################################################################
# D E F A U L T A C T I O N S / M A C R O S
###############################################################################
ACCEPT_DEFAULT="none"
DROP_DEFAULT="Drop"
NFQUEUE_DEFAULT="none"
QUEUE_DEFAULT="none"
REJECT_DEFAULT="Reject"
###############################################################################
# R S H / R C P C O M M A N D S
###############################################################################
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
RSH_COMMAND='ssh ${root}@${system} ${command}'
###############################################################################
# F I R E W A L L O P T I O N S
###############################################################################
ACCOUNTING=Yes
ACCOUNTING_TABLE=filter
ADD_IP_ALIASES=No
ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes
AUTOMAKE=No
BLACKLISTNEWONLY=Yes
CLAMPMSS=No
CLEAR_TC=Yes
COMPLETE=Yes
DISABLE_IPV6=No
DELETE_THEN_ADD=Yes
DETECT_DNAT_IPADDRS=No
DONT_LOAD=
DYNAMIC_BLACKLIST=Yes
EXPAND_POLICIES=Yes
EXPORTMODULES=Yes
FASTACCEPT=Yes
FORWARD_CLEAR_MARK=
IMPLICIT_CONTINUE=No
HIGH_ROUTE_MARKS=No
IP_FORWARDING=On
KEEP_RT_TABLES=No
LOAD_HELPERS_ONLY=Yes
LEGACY_FASTSTART=No
MACLIST_TABLE=filter
MACLIST_TTL=
MANGLE_ENABLED=Yes
MAPOLDACTIONS=No
MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX=ko
MULTICAST=No
MUTEX_TIMEOUT=60
NULL_ROUTE_RFC1918=No
OPTIMIZE=15
OPTIMIZE_ACCOUNTING=No
REQUIRE_INTERFACE=Yes
RESTORE_DEFAULT_ROUTE=Yes
RETAIN_ALIASES=No
ROUTE_FILTER=No
SAVE_IPSETS=No
TC_ENABLED=Internal
TC_EXPERT=No
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
TRACK_PROVIDERS=Yes
USE_DEFAULT_RT=No
WIDE_TC_MARKS=Yes
ZONE2ZONE=2
###############################################################################
# P A C K E T D I S P O S I T I O N
###############################################################################
BLACKLIST_DISPOSITION=DROP
MACLIST_DISPOSITION=REJECT
SMURF_DISPOSITION=DROP
SFILTER_DISPOSITION=DROP
TCP_FLAGS_DISPOSITION=DROP
################################################################################
# L E G A C Y O P T I O N
# D O N O T D E L E T E O R A L T E R
################################################################################
IPSECFILE=zones
#LAST LINE -- DO NOT REMOVE

View File

@@ -1,14 +0,0 @@
#
# Shorewall version 4 - Zones File
#
# For information about this file, type "man shorewall-zones"
#
# The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-zones.html
#
###############################################################################
#ZONE TYPE OPTIONS IN OUT
# OPTIONS OPTIONS
fw firewall
net ip

View File

@@ -13,10 +13,6 @@
#############################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK
# PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL
#SECTION ESTABLISHED
#SECTION RELATED
SECTION NEW
# Drop Ping from the "bad" net zone.. and prevent your log from being flooded..

View File

@@ -29,180 +29,182 @@ STARTUP_ENABLED=No
VERBOSITY=1
###############################################################################
# L O G G I N G
# L O G G I N G
###############################################################################
BLACKLIST_LOGLEVEL=
LOGFILE=/var/log/messages
LOG_MARTIANS=Yes
STARTUP_LOG=/var/log/shorewall-init.log
LOG_VERBOSITY=2
LOGALLNEW=
LOGFILE=/var/log/messages
LOGFORMAT="Shorewall:%s:%s:"
LOGTAGONLY=No
LOGLIMIT=
LOGRATE=
LOGBURST=
LOGALLNEW=
BLACKLIST_LOGLEVEL=
MACLIST_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info
TCP_FLAGS_LOG_LEVEL=info
SMURF_LOG_LEVEL=info
STARTUP_LOG=/var/log/shorewall-init.log
TCP_FLAGS_LOG_LEVEL=info
LOG_MARTIANS=Yes
###############################################################################
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
IPTABLES=
IP=
TC=
IPSET=
MODULESDIR=
PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
RESTOREFILE=restore
SHOREWALL_SHELL=/bin/sh
SUBSYSLOCK=
TC=
MODULESDIR=
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
RESTOREFILE=
IPSECFILE=zones
LOCKFILE=
###############################################################################
# D E F A U L T A C T I O N S / M A C R O S
###############################################################################
ACCEPT_DEFAULT="none"
DROP_DEFAULT="Drop"
NFQUEUE_DEFAULT="none"
QUEUE_DEFAULT="none"
REJECT_DEFAULT="Reject"
ACCEPT_DEFAULT="none"
QUEUE_DEFAULT="none"
NFQUEUE_DEFAULT="none"
###############################################################################
# R S H / R C P C O M M A N D S
###############################################################################
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
RSH_COMMAND='ssh ${root}@${system} ${command}'
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
###############################################################################
# F I R E W A L L O P T I O N S
###############################################################################
ACCOUNTING=Yes
ACCOUNTING_TABLE=filter
IP_FORWARDING=Off
ADD_IP_ALIASES=No
ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes
AUTOMAKE=No
BLACKLISTNEWONLY=Yes
CLAMPMSS=No
CLEAR_TC=Yes
COMPLETE=No
DISABLE_IPV6=No
DELETE_THEN_ADD=Yes
DETECT_DNAT_IPADDRS=No
DONT_LOAD=
DYNAMIC_BLACKLIST=Yes
EXPAND_POLICIES=Yes
EXPORTMODULES=Yes
FASTACCEPT=No
FORWARD_CLEAR_MARK=
IMPLICIT_CONTINUE=No
HIGH_ROUTE_MARKS=No
IP_FORWARDING=Off
KEEP_RT_TABLES=No
LOAD_HELPERS_ONLY=Yes
LEGACY_FASTSTART=No
MACLIST_TABLE=filter
MACLIST_TTL=
MANGLE_ENABLED=Yes
MAPOLDACTIONS=No
MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX=ko
MULTICAST=No
MUTEX_TIMEOUT=60
NULL_ROUTE_RFC1918=No
OPTIMIZE=1
OPTIMIZE_ACCOUNTING=No
REQUIRE_INTERFACE=No
RESTORE_DEFAULT_ROUTE=Yes
RETAIN_ALIASES=No
ROUTE_FILTER=No
SAVE_IPSETS=No
TC_ENABLED=Internal
TC_EXPERT=No
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
TRACK_PROVIDERS=Yes
CLEAR_TC=Yes
MARK_IN_FORWARD_CHAIN=No
CLAMPMSS=No
ROUTE_FILTER=No
DETECT_DNAT_IPADDRS=No
MUTEX_TIMEOUT=60
ADMINISABSENTMINDED=Yes
BLACKLISTNEWONLY=Yes
DELAYBLACKLISTLOAD=No
MODULE_SUFFIX=ko
DISABLE_IPV6=No
BRIDGING=No
DYNAMIC_ZONES=No
PKTTYPE=Yes
NULL_ROUTE_RFC1918=No
MACLIST_TABLE=filter
MACLIST_TTL=
SAVE_IPSETS=No
MAPOLDACTIONS=No
FASTACCEPT=No
IMPLICIT_CONTINUE=No
HIGH_ROUTE_MARKS=No
USE_ACTIONS=Yes
OPTIMIZE=1
EXPORTPARAMS=No
EXPAND_POLICIES=Yes
KEEP_RT_TABLES=No
DELETE_THEN_ADD=Yes
MULTICAST=No
DONT_LOAD=
AUTO_COMMENT=Yes
MANGLE_ENABLED=Yes
USE_DEFAULT_RT=No
RESTORE_DEFAULT_ROUTE=Yes
AUTOMAKE=No
WIDE_TC_MARKS=Yes
TRACK_PROVIDERS=Yes
ZONE2ZONE=2
ACCOUNTING=Yes
DYNAMIC_BLACKLIST=Yes
OPTIMIZE_ACCOUNTING=No
LOAD_HELPERS_ONLY=Yes
###############################################################################
# P A C K E T D I S P O S I T I O N
###############################################################################
@@ -211,17 +213,6 @@ BLACKLIST_DISPOSITION=DROP
MACLIST_DISPOSITION=REJECT
SMURF_DISPOSITION=DROP
SFILTER_DISPOSITION=DROP
TCP_FLAGS_DISPOSITION=DROP
################################################################################
# L E G A C Y O P T I O N
# D O N O T D E L E T E O R A L T E R
################################################################################
IPSECFILE=zones
#LAST LINE -- DO NOT REMOVE

View File

@@ -13,14 +13,6 @@
#############################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK
# PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL
#SECTION ESTABLISHED
#SECTION RELATED
SECTION NEW
# Don't allow connection pickup from the net
#
Invalid(DROP) net all
#
# Accept DNS connections from the firewall to the Internet
#

View File

@@ -3,7 +3,6 @@
# Shorewall version 4.0 - Sample shorewall.conf for three-interface
# configuration.
# Copyright (C) 2006 by the Shorewall Team
# 2011 by Thomas M. Eastep
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -18,6 +17,9 @@
# http://shorewall.net/manpages/shorewall.conf.html
#
###############################################################################
# S T A R T U P E N A B L E D
###############################################################################
STARTUP_ENABLED=No
###############################################################################
@@ -27,180 +29,182 @@ STARTUP_ENABLED=No
VERBOSITY=1
###############################################################################
# L O G G I N G
# L O G G I N G
###############################################################################
BLACKLIST_LOGLEVEL=
LOGFILE=/var/log/messages
LOG_MARTIANS=Yes
STARTUP_LOG=/var/log/shorewall-init.log
LOG_VERBOSITY=2
LOGALLNEW=
LOGFILE=/var/log/messages
LOGFORMAT="Shorewall:%s:%s:"
LOGTAGONLY=No
LOGLIMIT=
LOGRATE=
LOGBURST=
LOGALLNEW=
BLACKLIST_LOGLEVEL=
MACLIST_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info
TCP_FLAGS_LOG_LEVEL=info
SMURF_LOG_LEVEL=info
STARTUP_LOG=/var/log/shorewall-init.log
TCP_FLAGS_LOG_LEVEL=info
LOG_MARTIANS=Yes
###############################################################################
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
IPTABLES=
IP=
TC=
IPSET=
MODULESDIR=
PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
RESTOREFILE=restore
SHOREWALL_SHELL=/bin/sh
SUBSYSLOCK=
TC=
MODULESDIR=
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
RESTOREFILE=
IPSECFILE=zones
LOCKFILE=
###############################################################################
# D E F A U L T A C T I O N S / M A C R O S
###############################################################################
ACCEPT_DEFAULT="none"
DROP_DEFAULT="Drop"
NFQUEUE_DEFAULT="none"
QUEUE_DEFAULT="none"
REJECT_DEFAULT="Reject"
ACCEPT_DEFAULT="none"
QUEUE_DEFAULT="none"
NFQUEUE_DEFAULT="none"
###############################################################################
# R S H / R C P C O M M A N D S
###############################################################################
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
RSH_COMMAND='ssh ${root}@${system} ${command}'
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
###############################################################################
# F I R E W A L L O P T I O N S
###############################################################################
ACCOUNTING=Yes
ACCOUNTING_TABLE=filter
IP_FORWARDING=On
ADD_IP_ALIASES=No
ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes
AUTOMAKE=No
BLACKLISTNEWONLY=Yes
CLAMPMSS=Yes
CLEAR_TC=Yes
COMPLETE=No
DISABLE_IPV6=No
DELETE_THEN_ADD=Yes
DETECT_DNAT_IPADDRS=No
DONT_LOAD=
DYNAMIC_BLACKLIST=Yes
EXPAND_POLICIES=Yes
EXPORTMODULES=Yes
FASTACCEPT=No
FORWARD_CLEAR_MARK=
IMPLICIT_CONTINUE=No
HIGH_ROUTE_MARKS=No
IP_FORWARDING=On
KEEP_RT_TABLES=No
LOAD_HELPERS_ONLY=Yes
LEGACY_FASTSTART=No
MACLIST_TABLE=filter
MACLIST_TTL=
MANGLE_ENABLED=Yes
MAPOLDACTIONS=No
MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX=ko
MULTICAST=No
MUTEX_TIMEOUT=60
NULL_ROUTE_RFC1918=No
OPTIMIZE=1
OPTIMIZE_ACCOUNTING=No
REQUIRE_INTERFACE=No
RESTORE_DEFAULT_ROUTE=Yes
RETAIN_ALIASES=No
ROUTE_FILTER=No
SAVE_IPSETS=No
TC_ENABLED=Internal
TC_EXPERT=No
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
TRACK_PROVIDERS=Yes
CLEAR_TC=Yes
MARK_IN_FORWARD_CHAIN=No
CLAMPMSS=Yes
ROUTE_FILTER=No
DETECT_DNAT_IPADDRS=No
MUTEX_TIMEOUT=60
ADMINISABSENTMINDED=Yes
BLACKLISTNEWONLY=Yes
DELAYBLACKLISTLOAD=No
MODULE_SUFFIX=ko
DISABLE_IPV6=No
BRIDGING=No
DYNAMIC_ZONES=No
PKTTYPE=Yes
NULL_ROUTE_RFC1918=No
MACLIST_TABLE=filter
MACLIST_TTL=
SAVE_IPSETS=No
MAPOLDACTIONS=No
FASTACCEPT=No
IMPLICIT_CONTINUE=No
HIGH_ROUTE_MARKS=No
USE_ACTIONS=Yes
OPTIMIZE=1
EXPORTPARAMS=No
EXPAND_POLICIES=Yes
KEEP_RT_TABLES=No
DELETE_THEN_ADD=Yes
MULTICAST=No
DONT_LOAD=
AUTO_COMMENT=Yes
MANGLE_ENABLED=Yes
USE_DEFAULT_RT=No
RESTORE_DEFAULT_ROUTE=Yes
AUTOMAKE=No
WIDE_TC_MARKS=Yes
TRACK_PROVIDERS=Yes
ZONE2ZONE=2
ACCOUNTING=Yes
DYNAMIC_BLACKLIST=Yes
OPTIMIZE_ACCOUNTING=No
LOAD_HELPERS_ONLY=Yes
###############################################################################
# P A C K E T D I S P O S I T I O N
###############################################################################
@@ -209,17 +213,6 @@ BLACKLIST_DISPOSITION=DROP
MACLIST_DISPOSITION=REJECT
SMURF_DISPOSITION=DROP
SFILTER_DISPOSITION=DROP
TCP_FLAGS_DISPOSITION=DROP
################################################################################
# L E G A C Y O P T I O N
# D O N O T D E L E T E O R A L T E R
################################################################################
IPSECFILE=zones
#LAST LINE -- DO NOT REMOVE

View File

@@ -13,14 +13,6 @@
#############################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK
# PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL
#SECTION ESTABLISHED
#SECTION RELATED
SECTION NEW
# Don't allow connection pickup from the net
#
Invalid(DROP) net all
#
# Accept DNS connections from the firewall to the network
#

View File

@@ -3,7 +3,6 @@
# Shorewall version 4.0 - Sample shorewall.conf for two-interface
# configuration.
# Copyright (C) 2006,2007 by the Shorewall Team
# 2011 by Thomas M. Eastep
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -30,180 +29,189 @@ STARTUP_ENABLED=No
VERBOSITY=1
###############################################################################
# L O G G I N G
# C O M P I L E R
# (setting this to 'perl' requires installation of Shorewall-perl)
###############################################################################
BLACKLIST_LOGLEVEL=
SHOREWALL_COMPILER=
LOG_MARTIANS=Yes
LOG_VERBOSITY=2
LOGALLNEW=
###############################################################################
# L O G G I N G
###############################################################################
LOGFILE=/var/log/messages
STARTUP_LOG=/var/log/shorewall-init.log
LOG_VERBOSITY=2
LOGFORMAT="Shorewall:%s:%s:"
LOGTAGONLY=No
LOGLIMIT=
LOGRATE=
LOGBURST=
LOGALLNEW=
BLACKLIST_LOGLEVEL=
MACLIST_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info
TCP_FLAGS_LOG_LEVEL=info
SMURF_LOG_LEVEL=info
STARTUP_LOG=/var/log/shorewall-init.log
TCP_FLAGS_LOG_LEVEL=info
LOG_MARTIANS=Yes
###############################################################################
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
IPTABLES=
IP=
TC=
IPSET=
MODULESDIR=
PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
RESTOREFILE=restore
SHOREWALL_SHELL=/bin/sh
SUBSYSLOCK=
TC=
MODULESDIR=
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
RESTOREFILE=
IPSECFILE=zones
LOCKFILE=
###############################################################################
# D E F A U L T A C T I O N S / M A C R O S
###############################################################################
ACCEPT_DEFAULT="none"
DROP_DEFAULT="Drop"
NFQUEUE_DEFAULT="none"
QUEUE_DEFAULT="none"
REJECT_DEFAULT="Reject"
ACCEPT_DEFAULT="none"
QUEUE_DEFAULT="none"
NFQUEUE_DEFAULT="none"
###############################################################################
# R S H / R C P C O M M A N D S
###############################################################################
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
RSH_COMMAND='ssh ${root}@${system} ${command}'
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
###############################################################################
# F I R E W A L L O P T I O N S
###############################################################################
ACCOUNTING=Yes
ACCOUNTING_TABLE=filter
IP_FORWARDING=On
ADD_IP_ALIASES=No
ADD_SNAT_ALIASES=No
ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes
AUTOMAKE=No
BLACKLISTNEWONLY=Yes
CLAMPMSS=Yes
CLEAR_TC=Yes
COMPLETE=No
DISABLE_IPV6=No
DELETE_THEN_ADD=Yes
DETECT_DNAT_IPADDRS=No
DONT_LOAD=
DYNAMIC_BLACKLIST=Yes
EXPAND_POLICIES=Yes
EXPORTMODULES=Yes
FASTACCEPT=No
FORWARD_CLEAR_MARK=
IMPLICIT_CONTINUE=No
HIGH_ROUTE_MARKS=No
IP_FORWARDING=On
KEEP_RT_TABLES=No
LOAD_HELPERS_ONLY=Yes
LEGACY_FASTSTART=No
MACLIST_TABLE=filter
MACLIST_TTL=
MANGLE_ENABLED=Yes
MAPOLDACTIONS=No
MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX=ko
MULTICAST=No
MUTEX_TIMEOUT=60
NULL_ROUTE_RFC1918=No
OPTIMIZE=1
OPTIMIZE_ACCOUNTING=No
REQUIRE_INTERFACE=No
RESTORE_DEFAULT_ROUTE=Yes
RETAIN_ALIASES=No
ROUTE_FILTER=No
SAVE_IPSETS=No
TC_ENABLED=Internal
TC_EXPERT=No
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
TRACK_PROVIDERS=Yes
CLEAR_TC=Yes
MARK_IN_FORWARD_CHAIN=No
CLAMPMSS=Yes
ROUTE_FILTER=No
DETECT_DNAT_IPADDRS=No
MUTEX_TIMEOUT=60
ADMINISABSENTMINDED=Yes
BLACKLISTNEWONLY=Yes
DELAYBLACKLISTLOAD=No
MODULE_SUFFIX=ko
DISABLE_IPV6=No
BRIDGING=No
DYNAMIC_ZONES=No
PKTTYPE=Yes
NULL_ROUTE_RFC1918=No
MACLIST_TABLE=filter
MACLIST_TTL=
SAVE_IPSETS=No
MAPOLDACTIONS=No
FASTACCEPT=No
IMPLICIT_CONTINUE=No
HIGH_ROUTE_MARKS=No
USE_ACTIONS=Yes
OPTIMIZE=1
EXPORTPARAMS=No
EXPAND_POLICIES=Yes
KEEP_RT_TABLES=No
DELETE_THEN_ADD=Yes
MULTICAST=No
DONT_LOAD=
AUTO_COMMENT=Yes
MANGLE_ENABLED=Yes
USE_DEFAULT_RT=No
RESTORE_DEFAULT_ROUTE=Yes
AUTOMAKE=No
WIDE_TC_MARKS=Yes
TRACK_PROVIDERS=Yes
ZONE2ZONE=2
ACCOUNTING=Yes
DYNAMIC_BLACKLIST=Yes
OPTIMIZE_ACCOUNTING=No
LOAD_HELPERS_ONLY=Yes
###############################################################################
# P A C K E T D I S P O S I T I O N
###############################################################################
@@ -212,17 +220,6 @@ BLACKLIST_DISPOSITION=DROP
MACLIST_DISPOSITION=REJECT
SMURF_DISPOSITION=DROP
SFILTER_DISPOSITION=DROP
TCP_FLAGS_DISPOSITION=DROP
################################################################################
# L E G A C Y O P T I O N
# D O N O T D E L E T E O R A L T E R
################################################################################
IPSECFILE=zones
#LAST LINE -- DO NOT REMOVE

View File

@@ -1,13 +0,0 @@
#
# Shorewall version 4 - Interfaces File
#
# For information about entries in this file, type "man shorewall-interfaces"
#
# The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-interfaces.html
#
###############################################################################
#ZONE INTERFACE BROADCAST OPTIONS
- lo - ignore
net all - dhcp,physical=+,routeback

View File

@@ -1,14 +0,0 @@
#
# Shorewall version 4 - Policy File
#
# For information about entries in this file, type "man shorewall-policy"
#
# The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-policy.html
#
###############################################################################
#SOURCE DEST POLICY LOG LIMIT: CONNLIMIT:
# LEVEL BURST MASK
fw net ACCEPT
net all DROP

View File

@@ -1,18 +0,0 @@
#
# Shorewall version 4 - Rules File
#
# For information on the settings in this file, type "man shorewall-rules"
#
# The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-rules.html
#
####################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME
# PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL
#SECTION ESTABLISHED
#SECTION RELATED
SECTION NEW
SSH(ACCEPT) net $FW
Ping(ACCEPT) net $FW

View File

@@ -1,14 +0,0 @@
#
# Shorewall version 4 - Zones File
#
# For information about this file, type "man shorewall-zones"
#
# The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-zones.html
#
###############################################################################
#ZONE TYPE OPTIONS IN OUT
# OPTIONS OPTIONS
fw firewall
net ip

View File

@@ -13,10 +13,6 @@
#############################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK
# PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL
#SECTION ESTABLISHED
#SECTION RELATED
SECTION NEW
# Drop Ping from the "bad" net zone.. and prevent your log from being flooded..

View File

@@ -1,11 +1,19 @@
###############################################################################
#
# Shorewall Version 4 -- /etc/shorewall6/shorewall6.conf
# Shorewall6 version 4 - Sample shorewall.conf for one-interface configuration.
# Copyright (C) 2006,2008 by the Shorewall Team
#
# For information about the settings in this file, type "man shorewall6.conf"
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# Manpage also online at
# http://www.shorewall.net/manpages6/shorewall6.conf.html
# See the file README.txt for further details.
#
# For information about the settings in this file, type "man shorewall6.conf"
#
# The manpage is also online at
# http://shorewall.net/manpages6/shorewall6.conf.html
###############################################################################
# S T A R T U P E N A B L E D
###############################################################################
@@ -22,163 +30,135 @@ VERBOSITY=1
# L O G G I N G
###############################################################################
BLACKLIST_LOGLEVEL=
LOG_VERBOSITY=2
LOGALLNEW=
LOGFILE=
LOGFORMAT="Shorewall:%s:%s:"
LOGLIMIT=
LOGTAGONLY=No
MACLIST_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info
SMURF_LOG_LEVEL=info
LOGFILE=/var/log/messages
STARTUP_LOG=/var/log/shorewall6-init.log
LOG_VERBOSITY=2
LOGFORMAT="Shorewall:%s:%s:"
LOGTAGONLY=No
LOGRATE=
LOGBURST=
LOGALLNEW=
BLACKLIST_LOGLEVEL=
TCP_FLAGS_LOG_LEVEL=info
SMURF_LOG_LEVEL=info
###############################################################################
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall6:/usr/share/shorewall6:/usr/share/shorewall
IP6TABLES=
IP=
IPSET=
MODULESDIR=
PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
RESTOREFILE=
SHOREWALL_SHELL=/bin/sh
SUBSYSLOCK=
TC=
MODULESDIR=
CONFIG_PATH=/etc/shorewall6:/usr/share/shorewall6:/usr/share/shorewall
RESTOREFILE=
LOCKFILE=
###############################################################################
# D E F A U L T A C T I O N S / M A C R O S
###############################################################################
ACCEPT_DEFAULT="none"
DROP_DEFAULT="Drop"
NFQUEUE_DEFAULT="none"
QUEUE_DEFAULT="none"
REJECT_DEFAULT="Reject"
ACCEPT_DEFAULT="none"
QUEUE_DEFAULT="none"
NFQUEUE_DEFAULT="none"
###############################################################################
# R S H / R C P C O M M A N D S
###############################################################################
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
RSH_COMMAND='ssh ${root}@${system} ${command}'
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
###############################################################################
# F I R E W A L L O P T I O N S
###############################################################################
ACCOUNTING=Yes
ACCOUNTING_TABLE=filter
ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes
AUTOMAKE=No
BLACKLISTNEWONLY=Yes
CLAMPMSS=No
CLEAR_TC=Yes
COMPLETE=No
DELETE_THEN_ADD=Yes
DONT_LOAD=
DYNAMIC_BLACKLIST=Yes
EXPAND_POLICIES=No
EXPORTMODULES=Yes
FASTACCEPT=No
FORWARD_CLEAR_MARK=
HIGH_ROUTE_MARKS=No
IMPLICIT_CONTINUE=No
IP_FORWARDING=Off
KEEP_RT_TABLES=Yes
LEGACY_FASTSTART=No
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter
MACLIST_TTL=
MANGLE_ENABLED=Yes
MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX=ko
MUTEX_TIMEOUT=60
OPTIMIZE=1
OPTIMIZE_ACCOUNTING=No
REQUIRE_INTERFACE=No
TC_ENABLED=No
TC_EXPERT=No
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
TRACK_PROVIDERS=Yes
CLEAR_TC=Yes
MARK_IN_FORWARD_CHAIN=No
CLAMPMSS=No
MUTEX_TIMEOUT=60
ADMINISABSENTMINDED=Yes
BLACKLISTNEWONLY=Yes
MODULE_SUFFIX=ko
FASTACCEPT=No
IMPLICIT_CONTINUE=No
HIGH_ROUTE_MARKS=No
OPTIMIZE=1
EXPORTPARAMS=No
EXPAND_POLICIES=No
KEEP_RT_TABLES=Yes
DELETE_THEN_ADD=Yes
DONT_LOAD=
AUTO_COMMENT=Yes
MANGLE_ENABLED=Yes
AUTOMAKE=No
WIDE_TC_MARKS=Yes
TRACK_PROVIDERS=Yes
ZONE2ZONE=2
###############################################################################
ACCOUNTING=Yes
DYNAMIC_BLACKLIST=Yes
OPTIMIZE_ACCOUNTING=No
LOAD_HELPERS_ONLY=Yes
##############################################################################
# P A C K E T D I S P O S I T I O N
###############################################################################
BLACKLIST_DISPOSITION=DROP
MACLIST_DISPOSITION=REJECT
SFILTER_DISPOSITION=DROP
SMURF_DISPOSITION=DROP
TCP_FLAGS_DISPOSITION=DROP
#LAST LINE -- DO NOT REMOVE

View File

@@ -13,14 +13,6 @@
#############################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK
# PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL
#SECTION ESTABLISHED
#SECTION RELATED
SECTION NEW
# Don't allow connection pickup from the net
#
Invalid(DROP) net all
#
# Accept DNS connections from the firewall to the Internet
#

View File

@@ -1,11 +1,19 @@
###############################################################################
#
# Shorewall Version 4 -- /etc/shorewall6/shorewall6.conf
# Shorewall6 version 4 - Sample shorewall.conf for one-interface configuration.
# Copyright (C) 2006,2008 by the Shorewall Team
#
# For information about the settings in this file, type "man shorewall6.conf"
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# Manpage also online at
# http://www.shorewall.net/manpages6/shorewall6.conf.html
# See the file README.txt for further details.
#
# For information about the settings in this file, type "man shorewall6.conf"
#
# The manpage is also online at
# http://shorewall.net/manpages6/shorewall6.conf.html
###############################################################################
# S T A R T U P E N A B L E D
###############################################################################
@@ -22,163 +30,135 @@ VERBOSITY=1
# L O G G I N G
###############################################################################
BLACKLIST_LOGLEVEL=
LOG_VERBOSITY=2
LOGALLNEW=
LOGFILE=/var/log/messages
LOGFORMAT="Shorewall:%s:%s:"
LOGLIMIT=
LOGTAGONLY=No
MACLIST_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info
SMURF_LOG_LEVEL=info
STARTUP_LOG=/var/log/shorewall6-init.log
LOG_VERBOSITY=2
LOGFORMAT="Shorewall:%s:%s:"
LOGTAGONLY=No
LOGRATE=
LOGBURST=
LOGALLNEW=
BLACKLIST_LOGLEVEL=
TCP_FLAGS_LOG_LEVEL=info
SMURF_LOG_LEVEL=info
###############################################################################
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall6:/usr/share/shorewall6:/usr/share/shorewall
IP6TABLES=
IP=
IPSET=
MODULESDIR=
PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
RESTOREFILE=
SHOREWALL_SHELL=/bin/sh
SUBSYSLOCK=
TC=
MODULESDIR=
CONFIG_PATH=/etc/shorewall6/:/usr/share/shorewall6:/usr/share/shorewall
RESTOREFILE=
LOCKFILE=
###############################################################################
# D E F A U L T A C T I O N S / M A C R O S
###############################################################################
ACCEPT_DEFAULT="none"
DROP_DEFAULT="Drop"
NFQUEUE_DEFAULT="none"
QUEUE_DEFAULT="none"
REJECT_DEFAULT="Reject"
ACCEPT_DEFAULT="none"
QUEUE_DEFAULT="none"
NFQUEUE_DEFAULT="none"
###############################################################################
# R S H / R C P C O M M A N D S
###############################################################################
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
RSH_COMMAND='ssh ${root}@${system} ${command}'
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
###############################################################################
# F I R E W A L L O P T I O N S
###############################################################################
ACCOUNTING=Yes
ACCOUNTING_TABLE=filter
ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes
AUTOMAKE=No
BLACKLISTNEWONLY=Yes
CLAMPMSS=No
CLEAR_TC=Yes
COMPLETE=No
DELETE_THEN_ADD=Yes
DONT_LOAD=
DYNAMIC_BLACKLIST=Yes
EXPAND_POLICIES=Yes
EXPORTMODULES=Yes
FASTACCEPT=No
FORWARD_CLEAR_MARK=
HIGH_ROUTE_MARKS=No
IMPLICIT_CONTINUE=No
IP_FORWARDING=On
KEEP_RT_TABLES=Yes
LEGACY_FASTSTART=No
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter
MACLIST_TTL=
MANGLE_ENABLED=Yes
MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX=ko
MUTEX_TIMEOUT=60
OPTIMIZE=1
OPTIMIZE_ACCOUNTING=No
REQUIRE_INTERFACE=No
TC_ENABLED=No
TC_EXPERT=No
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
TRACK_PROVIDERS=Yes
CLEAR_TC=Yes
MARK_IN_FORWARD_CHAIN=No
CLAMPMSS=No
MUTEX_TIMEOUT=60
ADMINISABSENTMINDED=Yes
BLACKLISTNEWONLY=Yes
MODULE_SUFFIX=ko
FASTACCEPT=No
IMPLICIT_CONTINUE=No
HIGH_ROUTE_MARKS=No
OPTIMIZE=1
EXPORTPARAMS=No
EXPAND_POLICIES=Yes
KEEP_RT_TABLES=Yes
DELETE_THEN_ADD=Yes
DONT_LOAD=
AUTO_COMMENT=Yes
MANGLE_ENABLED=Yes
AUTOMAKE=No
WIDE_TC_MARKS=Yes
TRACK_PROVIDERS=Yes
ZONE2ZONE=2
ACCOUNTING=Yes
DYNAMIC_BLACKLIST=Yes
OPTIMIZE_ACCOUNTING=No
LOAD_HELPERS_ONLY=Yes
###############################################################################
# P A C K E T D I S P O S I T I O N
###############################################################################
BLACKLIST_DISPOSITION=DROP
MACLIST_DISPOSITION=REJECT
SFILTER_DISPOSITION=DROP
SMURF_DISPOSITION=DROP
TCP_FLAGS_DISPOSITION=DROP
#LAST LINE -- DO NOT REMOVE

View File

@@ -15,6 +15,6 @@
#ZONE TYPE OPTIONS IN OUT
# OPTIONS OPTIONS
fw firewall
net ipv6
loc ipv6
dmz ipv6
net ipv4
loc ipv4
dmz ipv4

View File

@@ -13,14 +13,6 @@
#############################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK
# PORT PORT(S) DEST LIMIT GROUP
#SECTION ALL
#SECTION ESTABLISHED
#SECTION RELATED
SECTION NEW
# Don't allow connection pickup from the net
#
Invalid(DROP) net all
#
# Accept DNS connections from the firewall to the network
#

View File

@@ -1,11 +1,19 @@
###############################################################################
#
# Shorewall Version 4 -- /etc/shorewall6/shorewall6.conf
# Shorewall version 3.4 - Sample shorewall.conf for one-interface configuration.
# Copyright (C) 2006 by the Shorewall Team
#
# For information about the settings in this file, type "man shorewall6.conf"
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# Manpage also online at
# http://www.shorewall.net/manpages6/shorewall6.conf.html
# See the file README.txt for further details.
#
# For information about the settings in this file, type "man shorewall6.conf"
#
# The manpage is also online at
# http://shorewall.net/manpages6/shorewall6.conf.html
###############################################################################
# S T A R T U P E N A B L E D
###############################################################################
@@ -22,163 +30,135 @@ VERBOSITY=1
# L O G G I N G
###############################################################################
BLACKLIST_LOGLEVEL=
LOG_VERBOSITY=2
LOGALLNEW=
LOGFILE=/var/log/messages
LOGFORMAT="Shorewall:%s:%s:"
LOGLIMIT=
LOGTAGONLY=No
MACLIST_LOG_LEVEL=info
SFILTER_LOG_LEVEL=info
SMURF_LOG_LEVEL=info
STARTUP_LOG=/var/log/shorewall6-init.log
LOG_VERBOSITY=2
LOGFORMAT="Shorewall:%s:%s:"
LOGTAGONLY=No
LOGRATE=
LOGBURST=
LOGALLNEW=
BLACKLIST_LOGLEVEL=
TCP_FLAGS_LOG_LEVEL=info
SMURF_LOG_LEVEL=info
###############################################################################
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH=/etc/shorewall6:/usr/share/shorewall6:/usr/share/shorewall
IP6TABLES=
IP=
IPSET=
MODULESDIR=
PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
RESTOREFILE=
SHOREWALL_SHELL=/bin/sh
SUBSYSLOCK=
TC=
MODULESDIR=
CONFIG_PATH=/etc/shorewall6/:/usr/share/shorewall6:/usr/share/shorewall/
RESTOREFILE=
LOCKFILE=
###############################################################################
# D E F A U L T A C T I O N S / M A C R O S
###############################################################################
ACCEPT_DEFAULT="none"
DROP_DEFAULT="Drop"
NFQUEUE_DEFAULT="none"
QUEUE_DEFAULT="none"
REJECT_DEFAULT="Reject"
ACCEPT_DEFAULT="none"
QUEUE_DEFAULT="none"
NFQUEUE_DEFAULT="none"
###############################################################################
# R S H / R C P C O M M A N D S
###############################################################################
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
RSH_COMMAND='ssh ${root}@${system} ${command}'
RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
###############################################################################
# F I R E W A L L O P T I O N S
###############################################################################
ACCOUNTING=Yes
ACCOUNTING_TABLE=filter
ADMINISABSENTMINDED=Yes
AUTO_COMMENT=Yes
AUTOMAKE=No
BLACKLISTNEWONLY=Yes
CLAMPMSS=No
CLEAR_TC=Yes
COMPLETE=No
DELETE_THEN_ADD=Yes
DONT_LOAD=
DYNAMIC_BLACKLIST=Yes
EXPAND_POLICIES=No
EXPORTMODULES=Yes
FASTACCEPT=No
FORWARD_CLEAR_MARK=
HIGH_ROUTE_MARKS=No
IMPLICIT_CONTINUE=No
IP_FORWARDING=On
KEEP_RT_TABLES=Yes
LEGACY_FASTSTART=No
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter
MACLIST_TTL=
MANGLE_ENABLED=Yes
MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX=ko
MUTEX_TIMEOUT=60
OPTIMIZE=1
OPTIMIZE_ACCOUNTING=No
REQUIRE_INTERFACE=No
TC_ENABLED=No
TC_EXPERT=No
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
TRACK_PROVIDERS=Yes
CLEAR_TC=Yes
MARK_IN_FORWARD_CHAIN=No
CLAMPMSS=No
MUTEX_TIMEOUT=60
ADMINISABSENTMINDED=Yes
BLACKLISTNEWONLY=Yes
MODULE_SUFFIX=ko
FASTACCEPT=No
IMPLICIT_CONTINUE=No
HIGH_ROUTE_MARKS=No
OPTIMIZE=1
EXPORTPARAMS=No
EXPAND_POLICIES=No
KEEP_RT_TABLES=Yes
DELETE_THEN_ADD=Yes
DONT_LOAD=
AUTO_COMMENT=Yes
MANGLE_ENABLED=Yes
AUTOMAKE=No
WIDE_TC_MARKS=Yes
TRACK_PROVIDERS=Yes
ZONE2ZONE=2
ACCOUNTING=Yes
DYNAMIC_BLACKLIST=Yes
OPTIMIZE_ACCOUNTING=No
LOAD_HELPERS_ONLY=Yes
###############################################################################
# P A C K E T D I S P O S I T I O N
###############################################################################
BLACKLIST_DISPOSITION=DROP
MACLIST_DISPOSITION=REJECT
SFILTER_DISPOSITION=DROP
SMURF_DISPOSITION=DROP
TCP_FLAGS_DISPOSITION=DROP
#LAST LINE -- DO NOT REMOVE

View File

@@ -1,341 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@@ -1 +0,0 @@
This is the Shorewall-init stable 4.4 branch of Git.

View File

@@ -1,196 +0,0 @@
#!/bin/sh
#
# ifupdown script for Shorewall-based products
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2010 - Tom Eastep (teastep@shorewall.net)
#
# Shorewall documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
Debian_SuSE_ppp() {
NEWPRODUCTS=
INTERFACE="$1"
case $0 in
/etc/ppp/ip-*)
#
# IPv4
#
for product in $PRODUCTS; do
case $product in
shorewall|shorewall-lite)
NEWPRODUCTS="$NEWPRODUCTS $product";
;;
esac
done
;;
/etc/ppp/ipv6-*)
#
# IPv6
#
for product in $PRODUCTS; do
case $product in
shorewall6|shorewall6-lite)
NEWPRODUCTS="$NEWPRODUCTS $product";
;;
esac
done
;;
*)
exit 0
;;
esac
PRODUCTS="$NEWPRODUCTS"
case $0 in
*up/*)
COMMAND=up
;;
*)
COMMAND=down
;;
esac
}
IFUPDOWN=0
PRODUCTS=
if [ -f /etc/default/shorewall-init ]; then
. /etc/default/shorewall-init
elif [ -f /etc/sysconfig/shorewall-init ]; then
. /etc/sysconfig/shorewall-init
fi
[ "$IFUPDOWN" = 1 -a -n "$PRODUCTS" ] || exit 0
if [ -f /etc/debian_version ]; then
case $0 in
/etc/ppp*)
#
# Debian ppp
#
Debian_SuSE_ppp
;;
*)
#
# Debian ifupdown system
#
INTERFACE="$IFACE"
if [ "$MODE" = start ]; then
COMMAND=up
elif [ "$MODE" = stop ]; then
COMMAND=down
else
exit 0
fi
case "$PHASE" in
pre-*)
exit 0
;;
esac
;;
esac
elif [ -f /etc/SuSE-release ]; then
case $0 in
/etc/ppp*)
#
# SUSE ppp
#
Debian_SuSE_ppp
;;
*)
#
# SuSE ifupdown system
#
INTERFACE="$2"
case $0 in
*if-up.d*)
COMMAND=up
;;
*if-down.d*)
COMMAND=down
;;
*)
exit 0
;;
esac
;;
esac
else
#
# Assume RedHat/Fedora/CentOS/Foobar/...
#
case $0 in
/etc/ppp*)
INTERFACE="$1"
case $0 in
*ip-up.local)
COMMAND=up
;;
*ip-down.local)
COMMAND=down
;;
*)
exit 0
;;
esac
;;
*)
#
# RedHat ifup/down system
#
INTERFACE="$1"
case $0 in
*ifup*)
COMMAND=up
;;
*ifdown*)
COMMAND=down
;;
*dispatcher.d*)
COMMAND="$2"
;;
*)
exit 0
;;
esac
;;
esac
fi
for PRODUCT in $PRODUCTS; do
VARDIR=/var/lib/$PRODUCT
[ -f /etc/$PRODUCT/vardir ] && . /etc/$PRODUCT/vardir
if [ -x $VARDIR/firewall ]; then
( . /usr/share/$PRODUCT/lib.base
mutex_on
${VARDIR}/firewall -V0 $COMMAND $INTERFACE || echo_notdone
mutex_off
)
fi
done
exit 0

View File

@@ -1,146 +0,0 @@
#!/bin/sh
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.4
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2010 - Tom Eastep (teastep@shorewall.net)
#
# On most distributions, this file should be called /etc/init.d/shorewall.
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
### BEGIN INIT INFO
# Provides: shorewall-init
# Required-Start: $local_fs
# X-Start-Before: $network
# Required-Stop: $local_fs
# X-Stop-After: $network
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Initialize the firewall at boot time
# Description: Place the firewall in a safe state at boot time prior to
# bringing up the network
### END INIT INFO
export VERBOSITY=0
if [ "$(id -u)" != "0" ]
then
echo "You must be root to start, stop or restart \"Shorewall \"."
exit 1
fi
echo_notdone () {
echo "not done."
exit 1
}
not_configured () {
echo "#### WARNING ####"
echo "the firewall won't be initialized unless it is configured"
if [ "$1" != "stop" ]
then
echo ""
echo "Please read about Debian specific customization in"
echo "/usr/share/doc/shorewall-init/README.Debian.gz."
fi
echo "#################"
exit 0
}
# check if shorewall-init is configured or not
if [ -f "/etc/default/shorewall-init" ]
then
. /etc/default/shorewall-init
if [ -z "$PRODUCTS" ]
then
not_configured
fi
else
not_configured
fi
# Initialize the firewall
shorewall_start () {
local product
local VARDIR
echo -n "Initializing \"Shorewall-based firewalls\": "
for product in $PRODUCTS; do
VARDIR=/var/lib/$product
[ -f /etc/$product/vardir ] && . /etc/$product/vardir
if [ -x ${VARDIR}/firewall ]; then
#
# Run in a sub-shell to avoid name collisions
#
(
. /usr/share/$product/lib.base
#
# Get mutex so the firewall state is stable
#
mutex_on
if ! ${VARDIR}/firewall status > /dev/null 2>&1; then
${VARDIR}/firewall stop || echo_notdone
fi
mutex_off
)
fi
done
echo "done."
return 0
}
# Clear the firewall
shorewall_stop () {
local product
local VARDIR
echo -n "Clearing \"Shorewall-based firewalls\": "
for product in $PRODUCTS; do
VARDIR=/var/lib/$product
[ -f /etc/$product/vardir ] && . /etc/$product/vardir
if [ -x ${VARDIR}/firewall ]; then
( . /usr/share/$product/lib.base
mutex_on
${VARDIR}/firewall clear || echo_notdone
mutex_off
)
fi
done
echo "done."
return 0
}
case "$1" in
start)
shorewall_start
;;
stop)
shorewall_stop
;;
reload|force-reload)
;;
*)
echo "Usage: /etc/init.d/shorewall-init {start|stop|reload|force-reload}"
exit 1
esac
exit 0

View File

@@ -1,121 +0,0 @@
#! /bin/bash
#
# 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:
# Default-Stop: 0 1 2 3 4 5 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
prog="shorewall-init"
logger="logger -i -t $prog"
lockfile="/var/lock/subsys/shorewall-init"
# Source function library.
. /etc/rc.d/init.d/functions
# Get startup options (override default)
OPTIONS=
# check if shorewall-init is configured or not
if [ -f "/etc/sysconfig/shorewall-init" ]; then
. /etc/sysconfig/shorewall-init
else
echo "/etc/sysconfig/shorewall-init not found"
exit 6
fi
# Initialize the firewall
start () {
local product
local vardir
if [ -z "$PRODUCTS" ]; then
echo "No firewalls configured for shorewall-init"
failure
return 6 #Not configured
fi
echo -n "Initializing \"Shorewall-based firewalls\": "
for product in $PRODUCTS; do
vardir=/var/lib/$product
[ -f /etc/$product/vardir ] && . /etc/$product/vardir
if [ -x ${vardir}/firewall ]; then
${vardir}/firewall stop 2>&1 | $logger
retval=${PIPESTATUS[0]}
[ retval -ne 0 ] && break
fi
done
if [ retval -eq 0 ]; then
touch $lockfile
success
else
failure
fi
echo
return $retval
}
# Clear the firewall
stop () {
local product
local vardir
echo -n "Clearing \"Shorewall-based firewalls\": "
for product in $PRODUCTS; do
vardir=/var/lib/$product
[ -f /etc/$product/vardir ] && . /etc/$product/vardir
if [ -x ${vardir}/firewall ]; then
${vardir}/firewall clear 2>&1 | $logger
retval=${PIPESTATUS[0]}
[ retval -ne 0 ] && break
fi
done
if [ retval -eq 0 ]; then
rm -f $lockfile
success
else
failure
fi
echo
return $retval
}
status_q() {
status > /dev/null 2>&1
}
case "$1" in
start)
status_q && exit 0
$1
;;
stop)
status_q || exit 0
$1
;;
restart|reload|force-reload)
echo "Not implemented"
exit 3
;;
condrestart|try-restart)
echo "Not implemented"
exit 3
;;
status)
status $prog
;;
*)
echo "Usage: /etc/init.d/shorewall-init {start|stop}"
exit 1
esac
exit 0

View File

@@ -1,115 +0,0 @@
#! /bin/bash
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.4
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2010 - Tom Eastep (teastep@shorewall.net)
#
# On most distributions, this file should be called /etc/init.d/shorewall.
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# chkconfig: - 09 91
#
### BEGIN INIT INFO
# Provides: shorewall-init
# Required-start: $local_fs
# Required-stop: $local_fs
# Default-Start: 2 3 5
# Default-Stop: 6
# Short-Description: Initialize the firewall at boot time
# Description: Place the firewall in a safe state at boot time
# prior to bringing up the network.
### END INIT INFO
if [ "$(id -u)" != "0" ]
then
echo "You must be root to start, stop or restart \"Shorewall \"."
exit 1
fi
# check if shorewall-init is configured or not
if [ -f "/etc/sysconfig/shorewall-init" ]
then
. /etc/sysconfig/shorewall-init
if [ -z "$PRODUCTS" ]
then
exit 0
fi
else
exit 0
fi
# Initialize the firewall
shorewall_start () {
local PRODUCT
local VARDIR
echo -n "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do
VARDIR=/var/lib/$PRODUCT
[ -f /etc/$PRODUCT/vardir ] && . /etc/$PRODUCT/vardir
if [ -x ${VARDIR}/firewall ]; then
if ! /sbin/$PRODUCT status > /dev/null 2>&1; then
${VARDIR}/firewall stop || echo_notdone
fi
fi
done
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
ipset -R < "$SAVE_IPSETS"
fi
return 0
}
# Clear the firewall
shorewall_stop () {
local PRODUCT
local VARDIR
echo -n "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do
VARDIR=/var/lib/$PRODUCT
[ -f /etc/$PRODUCT/vardir ] && . /etc/$PRODUCT/vardir
if [ -x ${VARDIR}/firewall ]; then
${VARDIR}/firewall clear || exit 1
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"
fi
fi
return 0
}
case "$1" in
start)
shorewall_start
;;
stop)
shorewall_stop
;;
*)
echo "Usage: /etc/init.d/shorewall-init {start|stop}"
exit 1
esac
exit 0

View File

@@ -1,391 +0,0 @@
#!/bin/sh
#
# Script to install Shoreline Firewall Init
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2000-2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2010 - Roberto C. Sanchez (roberto@connexer.com)
#
# Shorewall documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
VERSION=xxx #The Build script inserts the actual version.
usage() # $1 = exit status
{
ME=$(basename $0)
echo "usage: $ME"
echo " $ME -v"
echo " $ME -h"
exit $1
}
split() {
local ifs
ifs=$IFS
IFS=:
set -- $1
echo $*
IFS=$ifs
}
qt()
{
"$@" >/dev/null 2>&1
}
mywhich() {
local dir
for dir in $(split $PATH); do
if [ -x $dir/$1 ]; then
echo $dir/$1
return 0
fi
done
return 2
}
run_install()
{
if ! install $*; then
echo
echo "ERROR: Failed to install $*" >&2
exit 1
fi
}
cant_autostart()
{
echo
echo "WARNING: Unable to configure shorewall init to start automatically at boot" >&2
}
delete_file() # $1 = file to delete
{
rm -f $1
}
install_file() # $1 = source $2 = target $3 = mode
{
run_install $T $OWNERSHIP -m $3 $1 ${2}
}
[ -n "$DESTDIR" ] || DESTDIR="$PREFIX"
# DEST is the SysVInit script directory
# INIT is the name of the script in the $DEST directory
# ARGS is "yes" if we've already parsed an argument
#
ARGS=""
if [ -z "$DEST" ] ; then
DEST="/etc/init.d"
fi
if [ -z "$INIT" ] ; then
INIT="shorewall-init"
fi
while [ $# -gt 0 ] ; do
case "$1" in
-h|help|?)
usage 0
;;
-v)
echo "Shorewall Init Installer Version $VERSION"
exit 0
;;
*)
usage 1
;;
esac
shift
ARGS="yes"
done
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
[ -n "${LIBEXEC:=/usr/share}" ]
case "$LIBEXEC" in
/*)
;;
*)
LIBEXEC=/usr/${LIBEXEC}
;;
esac
#
# Determine where to install the firewall script
#
case $(uname) in
Darwin)
[ -z "$OWNER" ] && OWNER=root
[ -z "$GROUP" ] && GROUP=wheel
T=
;;
*)
[ -z "$OWNER" ] && OWNER=root
[ -z "$GROUP" ] && GROUP=root
;;
esac
OWNERSHIP="-o $OWNER -g $GROUP"
if [ -n "$DESTDIR" ]; then
if [ `id -u` != 0 ] ; then
echo "Not setting file owner/group permissions, not running as root."
OWNERSHIP=""
fi
install -d $OWNERSHIP -m 755 ${DESTDIR}${DEST}
elif [ -f /etc/debian_version ]; then
DEBIAN=yes
elif [ -f /etc/SuSE-release ]; then
SUSE=Yes
elif [ -f /etc/redhat-release ]; then
FEDORA=Yes
elif [ -f /etc/slackware-version ] ; then
echo "Shorewall-init is currently not supported on Slackware" >&2
exit 1
# DEST="/etc/rc.d"
# INIT="rc.firewall"
elif [ -f /etc/arch-release ] ; then
echo "Shorewall-init is currently not supported on Arch Linux" >&2
exit 1
# DEST="/etc/rc.d"
# INIT="shorewall-init"
# ARCHLINUX=yes
elif [ -d /etc/sysconfig/network-scripts/ ]; then
#
# Assume RedHat-based
#
REDHAT=Yes
else
echo "Unknown distribution: Shorewall-init support is not available" >&2
exit 1
fi
if [ -z "$DESTDIR" ]; then
if [ -f /lib/systemd/system ]; then
SYSTEMD=Yes
fi
elif [ -n "$SYSTEMD" ]; then
mkdir -p ${DESTDIR}/lib/systemd/system
fi
#
# Change to the directory containing this script
#
cd "$(dirname $0)"
echo "Installing Shorewall Init Version $VERSION"
#
# Check for /usr/share/shorewall-init/version
#
if [ -f ${DESTDIR}/usr/share/shorewall-init/version ]; then
first_install=""
else
first_install="Yes"
fi
#
# Install the Init Script
#
if [ -n "$DEBIAN" ]; then
install_file init.debian.sh ${DESTDIR}/etc/init.d/shorewall-init 0544
elif [ -n "$FEDORA" ]; then
install_file init.debian.sh ${DESTDIR}/etc/init.d/shorewall-init 0544
#elif [ -n "$ARCHLINUX" ]; then
# install_file init.archlinux.sh ${DESTDIR}${DEST}/$INIT 0544
else
install_file init.sh ${DESTDIR}${DEST}/$INIT 0544
fi
echo "Shorewall Init script installed in ${DESTDIR}${DEST}/$INIT"
#
# Install the .service file
#
if [ -n "$SYSTEMD" ]; then
run_install $OWNERSHIP -m 600 shorewall-init.service ${DESTDIR}/lib/systemd/system/shorewall-init.service
echo "Service file installed as ${DESTDIR}/lib/systemd/system/shorewall-init.service"
fi
#
# Create /usr/share/shorewall-init if needed
#
mkdir -p ${DESTDIR}/usr/share/shorewall-init
chmod 755 ${DESTDIR}/usr/share/shorewall-init
#
# Create the version file
#
echo "$VERSION" > ${DESTDIR}/usr/share/shorewall-init/version
chmod 644 ${DESTDIR}/usr/share/shorewall-init/version
#
# Remove and create the symbolic link to the init script
#
if [ -z "$DESTDIR" ]; then
rm -f /usr/share/shorewall-init/init
ln -s ${DEST}/${INIT} /usr/share/shorewall-init/init
fi
if [ -n "$DEBIAN" ]; then
if [ -n "${DESTDIR}" ]; then
mkdir -p ${DESTDIR}/etc/network/if-up.d/
mkdir -p ${DESTDIR}/etc/network/if-post-down.d/
fi
if [ ! -f ${DESTDIR}/etc/default/shorewall-init ]; then
if [ -n "${DESTDIR}" ]; then
mkdir ${DESTDIR}/etc/default
fi
install_file sysconfig ${DESTDIR}/etc/default/shorewall-init 0644
fi
else
if [ -n "$DESTDIR" ]; then
mkdir -p ${DESTDIR}/etc/sysconfig
if [ -z "$RPM" ]; then
if [ -n "$SUSE" ]; then
mkdir -p ${DESTDIR}/etc/sysconfig/network/if-up.d
mkdir -p ${DESTDIR}/etc/sysconfig/network/if-down.d
else
mkdir -p ${DESTDIR}/etc/NetworkManager/dispatcher.d
fi
fi
fi
if [ -d ${DESTDIR}/etc/sysconfig -a ! -f ${DESTDIR}/etc/sysconfig/shorewall-init ]; then
install_file sysconfig ${DESTDIR}/etc/sysconfig/shorewall-init 0644
fi
fi
#
# Install the ifupdown script
#
mkdir -p ${DESTDIR}${LIBEXEC}/shorewall-init
install_file ifupdown.sh ${DESTDIR}${LIBEXEC}/shorewall-init/ifupdown 0544
if [ -d ${DESTDIR}/etc/NetworkManager ]; then
install_file ifupdown.sh ${DESTDIR}/etc/NetworkManager/dispatcher.d/01-shorewall 0544
fi
if [ -n "$DEBIAN" ]; then
install_file ifupdown.sh ${DESTDIR}/etc/network/if-up.d/shorewall 0544
install_file ifupdown.sh ${DESTDIR}/etc/network/if-post-down.d/shorewall 0544
elif [ -n "$SUSE" ]; then
install_file ifupdown.sh ${DESTDIR}/etc/sysconfig/network/if-up.d/shorewall 0544
install_file ifupdown.sh ${DESTDIR}/etc/sysconfig/network/if-down.d/shorewall 0544
elif [ -n "$REDHAT" ]; then
if [ -f ${DESTDIR}/sbin/ifup-local -o -f ${DESTDIR}/sbin/ifdown-local ]; then
echo "WARNING: /sbin/ifup-local and/or /sbin/ifdown-local already exist; up/down events will not be handled"
else
install_file ifupdown.sh ${DESTDIR}/sbin/ifup-local 0544
install_file ifupdown.sh ${DESTDIR}/sbin/ifdown-local 0544
fi
fi
if [ -z "$DESTDIR" ]; then
if [ -n "$first_install" ]; then
if [ -n "$DEBIAN" ]; then
update-rc.d shorewall-init defaults
echo "Shorewall Init will start automatically at boot"
else
if [ -n "$SYSTEMD" ]; then
if systemctl enable shorewall-init; then
echo "Shorewall Init will start automatically at boot"
fi
elif [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
if insserv /etc/init.d/shorewall-init ; then
echo "Shorewall Init will start automatically at boot"
else
cant_autostart
fi
elif [ -x /sbin/chkconfig -o -x /usr/sbin/chkconfig ]; then
if chkconfig --add shorewall-init ; then
echo "Shorewall Init will start automatically in run levels as follows:"
chkconfig --list shorewall-init
else
cant_autostart
fi
elif [ -x /sbin/rc-update ]; then
if rc-update add shorewall-init default; then
echo "Shorewall Init will start automatically at boot"
else
cant_autostart
fi
elif [ "$INIT" != rc.firewall ]; then #Slackware starts this automatically
cant_autostart
fi
fi
fi
else
if [ -n "$first_install" ]; then
if [ -n "$DEBIAN" ]; then
if [ -n "${DESTDIR}" ]; then
mkdir -p ${DESTDIR}/etc/rcS.d
fi
ln -sf ../init.d/shorewall-init ${DESTDIR}/etc/rcS.d/S38shorewall-init
echo "Shorewall Init will start automatically at boot"
fi
fi
fi
if [ -f ${DESTDIR}/etc/ppp ]; then
if [ -n "$DEBIAN" ] -o -n "$SUSE" ]; then
for directory in ip-up.d ip-down.d ipv6-up.d ipv6-down.d; do
mkdir -p ${DESTDIR}/etc/ppp/$directory #SuSE doesn't create the IPv6 directories
cp -fp ${DESTDIR}${LIBEXEC}/shorewall-init/ifupdown ${DESTDIR}/etc/ppp/$directory/shorewall
done
elif [ -n "$REDHAT" ]; then
#
# Must use the dreaded ip_xxx.local file
#
for file in ip-up.local ip-down.local; do
FILE=${DESTDIR}/etc/ppp/$file
if [ -f $FILE ]; then
if fgrep -q Shorewall-based $FILE ; then
cp -fp ${DESTDIR}${LIBEXEC}/shorewall-init/ifupdown $FILE
else
echo "$FILE already exists -- ppp devices will not be handled"
break
fi
else
cp -fp ${DESTDIR}${LIBEXEC}/shorewall-init/ifupdown $FILE
fi
done
fi
fi
#
# Report Success
#
echo "shorewall Init Version $VERSION Installed"

View File

@@ -1,21 +0,0 @@
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.4
#
# Copyright 2011 Jonathan Underwood (jonathan.underwood@gmail.com)
#
[Unit]
Description=Shorewall IPv4 firewall
After=syslog.target
Before=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/sysconfig/shorewall-init
StandardOutput=syslog
ExecStart=/sbin/shorewall-init $OPTIONS start
ExecReload=/sbin/shorewall-init $OPTIONS restart
ExecStop=/sbin/shorewall-init $OPTIONS stop
[Install]
WantedBy=multi-user.target

View File

@@ -1,18 +0,0 @@
# List the Shorewall products that Shorewall-init is to
# initialize (space-separated list).
#
# Sample: PRODUCTS="shorewall shorewall6"
#
PRODUCTS=""
#
# Set this to 1 if you want Shorewall-init to react to
# ifup/ifdown and NetworkManager events
#
IFUPDOWN=0
#
# Set this to the name of the file that is to hold
# ipset contents. Shorewall-init will load those ipsets
# during 'start' and will save them there during 'stop'.
#
SAVE_IPSETS=""

View File

@@ -1,117 +0,0 @@
\#!/bin/sh
#
# Script to back uninstall Shoreline Firewall
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2000-2011 - Tom Eastep (teastep@shorewall.net)
#
# Shorewall documentation is available at http://shorewall.sourceforge.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Usage:
#
# You may only use this script to uninstall the version
# shown below. Simply run this script to remove Shorewall Firewall
VERSION=xxx #The Build script inserts the actual version
usage() # $1 = exit status
{
ME=$(basename $0)
echo "usage: $ME"
exit $1
}
qt()
{
"$@" >/dev/null 2>&1
}
remove_file() # $1 = file to restore
{
if [ -f $1 -o -L $1 ] ; then
rm -f $1
echo "$1 Removed"
fi
}
if [ -f /usr/share/shorewall-init/version ]; then
INSTALLED_VERSION="$(cat /usr/share/shorewall-init/version)"
if [ "$INSTALLED_VERSION" != "$VERSION" ]; then
echo "WARNING: Shorewall Init Version $INSTALLED_VERSION is installed"
echo " and this is the $VERSION uninstaller."
VERSION="$INSTALLED_VERSION"
fi
else
echo "WARNING: Shorewall Init Version $VERSION is not installed"
VERSION=""
fi
[ -n "${LIBEXEC:=/usr/share}" ]
echo "Uninstalling Shorewall Init $VERSION"
INITSCRIPT=/etc/init.d/shorewall-init
if [ -n "$INITSCRIPT" ]; then
if [ -x /usr/sbin/updaterc.d ]; then
updaterc.d shorewall-init remove
elif [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
insserv -r $INITSCRIPT
elif [ -x /sbin/chkconfig -o -x /usr/sbin/chkconfig ]; then
chkconfig --del $(basename $INITSCRIPT)
elif [ -x /sbin/systemctl ]; then
systemctl disable shorewall-init
else
rm -f /etc/rc*.d/*$(basename $INITSCRIPT)
fi
remove_file $INITSCRIPT
fi
[ "$(readlink -m -q /sbin/ifup-local)" = /usr/share/shorewall-init ] && remove_file /sbin/ifup-local
[ "$(readlink -m -q /sbin/ifdown-local)" = /usr/share/shorewall-init ] && remove_file /sbin/ifdown-local
remove_file /etc/default/shorewall-init
remove_file /etc/sysconfig/shorewall-init
remove_file /etc/NetworkManager/dispatcher.d/01-shorewall
remove_file /etc/network/if-up.d/shorewall
remove_file /etc/network/if-down.d/shorewall
remove_file /etc/sysconfig/network/if-up.d/shorewall
remove_file /etc/sysconfig/network/if-down.d/shorewall
remove_file /lib/systemd/system/shorewall.service
if [ -d /etc/ppp ]; then
for directory in ip-up.d ip-down.d ipv6-up.d ipv6-down.d; do
remove_file /etc/ppp/$directory/shorewall
done
for file in if-up.local if-down.local; do
if fgrep -q Shorewall-based /etc/ppp/$FILE; then
remove_file /etc/ppp/$FILE
fi
done
fi
rm -rf /usr/share/shorewall-init
rm -rf ${LIBEXEC}/shorewall-init
echo "Shorewall Init Uninstalled"

View File

@@ -2,8 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

View File

@@ -26,11 +26,4 @@ OPTIONS=""
#
INITLOG=/dev/null
#
# Set this to 1 to cause '/etc/init.d/shorewall-lite stop' to place the firewall in
# a safe state rather than to open it
#
SAFESTOP=0
# EOF

View File

@@ -17,9 +17,10 @@ SRWL=/sbin/shorewall-lite
SRWL_OPTS="-tvv"
test -n ${INITLOG:=/var/log/shorewall-lite-init.log}
[ "$INITLOG" = "/dev/null" ] && SHOREWALL_INIT_SCRIPT=1 || SHOREWALL_INIT_SCRIPT=0
[ "$INITLOG" eq "/dev/null" && SHOREWALL_INIT_SCRIPT=1 || SHOREWALL_INIT_SCRIPT=0
export SHOREWALL_INIT_SCRIPT
test -x $SRWL || exit 0
test -x $WAIT_FOR_IFUP || exit 0
test -n "$INITLOG" || {
@@ -87,11 +88,7 @@ shorewall_start () {
# stop the firewall
shorewall_stop () {
echo -n "Stopping \"Shorewall firewall\": "
if [ "$SAFESTOP" = 1 ]; then
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
else
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
fi
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
return 0
}

View File

@@ -1,112 +0,0 @@
#!/bin/sh
#
# Shorewall 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: VMware $time $named
# Required-Stop:
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: Packet filtering firewall
# Description: The Shoreline Firewall, more commonly known as "Shorewall", is a
# Netfilter (iptables) based firewall
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
prog="shorewall-lite"
shorewall="/sbin/$prog"
logger="logger -i -t $prog"
lockfile="/var/lock/subsys/$prog"
# Get startup options (override default)
OPTIONS=
if [ -f /etc/sysconfig/$prog ]; then
. /etc/sysconfig/$prog
fi
start() {
echo -n $"Starting Shorewall: "
$shorewall $OPTIONS start 2>&1 | $logger
retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then
touch $lockfile
success
else
failure
fi
echo
return $retval
}
stop() {
echo -n $"Stopping Shorewall: "
$shorewall $OPTIONS stop 2>&1 | $logger
retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then
rm -f $lockfile
success
else
failure
fi
echo
return $retval
}
restart() {
# Note that we don't simply stop and start since shorewall has a built in
# restart which stops the firewall if running and then starts it.
echo -n $"Restarting Shorewall: "
$shorewall $OPTIONS restart 2>&1 | $logger
retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then
touch $lockfile
success
else # Failed to start, clean up lock file if present
rm -f $lockfile
failure
fi
echo
return $retval
}
status(){
$shorewall status
return $?
}
status_q() {
status > /dev/null 2>&1
}
case "$1" in
start)
status_q && exit 0
$1
;;
stop)
status_q || exit 0
$1
;;
restart|reload|force-reload)
restart
;;
condrestart|try-restart)
status_q || exit 0
restart
;;
status)
$1
;;
*)
echo "Usage: $0 start|stop|reload|restart|force-reload|status"
exit 1
;;
esac

View File

@@ -4,7 +4,7 @@
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2000-2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# Shorewall documentation is available at http://shorewall.net
#
@@ -22,7 +22,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
VERSION=xxx #The Build script inserts the actual version
VERSION=4.4.9
usage() # $1 = exit status
{
@@ -82,16 +82,15 @@ delete_file() # $1 = file to delete
install_file() # $1 = source $2 = target $3 = mode
{
run_install $T $OWNERSHIP -m $3 $1 ${2}
run_install $OWNERSHIP -m $3 $1 ${2}
}
[ -n "$DESTDIR" ] || DESTDIR="$PREFIX"
#
# Parse the run line
#
# DEST is the SysVInit script directory
# INIT is the name of the script in the $DEST directory
# RUNLEVELS is the chkconfig parmeters for firewall
# ARGS is "yes" if we've already parsed an argument
#
ARGS=""
@@ -104,6 +103,10 @@ if [ -z "$INIT" ] ; then
INIT="shorewall-lite"
fi
if [ -z "$RUNLEVELS" ] ; then
RUNLEVELS=""
fi
while [ $# -gt 0 ] ; do
case "$1" in
-h|help|?)
@@ -123,26 +126,15 @@ done
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
[ -n "${LIBEXEC:=/usr/share}" ]
case "$LIBEXEC" in
/*)
;;
*)
LIBEXEC=/usr/${LIBEXEC}
;;
esac
#
# Determine where to install the firewall script
#
DEBIAN=
CYGWIN=
INSTALLD='-D'
T='-T'
case $(uname) in
CYGWIN*)
if [ -z "$DESTDIR" ]; then
if [ -z "$PREFIX" ]; then
DEST=
INIT=
fi
@@ -150,10 +142,6 @@ case $(uname) in
OWNER=$(id -un)
GROUP=$(id -gn)
;;
Darwin)
INSTALLD=
T=
;;
*)
[ -z "$OWNER" ] && OWNER=root
[ -z "$GROUP" ] && GROUP=root
@@ -162,18 +150,16 @@ esac
OWNERSHIP="-o $OWNER -g $GROUP"
if [ -n "$DESTDIR" ]; then
if [ -n "$PREFIX" ]; then
if [ `id -u` != 0 ] ; then
echo "Not setting file owner/group permissions, not running as root."
OWNERSHIP=""
fi
install -d $OWNERSHIP -m 755 ${DESTDIR}/sbin
install -d $OWNERSHIP -m 755 ${DESTDIR}${DEST}
install -d $OWNERSHIP -m 755 ${PREFIX}/sbin
install -d $OWNERSHIP -m 755 ${PREFIX}${DEST}
elif [ -d /etc/apt -a -e /usr/bin/dpkg ]; then
DEBIAN=yes
elif [ -f /etc/redhat-release ]; then
FEDORA=yes
elif [ -f /etc/slackware-version ] ; then
DEST="/etc/rc.d"
INIT="rc.firewall"
@@ -183,14 +169,6 @@ elif [ -f /etc/arch-release ] ; then
ARCHLINUX=yes
fi
if [ -z "$DESTDIR" ]; then
if [ -f /lib/systemd/system ]; then
SYSTEMD=Yes
fi
elif [ -n "$SYSTEMD" ]; then
mkdir -p ${DESTDIR}/lib/systemd/system
fi
#
# Change to the directory containing this script
#
@@ -201,217 +179,173 @@ echo "Installing Shorewall Lite Version $VERSION"
#
# Check for /etc/shorewall-lite
#
if [ -z "$DESTDIR" -a -d /etc/shorewall-lite ]; then
if [ -z "$PREFIX" -a -d /etc/shorewall-lite ]; then
[ -f /etc/shorewall-lite/shorewall.conf ] && \
mv -f /etc/shorewall-lite/shorewall.conf /etc/shorewall-lite/shorewall-lite.conf
else
rm -rf ${DESTDIR}/etc/shorewall-lite
rm -rf ${DESTDIR}/usr/share/shorewall-lite
rm -rf ${DESTDIR}/var/lib/shorewall-lite
[ "$LIBEXEC" = share ] || rm -rf /usr/share/shorewall-lite/shorecap /usr/share/shorecap
rm -rf ${PREFIX}/etc/shorewall-lite
rm -rf ${PREFIX}/usr/share/shorewall-lite
rm -rf ${PREFIX}/var/lib/shorewall-lite
fi
#
# Check for /sbin/shorewall-lite
#
if [ -f ${DESTDIR}/sbin/shorewall-lite ]; then
if [ -f ${PREFIX}/sbin/shorewall-lite ]; then
first_install=""
else
first_install="Yes"
fi
delete_file ${DESTDIR}/usr/share/shorewall-lite/xmodules
delete_file ${PREFIX}/usr/share/shorewall-lite/xmodules
install_file shorewall-lite ${DESTDIR}/sbin/shorewall-lite 0544
install_file shorewall-lite ${PREFIX}/sbin/shorewall-lite 0544 ${PREFIX}/var/lib/shorewall-lite-${VERSION}.bkout
eval sed -i \'``s\|g_libexec=.\*\|g_libexec=$LIBEXEC\|\' ${DESTDIR}/sbin/shorewall-lite
echo "Shorewall Lite control program installed in ${DESTDIR}/sbin/shorewall-lite"
echo "Shorewall Lite control program installed in ${PREFIX}/sbin/shorewall-lite"
#
# Install the Firewall Script
#
if [ -n "$DEBIAN" ]; then
install_file init.debian.sh ${DESTDIR}/etc/init.d/shorewall-lite 0544
elif [ -n "$FEDORA" ]; then
install_file init.fedora.sh ${DESTDIR}/etc/init.d/shorewall-lite 0544
install_file init.debian.sh /etc/init.d/shorewall-lite 0544 ${PREFIX}/usr/share/shorewall-lite-${VERSION}.bkout
elif [ -n "$ARCHLINUX" ]; then
install_file init.archlinux.sh ${DESTDIR}/${DEST}/$INIT 0544
install_file init.archlinux.sh ${PREFIX}${DEST}/$INIT 0544 ${PREFIX}/usr/share/shorewall-lite-${VERSION}.bkout
else
install_file init.sh ${DESTDIR}/${DEST}/$INIT 0544
install_file init.sh ${PREFIX}${DEST}/$INIT 0544 ${PREFIX}/usr/share/shorewall-lite-${VERSION}.bkout
fi
echo "Shorewall Lite script installed in ${DESTDIR}${DEST}/$INIT"
echo "Shorewall Lite script installed in ${PREFIX}${DEST}/$INIT"
#
# Create /etc/shorewall-lite, /usr/share/shorewall-lite and /var/lib/shorewall-lite if needed
#
mkdir -p ${DESTDIR}/etc/shorewall-lite
mkdir -p ${DESTDIR}/usr/share/shorewall-lite
mkdir -p ${DESTDIR}${LIBEXEC}/shorewall-lite
mkdir -p ${DESTDIR}/var/lib/shorewall-lite
mkdir -p ${PREFIX}/etc/shorewall-lite
mkdir -p ${PREFIX}/usr/share/shorewall-lite
mkdir -p ${PREFIX}/var/lib/shorewall-lite
chmod 755 ${DESTDIR}/etc/shorewall-lite
chmod 755 ${DESTDIR}/usr/share/shorewall-lite
chmod 755 ${PREFIX}/etc/shorewall-lite
chmod 755 ${PREFIX}/usr/share/shorewall-lite
if [ -n "$DESTDIR" ]; then
mkdir -p ${DESTDIR}/etc/logrotate.d
chmod 755 ${DESTDIR}/etc/logrotate.d
fi
#
# Install the .service file
#
if [ -n "$SYSTEMD" ]; then
run_install $OWNERSHIP -m 600 shorewall-lite.service ${DESTDIR}/lib/systemd/system/shorewall-lite.service
echo "Service file installed as ${DESTDIR}/lib/systemd/system/shorewall-lite.service"
if [ -n "$PREFIX" ]; then
mkdir -p ${PREFIX}/etc/logrotate.d
chmod 755 ${PREFIX}/etc/logrotate.d
fi
#
# Install the config file
#
if [ ! -f ${DESTDIR}/etc/shorewall-lite/shorewall-lite.conf ]; then
run_install $OWNERSHIP -m 0744 shorewall-lite.conf ${DESTDIR}/etc/shorewall-lite
echo "Config file installed as ${DESTDIR}/etc/shorewall-lite/shorewall-lite.conf"
if [ ! -f ${PREFIX}/etc/shorewall-lite/shorewall-lite.conf ]; then
run_install $OWNERSHIP -m 0744 shorewall-lite.conf ${PREFIX}/etc/shorewall-lite/shorewall-lite.conf
echo "Config file installed as ${PREFIX}/etc/shorewall-lite/shorewall-lite.conf"
fi
if [ -n "$ARCHLINUX" ] ; then
sed -e 's!LOGFILE=/var/log/messages!LOGFILE=/var/log/messages.log!' -i ${DESTDIR}/etc/shorewall-lite/shorewall.conf
sed -e 's!LOGFILE=/var/log/messages!LOGFILE=/var/log/messages.log!' -i ${PREFIX}/etc/shorewall-lite/shorewall.conf
fi
#
# Install the Makefile
#
run_install $OWNERSHIP -m 0600 Makefile ${DESTDIR}/etc/shorewall-lite
echo "Makefile installed as ${DESTDIR}/etc/shorewall-lite/Makefile"
run_install $OWNERSHIP -m 0600 Makefile ${PREFIX}/etc/shorewall-lite/Makefile
echo "Makefile installed as ${PREFIX}/etc/shorewall-lite/Makefile"
#
# Install the default config path file
#
install_file configpath ${DESTDIR}/usr/share/shorewall-lite/configpath 0644
echo "Default config path file installed as ${DESTDIR}/usr/share/shorewall-lite/configpath"
install_file configpath ${PREFIX}/usr/share/shorewall-lite/configpath 0644
echo "Default config path file installed as ${PREFIX}/usr/share/shorewall-lite/configpath"
#
# Install the libraries
#
for f in lib.* ; do
if [ -f $f ]; then
install_file $f ${DESTDIR}/usr/share/shorewall-lite/$f 0644
echo "Library ${f#*.} file installed as ${DESTDIR}/usr/share/shorewall-lite/$f"
install_file $f ${PREFIX}/usr/share/shorewall-lite/$f 0644
echo "Library ${f#*.} file installed as ${PREFIX}/usr/share/shorewall-lite/$f"
fi
done
ln -sf lib.base ${DESTDIR}/usr/share/shorewall-lite/functions
ln -sf lib.base ${PREFIX}/usr/share/shorewall-lite/functions
echo "Common functions linked through ${DESTDIR}/usr/share/shorewall-lite/functions"
echo "Common functions linked through ${PREFIX}/usr/share/shorewall-lite/functions"
#
# Install Shorecap
#
install_file shorecap ${DESTDIR}${LIBEXEC}/shorewall-lite/shorecap 0755
install_file shorecap ${PREFIX}/usr/share/shorewall-lite/shorecap 0755
echo
echo "Capability file builder installed in ${DESTDIR}${LIBEXEC}/shorewall-lite/shorecap"
echo "Capability file builder installed in ${PREFIX}/usr/share/shorewall-lite/shorecap"
#
# Install wait4ifup
#
if [ -f wait4ifup ]; then
install_file wait4ifup ${DESTDIR}${LIBEXEC}/shorewall-lite/wait4ifup 0755
install_file wait4ifup ${PREFIX}/usr/share/shorewall-lite/wait4ifup 0755
echo
echo "wait4ifup installed in ${DESTDIR}${LIBEXEC}/shorewall-lite/wait4ifup"
fi
echo
echo "wait4ifup installed in ${PREFIX}/usr/share/shorewall-lite/wait4ifup"
#
# Install the Modules files
# Install the Modules file
#
if [ -f modules ]; then
run_install $OWNERSHIP -m 0600 modules ${DESTDIR}/usr/share/shorewall-lite
echo "Modules file installed as ${DESTDIR}/usr/share/shorewall-lite/modules"
fi
if [ -f helpers ]; then
run_install $OWNERSHIP -m 0600 helpers ${DESTDIR}/usr/share/shorewall-lite
echo "Helper modules file installed as ${DESTDIR}/usr/share/shorewall-lite/helpers"
fi
for f in modules.*; do
run_install $OWNERSHIP -m 0644 $f ${DESTDIR}/usr/share/shorewall-lite/$f
echo "Module file $f installed as ${DESTDIR}/usr/share/shorewall-lite/$f"
done
run_install $OWNERSHIP -m 0600 modules ${PREFIX}/usr/share/shorewall-lite/modules
echo "Modules file installed as ${PREFIX}/usr/share/shorewall-lite/modules"
#
# Install the Man Pages
#
if [ -d manpages ]; then
cd manpages
cd manpages
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}/usr/share/man/man5/ ${DESTDIR}/usr/share/man/man8/
for f in *.5; do
gzip -c $f > $f.gz
run_install -D -m 644 $f.gz ${PREFIX}/usr/share/man/man5/$f.gz
echo "Man page $f.gz installed to ${PREFIX}/usr/share/man/man5/$f.gz"
done
for f in *.5; do
gzip -c $f > $f.gz
run_install $T $INSTALLD $OWNERSHIP -m 0644 $f.gz ${DESTDIR}/usr/share/man/man5/$f.gz
echo "Man page $f.gz installed to ${DESTDIR}/usr/share/man/man5/$f.gz"
done
for f in *.8; do
gzip -c $f > $f.gz
run_install -D -m 644 $f.gz ${PREFIX}/usr/share/man/man8/$f.gz
echo "Man page $f.gz installed to ${PREFIX}/usr/share/man/man8/$f.gz"
done
for f in *.8; do
gzip -c $f > $f.gz
run_install $T $INSTALLD $OWNERSHIP -m 0644 $f.gz ${DESTDIR}/usr/share/man/man8/$f.gz
echo "Man page $f.gz installed to ${DESTDIR}/usr/share/man/man8/$f.gz"
done
cd ..
cd ..
echo "Man Pages Installed"
echo "Man Pages Installed"
fi
if [ -d ${DESTDIR}/etc/logrotate.d ]; then
run_install $OWNERSHIP -m 0644 logrotate ${DESTDIR}/etc/logrotate.d/shorewall-lite
echo "Logrotate file installed as ${DESTDIR}/etc/logrotate.d/shorewall-lite"
if [ -d ${PREFIX}/etc/logrotate.d ]; then
run_install $OWNERSHIP -m 0644 logrotate ${PREFIX}/etc/logrotate.d/shorewall-lite
echo "Logrotate file installed as ${PREFIX}/etc/logrotate.d/shorewall-lite"
fi
#
# Create the version file
#
echo "$VERSION" > ${DESTDIR}/usr/share/shorewall-lite/version
chmod 644 ${DESTDIR}/usr/share/shorewall-lite/version
echo "$VERSION" > ${PREFIX}/usr/share/shorewall-lite/version
chmod 644 ${PREFIX}/usr/share/shorewall-lite/version
#
# Remove and create the symbolic link to the init script
#
if [ -z "$DESTDIR" ]; then
if [ -z "$PREFIX" ]; then
rm -f /usr/share/shorewall-lite/init
ln -s ${DEST}/${INIT} /usr/share/shorewall-lite/init
fi
if [ -z "$DESTDIR" ]; then
if [ -z "$PREFIX" ]; then
touch /var/log/shorewall-lite-init.log
if [ -n "$first_install" ]; then
if [ -n "$DEBIAN" ]; then
run_install $OWNERSHIP -m 0644 default.debian /etc/default/shorewall-lite
update-rc.d shorewall-lite defaults
if [ -x /sbin/insserv ]; then
insserv /etc/init.d/shorewall-lite
else
ln -s ../init.d/shorewall-lite /etc/rcS.d/S40shorewall-lite
fi
ln -s ../init.d/shorewall-lite /etc/rcS.d/S40shorewall-lite
echo "Shorewall Lite will start automatically at boot"
else
if [ -n "$SYSTEMD" ]; then
if systemctl enable shorewall-lite; then
echo "Shorewall Lite will start automatically at boot"
fi
elif [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
if [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
if insserv /etc/init.d/shorewall-lite ; then
echo "Shorewall Lite will start automatically at boot"
else

View File

@@ -1,10 +1,10 @@
#!/bin/sh
#
# Shorewall Lite Packet Filtering Firewall Control Program - V4.4
# Shorewall Lite Packet Filtering Firewall Control Program - V4.1
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2006,2007,2008,2009,2010,2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# This file should be placed in /sbin/shorewall-lite.
#
@@ -94,9 +94,9 @@ get_config() {
[ -z "$LOGFILE" ] && LOGFILE=/var/log/messages
if ( ps ax 2> /dev/null | grep -v grep | qt grep 'syslogd.*-C' ) ; then
g_logread="logread | tac"
LOGREAD="logread | tac"
elif [ -r $LOGFILE ]; then
g_logread="tac $LOGFILE"
LOGREAD="tac $LOGFILE"
else
echo "LOGFILE ($LOGFILE) does not exist!" >&2
exit 2
@@ -113,6 +113,10 @@ get_config() {
[ -n "$FW" ] || FW=fw
[ -n "LOGFORMAT" ] && LOGFORMAT="${LOGFORMAT%%%*}"
[ -n "$LOGFORMAT" ] || LOGFORMAT="Shorewall:"
if [ -n "$IPTABLES" ]; then
if [ ! -x "$IPTABLES" ]; then
echo " ERROR: The program specified in IPTABLES does not exist or is not executable" >&2
@@ -141,12 +145,6 @@ get_config() {
[ -n "$g_use_verbosity" ] && VERBOSITY=$g_use_verbosity || VERBOSITY=$(($g_verbose_offset + $VERBOSITY))
if [ $VERBOSITY -lt -1 ]; then
VERBOSITY=-1
elif [ $VERBOSITY -gt 2 ]; then
VERBOSITY=2
fi
g_hostname=$(hostname 2> /dev/null)
IP=$(mywhich ip 2> /dev/null)
@@ -177,15 +175,6 @@ verify_firewall_script() {
fi
}
#
# Fatal error
#
startup_error() {
echo " ERROR: $@" >&2
kill $$
exit 1
}
#
# Start Command Executor
#
@@ -363,7 +352,7 @@ usage() # $1 = exit status
echo "where <command> is one of:"
echo " add <interface>[:<host-list>] ... <zone>"
echo " allow <address> ..."
echo " clear"
echo " clear [ -f ]"
echo " delete <interface>[:<host-list>] ... <zone>"
echo " drop <address> ..."
echo " dump [ -x ]"
@@ -394,62 +383,13 @@ usage() # $1 = exit status
echo " show vardir"
echo " show zones"
echo " start [ -f ] [ -p ] [ <directory> ]"
echo " stop"
echo " stop [ -f ]"
echo " status"
echo " version [ -a ]"
echo
exit $1
}
version_command() {
local finished
finished=0
local all
all=
local product
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=
;;
a*)
all=Yes
option=${option#a}
;;
*)
usage 1
;;
esac
done
shift
;;
*)
finished=1
;;
esac
done
[ $# -gt 0 ] && usage 1
echo $SHOREWALL_VERSION
if [ -n "$all" ]; then
for product in shorewall shorewall6 shorewall6-lite shorewall-init; do
if [ -f /usr/share/$product/version ]; then
echo "$product: $(cat /usr/share/$product/version)"
fi
done
fi
}
#
# Execution begins here
#
@@ -474,13 +414,6 @@ g_use_verbosity=
g_noroutes=
g_timestamp=
g_recovering=
g_logread=
#
# Make sure that these variables are cleared
#
VERBOSE=
VERBOSITY=
finished=0
@@ -570,7 +503,6 @@ MUTEX_TIMEOUT=
SHAREDIR=/usr/share/shorewall-lite
CONFDIR=/etc/shorewall-lite
g_product="Shorewall Lite"
g_libexec=share
[ -f ${CONFDIR}/vardir ] && . ${CONFDIR}/vardir ]
@@ -647,12 +579,14 @@ case "$COMMAND" in
shift
start_command $@
;;
stop|reset|clear)
stop|clear)
[ $# -ne 1 ] && usage 1
verify_firewall_script
[ -n "$nolock" ] || mutex_on
run_it $g_firewall $debugging $COMMAND
[ -n "$nolock" ] || mutex_off
run_it $g_firewall $debugging $nolock $COMMAND
;;
reset)
verify_firewall_script
run_it $SHOREWALL_SHELL $g_firewall $debugging $nolock $@
;;
restart)
shift
@@ -678,7 +612,7 @@ case "$COMMAND" in
if [ -f ${VARDIR}/state ]; then
state="$(cat ${VARDIR}/state)"
case $state in
Stopped*|Closed*|Clear*)
Stopped*|Clear*)
status=3
;;
esac
@@ -699,8 +633,7 @@ case "$COMMAND" in
hits_command $@
;;
version)
shift
version_command $@
echo $SHOREWALL_VERSION Lite
;;
logwatch)
logwatch_command $@
@@ -794,9 +727,14 @@ case "$COMMAND" in
g_restorepath=${VARDIR}/$RESTOREFILE
if [ -x $g_restorepath ]; then
if [ -x ${g_restorepath}-ipsets ]; then
rm -f ${g_restorepath}-ipsets
echo " ${g_restorepath}-ipsets removed"
fi
rm -f $g_restorepath
rm -f ${g_restorepath}-iptables
rm -f ${g_restorepath}-ipsets
echo " $g_restorepath removed"
elif [ -f $g_restorepath ]; then
echo " $g_restorepath exists and is not a saved Shorewall configuration"

View File

@@ -21,7 +21,6 @@
###############################################################################
# V E R B O S I T Y
###############################################################################
VERBOSITY=
###############################################################################
@@ -30,6 +29,8 @@ VERBOSITY=
LOGFILE=
LOGFORMAT=
###############################################################################
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################

View File

@@ -1,21 +0,0 @@
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.4
#
# Copyright 2011 Jonathan Underwood (jonathan.underwood@gmail.com)
#
[Unit]
Description=Shorewall IPv4 firewall (lite)
After=syslog.target
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/sysconfig/shorewall-lite
StandardOutput=syslog
ExecStart=/sbin/shorewall-lite $OPTIONS start
ExecReload=/sbin/shorewall-lite $OPTIONS restart
ExecStop=/sbin/shorewall-lite $OPTIONS stop
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,331 @@
%define name shorewall-lite
%define version 4.4.9
%define release 0base
Summary: Shoreline Firewall Lite is an iptables-based firewall for Linux systems.
Name: %{name}
Version: %{version}
Release: %{release}
License: GPLv2
Packager: Tom Eastep <teastep@shorewall.net>
Group: Networking/Utilities
Source: %{name}-%{version}.tgz
URL: http://www.shorewall.net/
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Requires: iptables iproute
%description
The Shoreline Firewall, more commonly known as "Shorewall", is a Netfilter
(iptables) based firewall that can be used on a dedicated firewall system,
a multi-function gateway/ router/server or on a standalone GNU/Linux system.
Shorewall Lite is a companion product to Shorewall that allows network
administrators to centralize the configuration of Shorewall-based firewalls.
%prep
%setup
%build
%install
export PREFIX=$RPM_BUILD_ROOT ; \
export OWNER=`id -n -u` ; \
export GROUP=`id -n -g` ;\
./install.sh
%clean
rm -rf $RPM_BUILD_ROOT
%pre
if [ -f /etc/shorewall-lite/shorewall.conf ]; then
cp -fa /etc/shorewall-lite/shorewall.conf /etc/shorewall-lite/shorewall.conf.rpmsave
fi
%post
if [ $1 -eq 1 ]; then
if [ -x /sbin/insserv ]; then
/sbin/insserv /etc/rc.d/shorewall-lite
elif [ -x /sbin/chkconfig ]; then
/sbin/chkconfig --add shorewall-lite;
fi
elif [ -f /etc/shorewall-lite/shorewall.conf.rpmsave ]; then
mv -f /etc/shorewall-lite/shorewall-lite.conf /etc/shorewall-lite/shorewall-lite.conf.rpmnew
mv -f /etc/shorewall-lite/shorewall.conf.rpmsave /etc/shorewall-lite/shorewall-lite.conf
echo "/etc/shorewall-lite/shorewall.conf retained as /etc/shorewall-lite/shorewall-lite.conf"
echo "/etc/shorewall-lite/shorewall-lite.conf installed as /etc/shorewall-lite/shorewall-lite.conf.rpmnew"
fi
%preun
if [ $1 -eq 0 ]; then
if [ -x /sbin/insserv ]; then
/sbin/insserv -r /etc/init.d/shorewall-lite
elif [ -x /sbin/chkconfig ]; then
/sbin/chkconfig --del shorewall-lite
fi
fi
%files
%defattr(0644,root,root,0755)
%attr(0755,root,root) %dir /etc/shorewall-lite
%attr(0644,root,root) %config(noreplace) /etc/shorewall-lite/shorewall-lite.conf
%attr(0644,root,root) /etc/shorewall-lite/Makefile
%attr(0544,root,root) /etc/init.d/shorewall-lite
%attr(0755,root,root) %dir /usr/share/shorewall-lite
%attr(0700,root,root) %dir /var/lib/shorewall-lite
%attr(0644,root,root) /etc/logrotate.d/shorewall-lite
%attr(0755,root,root) /sbin/shorewall-lite
%attr(0644,root,root) /usr/share/shorewall-lite/version
%attr(0644,root,root) /usr/share/shorewall-lite/configpath
%attr(- ,root,root) /usr/share/shorewall-lite/functions
%attr(0644,root,root) /usr/share/shorewall-lite/lib.base
%attr(0644,root,root) /usr/share/shorewall-lite/lib.cli
%attr(0644,root,root) /usr/share/shorewall-lite/lib.common
%attr(0644,root,root) /usr/share/shorewall-lite/modules
%attr(0544,root,root) /usr/share/shorewall-lite/shorecap
%attr(0755,root,root) /usr/share/shorewall-lite/wait4ifup
%attr(0644,root,root) %{_mandir}/man5/shorewall-lite.conf.5.gz
%attr(0644,root,root) %{_mandir}/man5/shorewall-lite-vardir.5.gz
%attr(0644,root,root) %{_mandir}/man8/shorewall-lite.8.gz
%doc COPYING changelog.txt releasenotes.txt
%changelog
* Mon May 03 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.9-0base
* Sun May 02 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.9-0RC2
* Sun Apr 25 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.9-0RC1
* Sat Apr 24 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.9-0Beta5
* Fri Apr 16 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.9-0Beta4
* Fri Apr 09 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.9-0Beta3
* Thu Apr 08 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.9-0Beta2
* Sat Mar 20 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.9-0Beta1
* Fri Mar 19 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.8-0base
* Tue Mar 16 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.8-0RC2
* Mon Mar 08 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.8-0RC1
* Sun Feb 28 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.8-0Beta2
* Thu Feb 11 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.8-0Beta1
* Fri Feb 05 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.7-0base
* Tue Feb 02 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.7-0RC2
* Wed Jan 27 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.7-0RC1
* Mon Jan 25 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.7-0Beta4
* Fri Jan 22 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.7-0Beta3
* Fri Jan 22 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.7-0Beta2
* Sun Jan 17 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.7-0Beta1
* Wed Jan 13 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.6-0base
* Tue Jan 12 2010 Tom Eastep tom@shorewall.net
- Updated to 4.4.6-0Beta1
* Thu Dec 24 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.5-0base
* Sat Nov 21 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.4-0base
* Fri Nov 13 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.4-0Beta2
* Wed Nov 11 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.4-0Beta1
* Tue Nov 03 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.3-0base
* Sun Sep 06 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.2-0base
* Fri Sep 04 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.2-0base
* Fri Aug 14 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.1-0base
* Mon Aug 03 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.0-0base
* Tue Jul 28 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.0-0RC2
* Sun Jul 12 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.0-0RC1
* Thu Jul 09 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.0-0Beta4
* Sat Jun 27 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.0-0Beta3
* Mon Jun 15 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.0-0Beta2
* Fri Jun 12 2009 Tom Eastep tom@shorewall.net
- Updated to 4.4.0-0Beta1
* Sun Jun 07 2009 Tom Eastep tom@shorewall.net
- Updated to 4.3.13-0base
* Fri Jun 05 2009 Tom Eastep tom@shorewall.net
- Updated to 4.3.12-0base
* Sun May 10 2009 Tom Eastep tom@shorewall.net
- Updated to 4.3.11-0base
* Sun Apr 19 2009 Tom Eastep tom@shorewall.net
- Updated to 4.3.10-0base
* Sat Apr 11 2009 Tom Eastep tom@shorewall.net
- Updated to 4.3.9-0base
* Tue Mar 17 2009 Tom Eastep tom@shorewall.net
- Updated to 4.3.8-0base
* Sun Mar 01 2009 Tom Eastep tom@shorewall.net
- Updated to 4.3.7-0base
* Fri Feb 27 2009 Tom Eastep tom@shorewall.net
- Updated to 4.3.6-0base
* Sun Feb 22 2009 Tom Eastep tom@shorewall.net
- Updated to 4.3.5-0base
* Wed Feb 04 2009 Tom Eastep tom@shorewall.net
- Updated to 4.2.6-0base
* Thu Jan 29 2009 Tom Eastep tom@shorewall.net
- Updated to 4.2.6-0base
* Tue Jan 06 2009 Tom Eastep tom@shorewall.net
- Updated to 4.2.5-0base
* Thu Dec 25 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.4-0base
* Fri Dec 05 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.3-0base
* Wed Nov 05 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.2-0base
* Wed Oct 08 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.1-0base
* Fri Oct 03 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.0-0base
* Tue Sep 23 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.0-0RC4
* Mon Sep 15 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.0-0RC3
* Mon Sep 08 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.0-0RC2
* Tue Aug 19 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.0-0RC1
* Thu Jul 03 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.0-0Beta3
* Mon Jun 02 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.0-0Beta2
* Wed May 07 2008 Tom Eastep tom@shorewall.net
- Updated to 4.2.0-0Beta1
* Mon Apr 28 2008 Tom Eastep tom@shorewall.net
- Updated to 4.1.8-0base
* Mon Mar 24 2008 Tom Eastep tom@shorewall.net
- Updated to 4.1.7-0base
* Thu Mar 13 2008 Tom Eastep tom@shorewall.net
- Updated to 4.1.6-0base
* Tue Feb 05 2008 Tom Eastep tom@shorewall.net
- Updated to 4.1.5-0base
* Fri Jan 04 2008 Tom Eastep tom@shorewall.net
- Updated to 4.1.4-0base
* Wed Dec 12 2007 Tom Eastep tom@shorewall.net
- Updated to 4.1.3-0base
* Fri Dec 07 2007 Tom Eastep tom@shorewall.net
- Updated to 4.1.3-1
* Tue Nov 27 2007 Tom Eastep tom@shorewall.net
- Updated to 4.1.2-1
* Wed Nov 21 2007 Tom Eastep tom@shorewall.net
- Updated to 4.1.1-1
* Mon Nov 19 2007 Tom Eastep tom@shorewall.net
- Updated to 4.1.0-1
* Thu Nov 15 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.6-1
* Sat Nov 10 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.6-0RC3
* Wed Nov 07 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.6-0RC2
* Thu Oct 25 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.6-0RC1
* Tue Oct 03 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.5-1
* Wed Sep 05 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.4-1
* Mon Aug 13 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.3-1
* Thu Aug 09 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.2-1
* Sat Jul 21 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.1-1
* Wed Jul 11 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.0-1
* Sun Jul 08 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.0-0RC2
* Mon Jul 02 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.0-0RC1
* Sun Jun 24 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.0-0Beta7
* Wed Jun 20 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.0-0Beta6
* Thu Jun 14 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.0-0Beta5
* Fri Jun 08 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.0-0Beta4
* Tue Jun 05 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.0-0Beta3
* Tue May 15 2007 Tom Eastep tom@shorewall.net
- Updated to 4.0.0-0Beta1
* Fri May 11 2007 Tom Eastep tom@shorewall.net
- Updated to 3.9.7-1
* Sat May 05 2007 Tom Eastep tom@shorewall.net
- Updated to 3.9.6-1
* Mon Apr 30 2007 Tom Eastep tom@shorewall.net
- Updated to 3.9.5-1
* Mon Apr 23 2007 Tom Eastep tom@shorewall.net
- Updated to 3.9.4-1
* Wed Apr 18 2007 Tom Eastep tom@shorewall.net
- Updated to 3.9.3-1
* Sat Apr 14 2007 Tom Eastep tom@shorewall.net
- Updated to 3.9.2-1
* Sat Apr 07 2007 Tom Eastep tom@shorewall.net
- Updated to 3.9.1-1
* Thu Mar 15 2007 Tom Eastep tom@shorewall.net
- Updated to 3.4.1-1
* Sat Mar 10 2007 Tom Eastep tom@shorewall.net
- Updated to 3.4.0-1
* Sun Feb 25 2007 Tom Eastep tom@shorewall.net
- Updated to 3.4.0-0RC3
* Sun Feb 04 2007 Tom Eastep tom@shorewall.net
- Updated to 3.4.0-0RC2
* Wed Jan 24 2007 Tom Eastep tom@shorewall.net
- Updated to 3.4.0-0RC1
* Mon Jan 22 2007 Tom Eastep tom@shorewall.net
- Updated to 3.4.0-0Beta3
* Wed Jan 03 2007 Tom Eastep tom@shorewall.net
- Updated to 3.4.0-0Beta2
- Handle rename of shorewall.conf
* Thu Dec 14 2006 Tom Eastep tom@shorewall.net
- Updated to 3.4.0-0Beta1
* Sat Nov 25 2006 Tom Eastep tom@shorewall.net
- Added shorewall-exclusion(5)
- Updated to 3.3.6-1
* Sun Nov 19 2006 Tom Eastep tom@shorewall.net
- Updated to 3.3.5-1
* Sun Oct 29 2006 Tom Eastep tom@shorewall.net
- Updated to 3.3.4-1
* Mon Oct 16 2006 Tom Eastep tom@shorewall.net
- Updated to 3.3.3-1
* Sat Sep 30 2006 Tom Eastep tom@shorewall.net
- Updated to 3.3.2-1
* Wed Aug 30 2006 Tom Eastep tom@shorewall.net
- Updated to 3.3.1-1
* Wed Aug 09 2006 Tom Eastep tom@shorewall.net
- Updated to 3.3.0-1
* Wed Aug 09 2006 Tom Eastep tom@shorewall.net
- Updated to 3.3.0-1

View File

@@ -4,7 +4,7 @@
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2000-2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# Shorewall documentation is available at http://shorewall.sourceforge.net
#
@@ -26,7 +26,7 @@
# You may only use this script to uninstall the version
# shown below. Simply run this script to remove Shorewall Firewall
VERSION=xxx #The Build script inserts the actual version
VERSION=4.4.9
usage() # $1 = exit status
{
@@ -72,8 +72,6 @@ else
VERSION=""
fi
[ -n "${LIBEXEC:=/usr/share}" ]
echo "Uninstalling Shorewall Lite $VERSION"
if qt iptables -L shorewall -n && [ ! -f /sbin/shorewall ]; then
@@ -81,20 +79,16 @@ if qt iptables -L shorewall -n && [ ! -f /sbin/shorewall ]; then
fi
if [ -L /usr/share/shorewall-lite/init ]; then
FIREWALL=$(readlink -m -q /usr/share/shorewall-lite/init)
FIREWALL=$(ls -l /usr/share/shorewall-lite/init | sed 's/^.*> //')
else
FIREWALL=/etc/init.d/shorewall-lite
fi
if [ -n "$FIREWALL" ]; then
if [ -x /usr/sbin/updaterc.d ]; then
updaterc.d shorewall-lite remove
elif [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
if [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
insserv -r $FIREWALL
elif [ -x /sbin/chkconfig -o -x /usr/sbin/chkconfig ]; then
chkconfig --del $(basename $FIREWALL)
elif [ -x /sbin/systemctl ]; then
systemctl disable shorewall-lite
else
rm -f /etc/rc*.d/*$(basename $FIREWALL)
fi
@@ -111,11 +105,9 @@ rm -rf /etc/shorewall-lite-*.bkout
rm -rf /var/lib/shorewall-lite
rm -rf /var/lib/shorewall-lite-*.bkout
rm -rf /usr/share/shorewall-lite
rm -rf ${LIBEXEC}/shorewall-lite
rm -rf /usr/share/shorewall-lite-*.bkout
rm -f /etc/logrotate.d/shorewall-lite
rm -f /lib/systemd/system/shorewall-lite.service
echo "Shorewall Lite Uninstalled"
echo "Shorewall Uninstalled"

View File

@@ -2,8 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

View File

@@ -224,7 +224,7 @@ while : ; do
# One of the interfaces changed state -- restart Shorewall
#
echo $if1_state > $VARDIR/${IF1}.status
echo $if2_state > $VARDIR/${IF2}.status
echo $if2_state > $VARDIR/${IF2}.status
eval $COMMAND
state_changed=
fi

View File

@@ -32,7 +32,7 @@
### BEGIN INIT INFO
# Provides: swping
# Required-Start: shorewall
# Should-Start:
# Should-Start:
# Required-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
@@ -87,7 +87,7 @@ case "$command" in
echo "swping is running"
exit 0
else
echo "swping is stopped"
echo "swping is stopped"
exit 3
fi
;;

View File

@@ -1,15 +0,0 @@
#
# Shorewall version 4 - Audited AllowICMPs Macro
#
# /usr/share/shorewall/macro.AAllowICMPs
#
# This macro A_ACCEPTs needed ICMP types
#
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP
COMMENT Needed ICMP types
A_ACCEPT - - icmp fragmentation-needed
A_ACCEPT - - icmp time-exceeded

View File

@@ -1,14 +0,0 @@
#
# Shorewall version 4 - Audited DropDNSrep Macro
#
# /usr/share/shorewall/macro.ADropDNSrep
#
# This macro silently audites and drops DNS UDP replies
#
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP
COMMENT Late DNS Replies
A_DROP - - udp - 53

View File

@@ -1,14 +0,0 @@
#
# Shorewall version 4 - ADropUPnP Macro
#
# /usr/share/shorewall/macro.ADropUPnP
#
# This macro silently drops UPnP probes on UDP port 1900
#
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP
COMMENT UPnP
A_DROP - - udp 1900

View File

@@ -11,6 +11,5 @@
COMMENT Needed ICMP types
DEFAULT ACCEPT
PARAM - - icmp fragmentation-needed
PARAM - - icmp time-exceeded
ACCEPT - - icmp fragmentation-needed
ACCEPT - - icmp time-exceeded

View File

@@ -5,7 +5,7 @@
#
# This macro handles BitTorrent traffic for BitTorrent 3.1 and earlier.
#
# If you are running BitTorrent 3.2 or later, you should use the
# If you are running BitTorrent 3.2 or later, you should use the
# BitTorrent32 macro.
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/

View File

@@ -11,5 +11,4 @@
COMMENT Late DNS Replies
DEFAULT DROP
PARAM - - udp - 53
DROP - - udp - 53

View File

@@ -11,5 +11,4 @@
COMMENT UPnP
DEFAULT DROP
PARAM - - udp 1900
DROP - - udp 1900

View File

@@ -1,11 +0,0 @@
#
# Shorewall version 4 - ICPV2 Macro
#
# /usr/share/shorewall/macro.ICPV2
#
# This macro handles Internet Cache Protocol V2 (Squid) traffic
#
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP
PARAM - - udp 3130

View File

@@ -15,7 +15,7 @@
# Example for a two-interface firewall which acts as a print
# server for loc:
# IPPserver/ACCEPT loc $FW
#
#
# NOTE: If you want both to serve requests for local printers and
# listen to requests for remote printers (i.e. your CUPS server is
# also a client), you need to apply the rule twice, e.g.

View File

@@ -13,5 +13,5 @@
PARAM - - tcp 8080 # HTTP port
PARAM - - tcp 6544 # HTTP port
PARAM - - tcp 6543 # InfoService port
HTTPS(PARAM)
SSH(PARAM)
HTTPS/PARAM
SSH/PARAM

View File

@@ -1,11 +0,0 @@
#
# Shorewall version 4 - Munin Macro
#
# /usr/share/shorewall/macro.Munin
#
# This macro handles Munin networked resource monitoring traffic
#
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP
PARAM - - tcp 4949

View File

@@ -1,11 +0,0 @@
#
# Shorewall version 4 - Squid Macro
#
# /usr/share/shorewall/macro.Squid
#
# This macro handles Squid web proxy traffic
#
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP
PARAM - - tcp 3128

View File

@@ -15,7 +15,389 @@
# - All entries in a macro undergo substitution when the macro is
# invoked in the rules file.
#
# Columns are the same as in /etc/shorewall/rules.
# - Macros used in action bodies may not invoke other macros.
#
# The columns in the file are the same as those in the action.template file but
# have different restrictions:
#
# Columns are:
#
# ACTION ACCEPT, DROP, REJECT, DNAT, DNAT-, REDIRECT, CONTINUE,
# LOG, QUEUE, PARAM or an <action> name.
#
# ACCEPT -- allow the connection request
# ACCEPT+ -- like ACCEPT but also excludes the
# connection from any subsequent
# DNAT[-] or REDIRECT[-] rules
# NONAT -- Excludes the connection from any
# subsequent DNAT[-] or REDIRECT[-]
# rules but doesn't generate a rule
# to accept the traffic.
# DROP -- ignore the request
# REJECT -- disallow the request and return an
# icmp-unreachable or an RST packet.
# DNAT -- Forward the request to another
# system (and optionally another
# port).
# DNAT- -- Advanced users only.
# Like DNAT but only generates the
# DNAT iptables rule and not
# the companion ACCEPT rule.
# SAME -- Similar to DNAT except that the
# port may not be remapped and when
# multiple server addresses are
# listed, all requests from a given
# remote system go to the same
# server.
# SAME- -- Advanced users only.
# Like SAME but only generates the
# NAT iptables rule and not
# the companion ACCEPT rule.
# REDIRECT -- Redirect the request to a local
# port on the firewall.
# REDIRECT-
# -- Advanced users only.
# Like REDIRET but only generates the
# REDIRECT iptables rule and not
# the companion ACCEPT rule.
#
# CONTINUE -- (For experts only). Do not process
# any of the following rules for this
# (source zone,destination zone). If
# The source and/or destination IP
# address falls into a zone defined
# later in /etc/shorewall/zones, this
# connection request will be passed
# to the rules defined for that
# (those) zone(s).
# LOG -- Simply log the packet and continue.
# QUEUE -- Queue the packet to a user-space
# application such as ftwall
# (http://p2pwall.sf.net).
# PARAM -- If you code PARAM as the action in
# a macro then when you invoke the
# macro, you can include the name of
# the macro followed by a slash ("/")
# and an ACTION (either builtin or
# user-defined. All instances of
# PARAM in the body of the macro will
# be replaced with the ACTION.
# <action> -- The name of an action defined in
# /usr/share/shorewall/actions.std or
# in /etc/shorewall/actions.
#
# The ACTION may optionally be followed
# by ":" and a syslog log level (e.g, REJECT:info or
# DNAT:debug). This causes the packet to be
# logged at the specified level.
#
# You may also specify ULOG (must be in upper case) as a
# log level.This will log to the ULOG target for routing
# to a separate log through use of ulogd
# (http://www.gnumonks.org/projects/ulogd).
#
# Actions specifying logging may be followed by a
# log tag (a string of alphanumeric characters)
# are appended to the string generated by the
# LOGPREFIX (in /etc/shorewall/shorewall.conf).
#
# Example: ACCEPT:info:ftp would include 'ftp '
# at the end of the log prefix generated by the
# LOGPREFIX setting.
#
# SOURCE Source hosts to which the rule applies. May be a zone
# defined in /etc/shorewall/zones, $FW to indicate the
# firewall itself, "all", "all+" or "none" If the ACTION
# is DNAT or REDIRECT, sub-zones of the specified zone
# may be excluded from the rule by following the zone
# name with "!' and a comma-separated list of sub-zone
# names.
#
# When "none" is used either in the SOURCE or DEST
# column, the rule is ignored.
#
# When "all" is used either in the SOURCE or DEST column
# intra-zone traffic is not affected. When "all+" is
# used, intra-zone traffic is affected.
#
# Except when "all[+]" is specified, clients may be
# further restricted to a list of subnets and/or hosts by
# appending ":" and a comma-separated list of subnets
# and/or hosts. Hosts may be specified by IP or MAC
# address; mac addresses must begin with "~" and must use
# "-" as a separator.
#
# Hosts may be specified as an IP address range using the
# syntax <low address>-<high address>. This requires that
# your kernel and iptables contain iprange match support.
# If you kernel and iptables have ipset match support
# then you may give the name of an ipset prefaced by "+".
# The ipset name may be optionally followed by a number
# from 1 to 6 enclosed in square brackets ([]) to
# indicate the number of levels of source bindings to be
# matched.
#
# dmz:192.168.2.2 Host 192.168.2.2 in the DMZ
#
# net:155.186.235.0/24 Subnet 155.186.235.0/24 on the
# Internet
#
# loc:192.168.1.1,192.168.1.2
# Hosts 192.168.1.1 and
# 192.168.1.2 in the local zone.
# loc:~00-A0-C9-15-39-78 Host in the local zone with
# MAC address 00:A0:C9:15:39:78.
#
# net:192.0.2.11-192.0.2.17
# Hosts 192.0.2.11-192.0.2.17 in
# the net zone.
#
# Alternatively, clients may be specified by interface
# by appending ":" to the zone name followed by the
# interface name. For example, loc:eth1 specifies a
# client that communicates with the firewall system
# through eth1. This may be optionally followed by
# another colon (":") and an IP/MAC/subnet address
# as described above (e.g., loc:eth1:192.168.1.5).
#
# DEST Location of Server. May be a zone defined in
# /etc/shorewall/zones, $FW to indicate the firewall
# itself, "all". "all+" or "none".
#
# When "none" is used either in the SOURCE or DEST
# column, the rule is ignored.
#
# When "all" is used either in the SOURCE or DEST column
# intra-zone traffic is not affected. When "all+" is
# used, intra-zone traffic is affected.
#
# Except when "all[+]" is specified, the server may be
# further restricted to a particular subnet, host or
# interface by appending ":" and the subnet, host or
# interface. See above.
#
# Restrictions:
#
# 1. MAC addresses are not allowed.
# 2. In DNAT rules, only IP addresses are
# allowed; no FQDNs or subnet addresses
# are permitted.
# 3. You may not specify both an interface and
# an address.
#
# Like in the SOURCE column, you may specify a range of
# up to 256 IP addresses using the syntax
# <first ip>-<last ip>. When the ACTION is DNAT or DNAT-,
# the connections will be assigned to addresses in the
# range in a round-robin fashion.
#
# If you kernel and iptables have ipset match support
# then you may give the name of an ipset prefaced by "+".
# The ipset name may be optionally followed by a number
# from 1 to 6 enclosed in square brackets ([]) to
# indicate the number of levels of destination bindings
# to be matched. Only one of the SOURCE and DEST columns
# may specify an ipset name.
#
# The port that the server is listening on may be
# included and separated from the server's IP address by
# ":". If omitted, the firewall will not modifiy the
# destination port. A destination port may only be
# included if the ACTION is DNAT or REDIRECT.
#
# Example: loc:192.168.1.3:3128 specifies a local
# server at IP address 192.168.1.3 and listening on port
# 3128. The port number MUST be specified as an integer
# and not as a name from /etc/services.
#
# if the ACTION is REDIRECT, this column needs only to
# contain the port number on the firewall that the
# request should be redirected to.
#
# PROTO Protocol - Must be "tcp", "tcp:syn", "udp", "icmp",
# "ipp2p", "ipp2p:udp", "ipp2p:all" a number, or "all".
# "ipp2p*" requires ipp2p match support in your kernel
# and iptables.
#
# "tcp:syn" implies "tcp" plus the SYN flag must be
# set and the RST,ACK and FIN flags must be reset.
#
# DEST PORT(S) Destination Ports. A comma-separated list of Port
# names (from /etc/services), port numbers or port
# ranges; if the protocol is "icmp", this column is
# interpreted as the destination icmp-type(s).
#
# If the protocol is ipp2p*, this column is interpreted
# as an ipp2p option without the leading "--" (example
# "bit" for bit-torrent). If no port is given, "ipp2p" is
# assumed.
#
# A port range is expressed as <low port>:<high port>.
#
# This column is ignored if PROTOCOL = all but must be
# entered if any of the following ields are supplied.
# In that case, it is suggested that this field contain
# "-"
#
# If your kernel contains multi-port match support, then
# only a single Netfilter rule will be generated if in
# this list and the CLIENT PORT(S) list below:
# 1. There are 15 or less ports listed.
# 2. No port ranges are included.
# Otherwise, a separate rule will be generated for each
# port.
#
# SOURCE PORT(S) (Optional) Port(s) used by the client. If omitted,
# any source port is acceptable. Specified as a comma-
# separated list of port names, port numbers or port
# ranges.
#
# If you don't want to restrict client ports but need to
# specify an ORIGINAL DEST in the next column, then
# place "-" in this column.
#
# If your kernel contains multi-port match support, then
# only a single Netfilter rule will be generated if in
# this list and the DEST PORT(S) list above:
# 1. There are 15 or less ports listed.
# 2. No port ranges are included.
# Otherwise, a separate rule will be generated for each
# port.
#
# ORIGINAL Original destination IP address. Must be omitted (
# DEST or '-') if the macro is to be used from within
# an action. See 'man shorewall-rules'.
#
# RATE LIMIT You may rate-limit the rule by placing a value in
# this column:
#
# <rate>/<interval>[:<burst>]
#
# where <rate> is the number of connections per
# <interval> ("sec" or "min") and <burst> is the
# largest burst permitted. If no <burst> is given,
# a value of 5 is assumed. There may be no
# no whitespace embedded in the specification.
#
# Example: 10/sec:20
#
# USER/GROUP This column may only be non-empty if the SOURCE is
# the firewall itself.
#
# The column may contain:
#
# [!][<user name or number>][:<group name or number>][+<program name>]
#
# When this column is non-empty, the rule applies only
# if the program generating the output is running under
# the effective <user> and/or <group> specified (or is
# NOT running under that id if "!" is given).
#
# Examples:
#
# joe #program must be run by joe
# :kids #program must be run by a member of
# #the 'kids' group
# !:kids #program must not be run by a member
# #of the 'kids' group
# +upnpd #program named upnpd (This feature was
# #removed from Netfilter in kernel
# #version 2.6.14).
#
# MARK Specifies a MARK value to match. Must be empty or
# '-' if the macro is to be used within an action.
#
# [!]value[/mask][:C]
#
# Defines a test on the existing packet or connection
# mark. The rule will match only if the test returns
# true.
#
# If you don't want to define a test but need to
# specify anything in the following columns,
# place a "-" in this field.
#
# !
#
# Inverts the test (not equal)
#
# value
#
# Value of the packet or connection mark.
#
# mask
#
# A mask to be applied to the mark before
# testing.
#
# :C
#
# Designates a connection mark. If omitted, the
# packet mark's value is tested.
#
# CONNLIMIT Must be empty or '-' if the macro is to be used within
# an action.
#
# [!]limit[:mask]
#
# May be used to limit the number of simultaneous
# connections from each individual host to limit
# connections. Requires connlimit match in your kernel
# and iptables. While the limit is only checked on rules
# specifying CONNLIMIT, the number of current connections
# is calculated over all current connections from the
# SOURCE host. By default, the limit is applied to each
# host but can be made to apply to networks of hosts by
# specifying a mask. The mask specifies the width of a
# VLSM mask to be applied to the source address; the
# number of current connections is then taken over all
# hosts in the subnet source-address/mask. When ! is
# specified, the rule matches when the number of
# connection exceeds the limit.
#
# TIME Must be empty or '-' if the macro is to be used within
# an action.
#
#
# <timeelement>[&...]
#
# timeelement may be:
#
# timestart=hh:mm[:ss]
#
# Defines the starting time of day.
#
# timestop=hh:mm[:ss]
#
# Defines the ending time of day.
#
# utc
#
# Times are expressed in Greenwich Mean
# Time.
#
# localtz
#
# Times are expressed in Local Civil Time
# (default).
#
# weekdays=ddd[,ddd]...
#
# where ddd is one of Mon, Tue, Wed, Thu,
# Fri, Sat or Sun
#
# monthdays=dd[,dd],...
#
# where dd is an ordinal day of the month#
#
# datestart=yyyy[-mm[-dd[Thh[:mm[:ss]]]]]
#
# Defines the starting date and time.
#
# datestop=yyyy[-mm[-dd[Thh[:mm[:ss]]]]]
#
# Defines the ending date and time.
#
# A few examples should help show how Macros work.
#
# /etc/shorewall/macro.FwdFTP:
@@ -74,6 +456,6 @@
#######################################################################################################
# DO NOT REMOVE THE FOLLOWING LINE
FORMAT 2
####################################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS
# PORT PORT(S) DEST LIMIT GROUP
#######################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ ORIGINAL
# PORT(S) PORT(S) DEST LIMIT GROUP DEST

View File

@@ -23,10 +23,10 @@
# to the name of the remote firewall corresponding to the directory.
#
# To make the 'firewall' script, type "make".
#
#
# Once the script is compiling correctly, you can install it by
# typing "make install".
#
#
################################################################################
# V A R I A B L E S
#
@@ -55,7 +55,7 @@ all: firewall
#
# Only generate the capabilities file if it doesn't already exist
#
capabilities:
capabilities:
ssh root@$(HOST) "MODULESDIR=$(MODULESDIR) /usr/share/shorewall-lite/shorecap > $(LITEDIR)/capabilities"
scp root@$(HOST):$(LITEDIR)/capabilities .
#
@@ -78,5 +78,5 @@ save:
#
# Remove generated files
#
clean:
clean:
rm -f capabilities firewall firewall.conf reload

View File

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

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Shorewall</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.epic.perleditor.perlbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.epic.perleditor.perlnature</nature>
</natures>
</projectDescription>

View File

@@ -3,7 +3,7 @@
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2010,2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -35,101 +35,14 @@ use strict;
our @ISA = qw(Exporter);
our @EXPORT = qw( setup_accounting );
our @EXPORT_OK = qw( );
our $VERSION = 'MODULEVERSION';
#
# Per-IP accounting tables. Each entry contains the associated network.
#
my %tables;
my $jumpchainref;
my %accountingjumps;
my $asection;
my $defaultchain;
my $defaultrestriction;
my $restriction;
my $accounting_commands = { COMMENT => 0, SECTION => 2 };
my $sectionname;
my $acctable;
#
# Sections in the Accounting File
#
use constant {
LEGACY => 0,
PREROUTING => 1,
INPUT => 2,
OUTPUT => 3,
FORWARD => 4,
POSTROUTING => 5
};
#
# Map names to values
#
our %asections = ( PREROUTING => PREROUTING,
INPUT => INPUT,
FORWARD => FORWARD,
OUTPUT => OUTPUT,
POSTROUTING => POSTROUTING
);
our $VERSION = '4.4.7';
#
# Called by the compiler to [re-]initialize this module's state
#
sub initialize() {
$jumpchainref = undef;
%tables = ();
%accountingjumps = ();
#
# The section number is initialized to a value less thatn LEGACY. It will be set to LEGACY if a
# the first non-commentary line in the accounting file isn't a section header
#
# This allows the section header processor to quickly check for correct order
#
$asection = -1;
#
# These are the legacy values
#
$defaultchain = 'accounting';
$defaultrestriction = NO_RESTRICT;
$sectionname = '';
}
#
# Process a SECTION header
#
sub process_section ($) {
$sectionname = shift;
my $newsect = $asections{$sectionname};
#
# read_a_line has already verified that there are exactly two tokens on the line
#
fatal_error "Invalid SECTION ($sectionname)" unless defined $newsect;
fatal_error "SECTION not allowed after un-sectioned rules" unless $asection;
fatal_error "Duplicate or out-of-order SECTION ($sectionname)" if $newsect <= $asection;
if ( $sectionname eq 'INPUT' ) {
$defaultchain = 'accountin';
$defaultrestriction = INPUT_RESTRICT;
} elsif ( $sectionname eq 'OUTPUT' ) {
$defaultchain = 'accountout';
$defaultrestriction = OUTPUT_RESTRICT;
} elsif ( $sectionname eq 'FORWARD' ) {
$defaultchain = 'accountfwd';
$defaultrestriction = NO_RESTRICT;
} else {
fatal_error "The $sectionname SECTION is not allowed when ACCOUNTING_TABLE=filter" unless $acctable eq 'mangle';
if ( $sectionname eq 'PREROUTING' ) {
$defaultchain = 'accountpre';
$defaultrestriction = PREROUTE_RESTRICT;
} else {
$defaultchain = 'accountpost';
$defaultrestriction = POSTROUTE_RESTRICT;
}
}
$asection = $newsect;
our $jumpchainref;
$jumpchainref = undef;
}
#
@@ -137,36 +50,17 @@ sub process_section ($) {
#
sub process_accounting_rule( ) {
$acctable = $config{ACCOUNTING_TABLE};
our $jumpchainref;
$jumpchainref = 0;
my ($action, $chain, $source, $dest, $proto, $ports, $sports, $user, $mark, $ipsec, $headers ) = split_line1 1, 11, 'Accounting File', $accounting_commands;
my ($action, $chain, $source, $dest, $proto, $ports, $sports, $user, $mark ) = split_line1 1, 9, 'Accounting File';
if ( $action eq 'COMMENT' ) {
process_comment;
return 0;
}
if ( $action eq 'SECTION' ) {
process_section( $chain );
return 0;
}
$asection = LEGACY if $asection < 0;
our $disposition = '';
sub reserved_chain_name($) {
$_[0] =~ /^acc(?:ount(?:fwd|in|ing|out|pre|post)|ipsecin|ipsecout)$/;
}
sub ipsec_chain_name($) {
if ( $_[0] =~ /^accipsec(in|out)$/ ) {
$1;
}
}
sub check_chain( $ ) {
my $chainref = shift;
fatal_error "A non-accounting chain ($chainref->{name}) may not appear in the accounting file" if $chainref->{policy};
@@ -178,11 +72,10 @@ sub process_accounting_rule( ) {
sub jump_to_chain( $ ) {
my $jumpchain = $_[0];
fatal_error "Jumps to the $jumpchain chain are not allowed" if reserved_chain_name( $jumpchain );
$jumpchainref = ensure_accounting_chain( $jumpchain, 0, $defaultrestriction );
$jumpchainref = ensure_accounting_chain( $jumpchain );
check_chain( $jumpchainref );
$disposition = $jumpchain;
$jumpchain;
"-j $jumpchain";
}
my $target = '';
@@ -191,50 +84,18 @@ sub process_accounting_rule( ) {
$ports = '' if $ports eq 'any' || $ports eq 'all';
$sports = '' if $sports eq 'any' || $sports eq 'all';
fatal_error "USER/GROUP may only be specified in the OUTPUT section" unless $user eq '-' || $asection == OUTPUT;
my $rule = do_proto( $proto, $ports, $sports ) . do_user ( $user ) . do_test ( $mark, $globals{TC_MASK} ) . do_headers( $headers );
my $rule = do_proto( $proto, $ports, $sports ) . do_user ( $user ) . do_test ( $mark, $globals{TC_MASK} );
my $rule2 = 0;
my $jump = 0;
unless ( $action eq 'COUNT' ) {
if ( $action eq 'DONE' ) {
$target = 'RETURN';
} elsif ( $action =~ /^ACCOUNT\(/ ) {
if ( $action =~ /^ACCOUNT\((.+)\)$/ ) {
require_capability 'ACCOUNT_TARGET' , 'ACCOUNT Rules' , '';
my ( $table, $net, $rest ) = split/,/, $1;
fatal_error "Invalid Network Address (${net},${rest})" if defined $rest;
fatal_error "Missing Table Name" unless supplied $table;
fatal_error "Invalid Table Name ($table)" unless $table =~ /^([-\w.]+)$/;
fatal_error "Missing Network Address" unless defined $net;
fatal_error "Invalid Network Address ($net)" unless defined $net && $net =~ '/(\d+)$';
fatal_error "Netmask ($1) out of range" unless $1 >= 8;
validate_net $net, 0;
my $prevnet = $tables{$table};
if ( $prevnet ) {
fatal_error "Previous net associated with $table ($prevnet) does not match this one ($net)" unless compare_nets( $net , $prevnet );
} else {
$tables{$table} = $net;
}
$target = "ACCOUNT --addr $net --tname $table";
} else {
fatal_error "Invalid ACCOUNT Action";
}
} elsif ( $action =~ /^NFLOG/ ) {
$target = validate_level $action;
$target = '-j RETURN';
} else {
( $action, my $cmd ) = split /:/, $action;
if ( $cmd ) {
if ( $cmd eq 'COUNT' ) {
$rule2 = 1;
} elsif ( $cmd eq 'JUMP' ) {
$jump = 1;
} else {
$rule2=1;
} elsif ( $cmd ne 'JUMP' ) {
accounting_error;
}
}
@@ -243,15 +104,11 @@ sub process_accounting_rule( ) {
}
}
$restriction = $defaultrestriction;
my $restriction = NO_RESTRICT;
if ( $source eq 'any' || $source eq 'all' ) {
$source = ALLIP;
} else {
fatal_error "MAC addresses only allowed in the INPUT and FORWARD sections" if $source =~ /~/ && ( $asection == OUTPUT || ! $asection );
}
$source = ALLIP if $source eq 'any' || $source eq 'all';
if ( have_bridges && ! $asection ) {
if ( have_bridges ) {
my $fw = firewall_zone;
if ( $source =~ /^$fw:?(.*)$/ ) {
@@ -261,10 +118,9 @@ sub process_accounting_rule( ) {
$dest = ALLIP if $dest eq 'any' || $dest eq 'all';
} else {
$chain = 'accounting' unless $chain and $chain ne '-';
if ( $dest eq 'any' || $dest eq 'all' || $dest eq ALLIP ) {
expand_rule(
ensure_rules_chain ( 'accountout' ) ,
ensure_filter_chain( 'accountout' , 0 ) ,
OUTPUT_RESTRICT ,
$rule ,
$source ,
@@ -277,66 +133,11 @@ sub process_accounting_rule( ) {
}
}
} else {
$chain = $defaultchain unless $chain and $chain ne '-';
$chain = 'accounting' unless $chain and $chain ne '-';
$dest = ALLIP if $dest eq 'any' || $dest eq 'all';
}
my $chainref = $chain_table{$config{ACCOUNTING_TABLE}}{$chain};
my $dir;
if ( ! $chainref ) {
if ( reserved_chain_name( $chain ) ) {
fatal_error "May not use chain $chain in the $sectionname section" if $asection && $chain ne $defaultchain;
$chainref = ensure_accounting_chain $chain, 0 , $restriction;
} elsif ( $asection ) {
fatal_error "Unknown accounting chain ($chain)";
} else {
$chainref = ensure_accounting_chain $chain, 0 , $restriction;
}
$dir = ipsec_chain_name( $chain );
if ( $ipsec ne '-' ) {
if ( $dir ) {
$rule .= do_ipsec( $dir, $ipsec );
$chainref->{ipsec} = $dir;
} else {
fatal_error "Adding an IPSEC rule to an unreferenced accounting chain is not allowed";
}
} else {
warning_message "Adding rule to unreferenced accounting chain $chain" unless reserved_chain_name( $chain );
$chainref->{ipsec} = $dir;
}
} else {
fatal_error "$chain is not an accounting chain" unless $chainref->{accounting};
if ( $ipsec ne '-' ) {
$dir = $chainref->{ipsec};
fatal_error "Adding an IPSEC rule into a non-IPSEC chain is not allowed" unless $dir;
$rule .= do_ipsec( $dir , $ipsec );
} elsif ( $asection ) {
$restriction |= $chainref->{restriction};
}
}
dont_optimize( $chainref ) if $target eq 'RETURN';
if ( $jumpchainref ) {
if ( $asection ) {
#
# Check the jump-to chain to be sure that it doesn't contain rules that are incompatible with this section
#
my $jumprestricted = $jumpchainref->{restricted};
fatal_error "Chain $jumpchainref->{name} contains rules that are incompatible with the $sectionname section" if $jumprestricted && $restriction && $jumprestricted ne $restriction;
$restriction |= $jumpchainref->{restriction};
}
$accountingjumps{$jumpchainref->{name}}{$chain} = 1;
}
fatal_error "$chain is not an accounting chain" unless $chainref->{accounting};
$restriction = $dir eq 'in' ? INPUT_RESTRICT : OUTPUT_RESTRICT if $dir;
my $chainref = ensure_accounting_chain $chain;
expand_rule
$chainref ,
@@ -350,22 +151,6 @@ sub process_accounting_rule( ) {
$disposition ,
'' ;
if ( $rule2 || $jump ) {
if ( $chainref->{ipsec} ) {
if ( $jumpchainref->{ipsec} ) {
fatal_error "IPSEC in/out mismatch on chains $chain and $jumpchainref->{name}";
} else {
fatal_error "$jumpchainref->{name} is not an IPSEC chain" if keys %{$jumpchainref->{references}} > 1;
$jumpchainref->{ipsec} = $chainref->{ipsec};
}
} elsif ( $jumpchainref->{ipsec} ) {
fatal_error "Jump from a non-IPSEC chain to an IPSEC chain not allowed";
} else {
$jumpchainref->{ipsec} = $chainref->{ipsec};
}
}
if ( $rule2 ) {
expand_rule
$jumpchainref ,
@@ -385,93 +170,32 @@ sub process_accounting_rule( ) {
sub setup_accounting() {
if ( my $fn = open_file 'accounting' ) {
my $fn = open_file 'accounting';
first_entry "$doing $fn...";
first_entry "$doing $fn...";
my $nonEmpty = 0;
my $nonEmpty = 0;
$nonEmpty |= process_accounting_rule while read_a_line;
$nonEmpty |= process_accounting_rule while read_a_line;
clear_comment;
fatal_error "Accounring rules are isolated" if $nonEmpty && ! $filter_table->{accounting};
if ( $nonEmpty ) {
my $tableref = $chain_table{$acctable};
clear_comment;
if ( have_bridges || $asection ) {
if ( $tableref->{accountin} ) {
insert_ijump( $tableref->{INPUT}, j => 'accountin', 0 );
}
if ( $tableref->{accounting} ) {
dont_optimize( 'accounting' );
for my $chain ( qw/INPUT FORWARD/ ) {
insert_ijump( $tableref->{$chain}, j => 'accounting', 0 );
}
}
if ( $tableref->{accountfwd} ) {
insert_ijump( $tableref->{FORWARD}, j => 'accountfwd', 0 );
}
if ( $tableref->{accountout} ) {
insert_ijump( $tableref->{OUTPUT}, j => 'accountout', 0 );
}
if ( $tableref->{accountpre} ) {
insert_ijump( $tableref->{PREROUTING}, j => 'accountpre' , 0 );
}
if ( $tableref->{accountpost} ) {
insert_ijump( $tableref->{POSTROUTING}, j => 'accountpost', 0 );
}
} elsif ( $tableref->{accounting} ) {
dont_optimize( 'accounting' );
for my $chain ( qw/INPUT FORWARD OUTPUT/ ) {
insert_ijump( $tableref->{$chain}, j => 'accounting', 0 );
}
if ( have_bridges ) {
if ( $filter_table->{accounting} ) {
for my $chain ( qw/INPUT FORWARD/ ) {
add_jump( $filter_table->{$chain}, 'accounting', 0, '', 0, 0 );
}
}
if ( $tableref->{accipsecin} ) {
for my $chain ( qw/INPUT FORWARD/ ) {
insert_ijump( $tableref->{$chain}, j => 'accipsecin', 0 );
}
}
if ( $tableref->{accipsecout} ) {
for my $chain ( qw/FORWARD OUTPUT/ ) {
insert_ijump( $tableref->{$chain}, j => 'accipsecout', 0 );
}
}
unless ( $asection ) {
for ( accounting_chainrefs ) {
warning_message "Accounting chain $_->{name} has no references" unless keys %{$_->{references}};
}
}
if ( my $chainswithjumps = keys %accountingjumps ) {
my $progress = 1;
while ( $chainswithjumps && $progress ) {
$progress = 0;
for my $chain1 ( keys %accountingjumps ) {
if ( keys %{$accountingjumps{$chain1}} ) {
for my $chain2 ( keys %{$accountingjumps{$chain1}} ) {
delete $accountingjumps{$chain1}{$chain2}, $progress = 1 unless $accountingjumps{$chain2};
}
} else {
delete $accountingjumps{$chain1};
$chainswithjumps--;
$progress = 1;
}
}
}
if ( $chainswithjumps ) {
my @chainswithjumps = keys %accountingjumps;
fatal_error "Jump loop involving the following chains: @chainswithjumps";
}
if ( $filter_table->{accountout} ) {
add_jump( $filter_table->{OUTPUT}, 'accountout', 0, '', 0, 0 );
}
} else {
if ( $filter_table->{accounting} ) {
for my $chain ( qw/INPUT FORWARD OUTPUT/ ) {
add_jump( $filter_table->{$chain}, 'accounting', 0, '', 0, 0 );
}
}
}

View File

@@ -0,0 +1,944 @@
#
# Shorewall 4.4 -- /usr/share/shorewall/Shorewall/Actions.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# This module contains the code for dealing with actions (built-in,
# standard and user-defined) and Macros.
#
package Shorewall::Actions;
require Exporter;
use Shorewall::Config qw(:DEFAULT :internal);
use Shorewall::Zones;
use Shorewall::Chains qw(:DEFAULT :internal);
use strict;
our @ISA = qw(Exporter);
our @EXPORT = qw( merge_levels
isolate_basic_target
get_target_param
add_requiredby
createactionchain
find_logactionchain
process_actions1
process_actions2
process_actions3
find_macro
split_action
substitute_param
merge_macro_source_dest
merge_macro_column
map_old_actions
%usedactions
%default_actions
%actions
%macros
$macro_commands
);
our @EXPORT_OK = qw( initialize );
our $VERSION = '4.4_9';
#
# Used Actions. Each action that is actually used has an entry with value 1.
#
our %usedactions;
#
# Default actions for each policy.
#
our %default_actions;
# Action Table
#
# %actions{ <action1> => { requires => { <requisite1> = 1,
# <requisite2> = 1,
# ...
# } ,
# actchain => <action chain number> # Used for generating unique chain names for each <level>:<tag> pair.
#
our %actions;
#
# Contains an entry for each used <action>:<level>[:<tag>] that maps to the associated chain.
#
our %logactionchains;
our %macros;
our $family;
our @builtins;
#
# Commands that can be embedded in a macro file and how many total tokens on the line (0 => unlimited).
#
our $macro_commands = { COMMENT => 0, FORMAT => 2 };
#
# Rather than initializing globals in an INIT block or during declaration,
# we initialize them in a function. This is done for two reasons:
#
# 1. Proper initialization depends on the address family which isn't
# known until the compiler has started.
#
# 2. The compiler can run multiple times in the same process so it has to be
# able to re-initialize its dependent modules' state.
#
sub initialize( $ ) {
$family = shift;
%usedactions = ();
%default_actions = ( DROP => 'none' ,
REJECT => 'none' ,
ACCEPT => 'none' ,
QUEUE => 'none' );
%actions = ();
%logactionchains = ();
%macros = ();
if ( $family == F_IPV4 ) {
@builtins = qw/dropBcast allowBcast dropNotSyn rejNotSyn dropInvalid allowInvalid allowinUPnP forwardUPnP Limit/;
} else {
@builtins = qw/dropBcast allowBcast dropNotSyn rejNotSyn dropInvalid allowInvalid/;
}
}
#
# This function determines the logging for a subordinate action or a rule within a superior action
#
sub merge_levels ($$) {
my ( $superior, $subordinate ) = @_;
my @supparts = split /:/, $superior;
my @subparts = split /:/, $subordinate;
my $subparts = @subparts;
my $target = $subparts[0];
push @subparts, '' while @subparts < 3; #Avoid undefined values
my $level = $supparts[1];
my $tag = $supparts[2];
if ( @supparts == 3 ) {
return "$target:none!:$tag" if $level eq 'none!';
return "$target:$level:$tag" if $level =~ /!$/;
return $subordinate if $subparts >= 2;
return "$target:$level:$tag";
}
if ( @supparts == 2 ) {
return "$target:none!" if $level eq 'none!';
return "$target:$level" if ($level =~ /!$/) || ($subparts < 2);
}
$subordinate;
}
#
# Try to find a macro file -- RETURNS false if the file doesn't exist or MACRO if it does.
# If the file exists, the macro is entered into the 'targets' table and the fully-qualified
# name of the file is stored in the 'macro' table.
#
sub find_macro( $ )
{
my $macro = $_[0];
my $macrofile = find_file "macro.$macro";
if ( -f $macrofile ) {
$macros{$macro} = $macrofile;
$targets{$macro} = MACRO;
} else {
0;
}
}
#
# Return ( action, level[:tag] ) from passed full action
#
sub split_action ( $ ) {
my $action = $_[0];
my @a = split( /:/ , $action, 4 );
fatal_error "Invalid ACTION ($action)" if ( $action =~ /::/ ) || ( @a > 3 );
( shift @a, join ":", @a );
}
#
# This function substitutes the second argument for the first part of the first argument up to the first colon (":")
#
# Example:
#
# substitute_param DNAT PARAM:info:FTP
#
# produces "DNAT:info:FTP"
#
sub substitute_param( $$ ) {
my ( $param, $action ) = @_;
if ( $action =~ /:/ ) {
my $logpart = (split_action $action)[1];
$logpart =~ s!/$!!;
return "$param:$logpart";
}
$param;
}
#
# Combine fields from a macro body with one from the macro invocation
#
sub merge_macro_source_dest( $$ ) {
my ( $body, $invocation ) = @_;
if ( $invocation ) {
if ( $body ) {
return $body if $invocation eq '-';
return "$body:$invocation" if $invocation =~ /.*?\.*?\.|^\+|^!+|^~|^!~|~<|~\[/;
return "$invocation:$body";
}
return $invocation;
}
$body || '';
}
sub merge_macro_column( $$ ) {
my ( $body, $invocation ) = @_;
if ( defined $invocation && $invocation ne '' && $invocation ne '-' ) {
$invocation;
} else {
$body;
}
}
#
# Get Macro Name -- strips away trailing /*, :* and (*) from the first column in a rule, macro or action.
#
sub isolate_basic_target( $ ) {
my $target = ( split '[/:]', $_[0])[0];
$target =~ /^(\w+)[(].*[)]$/ ? $1 : $target;
}
#
# Split the passed target into the basic target and parameter
#
sub get_target_param( $ ) {
my ( $target, $param ) = split '/', $_[0];
unless ( defined $param ) {
( $target, $param ) = ( $1, $2 ) if $target =~ /^(.*?)[(](.*)[)]$/;
}
( $target, $param );
}
#
# Define an Action
#
sub new_action( $ ) {
my $action = $_[0];
$actions{$action} = { actchain => '', requires => {} };
}
#
# Record a 'requires' relationship between a pair of actions.
#
sub add_requiredby ( $$ ) {
my ($requiredby , $requires ) = @_;
$actions{$requires}{requires}{$requiredby} = 1;
}
#
# Map pre-3.0 actions to the corresponding Macro invocation
#
sub find_old_action ( $$$ ) {
my ( $target, $macro, $param ) = @_;
if ( my $actiontype = find_macro( $macro ) ) {
( $macro, $actiontype , $param );
} else {
( $target, 0, '' );
}
}
sub map_old_actions( $ ) {
my $target = shift;
if ( $target =~ /^Allow(.*)$/ ) {
find_old_action( $target, $1, 'ACCEPT' );
} elsif ( $target =~ /^Drop(.*)$/ ) {
find_old_action( $target, $1, 'DROP' );
} elsif ( $target = /^Reject(.*)$/ ) {
find_old_action( $target, $1, 'REJECT' );
} else {
( $target, 0, '' );
}
}
#
# Create and record a log action chain -- Log action chains have names
# that are formed from the action name by prepending a "%" and appending
# a 1- or 2-digit sequence number. In the functions that follow,
# the $chain, $level and $tag variable serves as arguments to the user's
# exit. We call the exit corresponding to the name of the action but we
# set $chain to the name of the iptables chain where rules are to be added.
# Similarly, $level and $tag contain the log level and log tag respectively.
#
# The maximum length of a chain name is 30 characters -- since the log
# action chain name is 2-3 characters longer than the base chain name,
# this function truncates the original chain name where necessary before
# it adds the leading "%" and trailing sequence number.
#
sub createlogactionchain( $$ ) {
my ( $action, $level ) = @_;
my $chain = $action;
my $actionref = $actions{$action};
my $chainref;
my ($lev, $tag) = split ':', $level;
validate_level $lev;
$actionref = new_action $action unless $actionref;
$chain = substr $chain, 0, 28 if ( length $chain ) > 28;
CHECKDUP:
{
$actionref->{actchain}++ while $chain_table{filter}{'%' . $chain . $actionref->{actchain}};
$chain = substr( $chain, 0, 27 ), redo CHECKDUP if ( $actionref->{actchain} || 0 ) >= 10 and length $chain == 28;
}
$logactionchains{"$action:$level"} = $chainref = new_standard_chain '%' . $chain . $actionref->{actchain}++;
fatal_error "Too many invocations of Action $action" if $actionref->{actchain} > 99;
unless ( $targets{$action} & BUILTIN ) {
dont_optimize $chainref;
my $file = find_file $chain;
if ( -f $file ) {
progress_message "Processing $file...";
( $level, my $tag ) = split /:/, $level;
$tag = $tag || '';
unless ( my $return = eval `cat $file` ) {
fatal_error "Couldn't parse $file: $@" if $@;
fatal_error "Couldn't do $file: $!" unless defined $return;
fatal_error "Couldn't run $file" unless $return;
}
}
}
}
sub createsimpleactionchain( $ ) {
my $action = shift;
my $chainref = new_standard_chain $action;
$logactionchains{"$action:none"} = $chainref;
unless ( $targets{$action} & BUILTIN ) {
dont_optimize $chainref;
my $file = find_file $action;
if ( -f $file ) {
progress_message "Processing $file...";
my ( $level, $tag ) = ( '', '' );
unless ( my $return = eval `cat $file` ) {
fatal_error "Couldn't parse $file: $@" if $@;
fatal_error "Couldn't do $file: $!" unless defined $return;
fatal_error "Couldn't run $file" unless $return;
}
}
}
}
#
# Create an action chain and run its associated user exit
#
sub createactionchain( $ ) {
my ( $action , $level ) = split_action $_[0];
my $chainref;
if ( defined $level && $level ne '' ) {
if ( $level eq 'none' ) {
createsimpleactionchain $action;
} else {
createlogactionchain $action , $level;
}
} else {
createsimpleactionchain $action;
}
}
#
# Find the chain that handles the passed action. If the chain cannot be found,
# a fatal error is generated and the function does not return.
#
sub find_logactionchain( $ ) {
my $fullaction = $_[0];
my ( $action, $level ) = split_action $fullaction;
$level = 'none' unless $level;
fatal_error "Fatal error in find_logactionchain" unless $logactionchains{"$action:$level"};
}
#
# Scans a macro file invoked from an action file ensuring that all targets mentioned in the file are known and that none are actions.
#
sub process_macro1 ( $$ ) {
my ( $action, $macrofile ) = @_;
progress_message " ..Expanding Macro $macrofile...";
push_open( $macrofile );
while ( read_a_line ) {
my ( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $morigdest, $mrate, $muser ) = split_line1 1, 9, 'macro file', $macro_commands;
next if $mtarget eq 'COMMENT' || $mtarget eq 'FORMAT';
$mtarget =~ s/:.*$//;
$mtarget = (split '/' , $mtarget)[0];
my $targettype = $targets{$mtarget};
$targettype = 0 unless defined $targettype;
fatal_error "Invalid target ($mtarget)"
unless ( $targettype == STANDARD ) || ( $mtarget eq 'PARAM' ) || ( $targettype & ( LOGRULE | NFQ | CHAIN ) );
}
progress_message " ..End Macro $macrofile";
pop_open;
}
#
# The functions process_actions1-3() implement the three phases of action processing.
#
# The first phase (process_actions1) occurs before the rules file is processed. The builtin-actions are added
# to the target table (%Shorewall::Chains::targets) and actions table, then ${SHAREDIR}/actions.std and
# ${CONFDIR}/actions are scanned (in that order). For each action:
#
# a) The related action definition file is located and scanned.
# b) Forward and unresolved action references are trapped as errors.
# c) A dependency graph is created using the 'requires' field in the 'actions' table.
#
# As the rules file is scanned, each action[:level[:tag]] is merged onto the 'usedactions' hash. When an <action>
# is merged into the hash, its action chain is created. Where logging is specified, a chain with the name
# %<action>n is used where the <action> name is truncated on the right where necessary to ensure that the total
# length of the chain name does not exceed 30 characters.
#
# The second phase (process_actions2) occurs after the rules file is scanned. The transitive closure of
# %usedactions is generated; again, as new actions are merged into the hash, their action chains are created.
#
# The final phase (process_actions3) traverses the keys of %usedactions populating each chain appropriately
# by reading the related action definition file and creating rules. Note that a given action definition file is
# processed once for each unique [:level[:tag]] applied to an invocation of the action.
#
sub process_action1 ( $$ ) {
my ( $action, $wholetarget ) = @_;
my ( $target, $level ) = split_action $wholetarget;
$level = 'none' unless $level;
my $targettype = $targets{$target};
if ( defined $targettype ) {
return if ( $targettype == STANDARD ) || ( $targettype & ( MACRO | LOGRULE | NFQ | CHAIN ) );
fatal_error "Invalid TARGET ($target)" if $targettype & STANDARD;
fatal_error "An action may not invoke itself" if $target eq $action;
add_requiredby $wholetarget, $action if $targettype & ACTION;
} elsif ( $target eq 'COMMENT' ) {
fatal_error "Invalid TARGET ($wholetarget)" unless $wholetarget eq $target;
} else {
( $target, my $param ) = get_target_param $target;
return if $target eq 'NFQUEUE';
if ( defined $param ) {
my $paramtype = $targets{$param} || 0;
fatal_error "Parameter value not allowed in action files ($param)" if $paramtype & NATRULE;
}
fatal_error "Invalid or missing ACTION ($wholetarget)" unless defined $target;
if ( find_macro $target ) {
process_macro1( $action, $macros{$target} );
} else {
fatal_error "Invalid TARGET ($target)";
}
}
}
sub process_actions1() {
progress_message2 "Preprocessing Action Files...";
#
# Add built-in actions to the target table and create those actions
#
$targets{$_} = ACTION + BUILTIN, new_action( $_ ) for @builtins;
for my $file ( qw/actions.std actions/ ) {
open_file $file;
while ( read_a_line ) {
my ( $action ) = split_line 1, 1, 'action file';
if ( $action =~ /:/ ) {
warning_message 'Default Actions are now specified in /etc/shorewall/shorewall.conf';
$action =~ s/:.*$//;
}
next unless $action;
if ( $targets{$action} ) {
warning_message "Duplicate Action Name ($action) Ignored" unless $targets{$action} & ACTION;
next;
}
$targets{$action} = ACTION;
fatal_error "Invalid Action Name ($action)" unless "\L$action" =~ /^[a-z]\w*$/;
new_action $action;
my $actionfile = find_file "action.$action";
fatal_error "Missing Action File ($actionfile)" unless -f $actionfile;
progress_message2 " Pre-processing $actionfile...";
push_open( $actionfile );
while ( read_a_line ) {
my ($wholetarget, $source, $dest, $proto, $ports, $sports, $rate, $users, $mark ) = split_line 1, 9, 'action file';
process_action1( $action, $wholetarget );
}
pop_open;
}
}
}
sub process_actions2 () {
progress_message2 'Generating Transitive Closure of Used-action List...';
my $changed = 1;
while ( $changed ) {
$changed = 0;
for my $target (keys %usedactions) {
my ($action, $level) = split_action $target;
my $actionref = $actions{$action};
assert( $actionref );
for my $action1 ( keys %{$actionref->{requires}} ) {
my $action2 = merge_levels $target, $action1;
unless ( $usedactions{ $action2 } ) {
$usedactions{ $action2 } = 1;
createactionchain $action2;
$changed = 1;
}
}
}
}
}
#
# This function is called to process each rule generated from an action file.
#
sub process_action( $$$$$$$$$$$ ) {
my ($chainref, $actionname, $target, $source, $dest, $proto, $ports, $sports, $rate, $user, $mark ) = @_;
my ( $action , $level ) = split_action $target;
if ( $action eq 'REJECT' ) {
$action = 'reject';
} elsif ( $action eq 'CONTINUE' ) {
$action = 'RETURN';
} elsif ( $action =~ /^NFQUEUE/ ) {
( $action, my $param ) = get_target_param $action;
$param = 1 unless defined $param;
$action = "NFQUEUE --queue-num $param";
} elsif ( $action eq 'COUNT' ) {
$action = '';
}
expand_rule ( $chainref ,
NO_RESTRICT ,
do_proto( $proto, $ports, $sports ) . do_ratelimit( $rate, $action ) . do_user $user . do_test( $mark, $globals{TC_MASK} ) ,
$source ,
$dest ,
'', #Original Dest
$action ? "-j $action" : '',
$level ,
$action ,
'' );
}
#
# Expand Macro in action files.
#
sub process_macro3( $$$$$$$$$$$$ ) {
my ( $macro, $param, $chainref, $action, $source, $dest, $proto, $ports, $sports, $rate, $user, $mark ) = @_;
my $nocomment = no_comment;
my $format = 1;
macro_comment $macro;
my $fn = $macros{$macro};
progress_message "..Expanding Macro $fn...";
push_open $fn;
while ( read_a_line ) {
my ( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $morigdest, $mrate, $muser, $mmark );
if ( $format == 1 ) {
( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $mrate, $muser ) = split_line1 1, 8, 'macro file', $macro_commands;
$morigdest = '-';
$mmark = '-';
} else {
( $mtarget, $msource, $mdest, $mproto, $mports, $msports, $morigdest, $mrate, $muser, $mmark ) = split_line1 1, 10, 'macro file', $macro_commands;
}
if ( $mtarget eq 'COMMENT' ) {
process_comment unless $nocomment;
next;
}
if ( $mtarget eq 'FORMAT' ) {
fatal_error "Invalid FORMAT ($msource)" unless $msource =~ /^[12]$/;
$format = $msource;
next;
}
if ( $mtarget =~ /^PARAM:?/ ) {
fatal_error 'PARAM requires that a parameter be supplied in macro invocation' unless $param;
$mtarget = substitute_param $param, $mtarget;
}
fatal_error "Macros used within Actions may not specify an ORIGINAL DEST " if $morigdest ne '-';
if ( $msource ) {
if ( ( $msource eq '-' ) || ( $msource eq 'SOURCE' ) ) {
$msource = $source || '';
} elsif ( $msource eq 'DEST' ) {
$msource = $dest || '';
} else {
$msource = merge_macro_source_dest $msource, $source;
}
} else {
$msource = '';
}
$msource = '' if $msource eq '-';
if ( $mdest ) {
if ( ( $mdest eq '-' ) || ( $mdest eq 'DEST' ) ) {
$mdest = $dest || '';
} elsif ( $mdest eq 'SOURCE' ) {
$mdest = $source || '';
} else {
$mdest = merge_macro_source_dest $mdest, $dest;
}
} else {
$mdest = '';
}
$mdest = '' if $mdest eq '-';
$mproto = merge_macro_column $mproto, $proto;
$mports = merge_macro_column $mports, $ports;
$msports = merge_macro_column $msports, $sports;
$mrate = merge_macro_column $mrate, $rate;
$muser = merge_macro_column $muser, $user;
$mmark = merge_macro_column $mmark, $mark;
process_action $chainref, $action, $mtarget, $msource, $mdest, $mproto, $mports, $msports, $mrate, $muser, $mark;
}
pop_open;
progress_message '..End Macro';
clear_comment unless $nocomment;
}
#
# Generate chain for non-builtin action invocation
#
sub process_action3( $$$$$ ) {
my ( $chainref, $wholeaction, $action, $level, $tag ) = @_;
my $actionfile = find_file "action.$action";
fatal_error "Missing Action File ($actionfile)" unless -f $actionfile;
progress_message2 "Processing $actionfile for chain $chainref->{name}...";
open_file $actionfile;
while ( read_a_line ) {
my ($target, $source, $dest, $proto, $ports, $sports, $rate, $user, $mark ) = split_line1 1, 9, 'action file';
if ( $target eq 'COMMENT' ) {
process_comment;
next;
}
my $target2 = merge_levels $wholeaction, $target;
my ( $action2 , $level2 ) = split_action $target2;
( $action2 , my $param ) = get_target_param $action2;
my $action2type = $targets{$action2} || 0;
unless ( $action2type == STANDARD ) {
if ( $action2type & ACTION ) {
$target2 = (find_logactionchain ( $target = $target2 ))->{name};
} else {
assert( $action2type & ( MACRO | LOGRULE | NFQ | CHAIN ) );
}
}
if ( $action2type == MACRO ) {
process_macro3( $action2, $param, $chainref, $action, $source, $dest, $proto, $ports, $sports, $rate, $user, $mark );
} else {
process_action $chainref, $action, $target2, $source, $dest, $proto, $ports, $sports, $rate, $user, $mark;
}
}
clear_comment;
}
#
# The following small functions generate rules for the builtin actions of the same name
#
sub dropBcast( $$$ ) {
my ($chainref, $level, $tag) = @_;
if ( have_capability( 'ADDRTYPE' ) ) {
if ( $level ne '' ) {
log_rule_limit $level, $chainref, 'dropBcast' , 'DROP', '', $tag, 'add', ' -m addrtype --dst-type BROADCAST ';
if ( $family == F_IPV4 ) {
log_rule_limit $level, $chainref, 'dropBcast' , 'DROP', '', $tag, 'add', ' -d 224.0.0.0/4 ';
} else {
log_rule_limit $level, $chainref, 'dropBcast' , 'DROP', '', $tag, 'add', ' -d ff00::/10 -j DROP ';
}
}
add_rule $chainref, '-m addrtype --dst-type BROADCAST -j DROP';
} else {
if ( $family == F_IPV4 ) {
add_commands $chainref, 'for address in $ALL_BCASTS; do';
} else {
add_commands $chainref, 'for address in $ALL_ACASTS; do';
}
incr_cmd_level $chainref;
log_rule_limit $level, $chainref, 'dropBcast' , 'DROP', '', $tag, 'add', ' -d $address ' if $level ne '';
add_rule $chainref, '-d $address -j DROP';
decr_cmd_level $chainref;
add_commands $chainref, 'done';
log_rule_limit $level, $chainref, 'dropBcast' , 'DROP', '', $tag, 'add', ' -d 224.0.0.0/4 ' if $level ne '';
}
if ( $family == F_IPV4 ) {
add_rule $chainref, '-d 224.0.0.0/4 -j DROP';
} else {
add_rule $chainref, '-d ff00::/10 -j DROP';
}
}
sub allowBcast( $$$ ) {
my ($chainref, $level, $tag) = @_;
if ( $family == F_IPV4 && have_capability( 'ADDRTYPE' ) ) {
if ( $level ne '' ) {
log_rule_limit $level, $chainref, 'allowBcast' , 'ACCEPT', '', $tag, 'add', ' -m addrtype --dst-type BROADCAST ';
log_rule_limit $level, $chainref, 'allowBcast' , 'ACCEPT', '', $tag, 'add', ' -d 224.0.0.0/4 ';
}
add_rule $chainref, '-m addrtype --dst-type BROADCAST -j ACCEPT';
add_rule $chainref, '-d 224.0.0.0/4 -j ACCEPT';
} else {
if ( $family == F_IPV4 ) {
add_commands $chainref, 'for address in $ALL_BCASTS; do';
} else {
add_commands $chainref, 'for address in $ALL_MACASTS; do';
}
incr_cmd_level $chainref;
log_rule_limit $level, $chainref, 'allowBcast' , 'ACCEPT', '', $tag, 'add', ' -d $address ' if $level ne '';
add_rule $chainref, '-d $address -j ACCEPT';
decr_cmd_level $chainref;
add_commands $chainref, 'done';
if ( $family == F_IPV4 ) {
log_rule_limit $level, $chainref, 'allowBcast' , 'ACCEPT', '', $tag, 'add', ' -d 224.0.0.0/4 ' if $level ne '';
add_rule $chainref, '-d 224.0.0.0/4 -j ACCEPT';
} else {
log_rule_limit $level, $chainref, 'allowBcast' , 'ACCEPT', '', $tag, 'add', ' -d ff00::/10 ' if $level ne '';
add_rule $chainref, '-d ff00:/10 -j ACCEPT';
}
}
}
sub dropNotSyn ( $$$ ) {
my ($chainref, $level, $tag) = @_;
log_rule_limit $level, $chainref, 'dropNotSyn' , 'DROP', '', $tag, 'add', '-p 6 ! --syn ' if $level ne '';
add_rule $chainref , '-p 6 ! --syn -j DROP';
}
sub rejNotSyn ( $$$ ) {
my ($chainref, $level, $tag) = @_;
log_rule_limit $level, $chainref, 'rejNotSyn' , 'REJECT', '', $tag, 'add', '-p 6 ! --syn ' if $level ne '';
add_rule $chainref , '-p 6 ! --syn -j REJECT --reject-with tcp-reset';
}
sub dropInvalid ( $$$ ) {
my ($chainref, $level, $tag) = @_;
log_rule_limit $level, $chainref, 'dropInvalid' , 'DROP', '', $tag, 'add', "$globals{STATEMATCH} INVALID " if $level ne '';
add_rule $chainref , "$globals{STATEMATCH} INVALID -j DROP";
}
sub allowInvalid ( $$$ ) {
my ($chainref, $level, $tag) = @_;
log_rule_limit $level, $chainref, 'allowInvalid' , 'ACCEPT', '', $tag, 'add', "$globals{STATEMATCH} INVALID " if $level ne '';
add_rule $chainref , "$globals{STATEMATCH} INVALID -j ACCEPT";
}
sub forwardUPnP ( $$$ ) {
dont_optimize 'forwardUPnP';
}
sub allowinUPnP ( $$$ ) {
my ($chainref, $level, $tag) = @_;
if ( $level ne '' ) {
log_rule_limit $level, $chainref, 'allowinUPnP' , 'ACCEPT', '', $tag, 'add', '-p 17 --dport 1900 ';
log_rule_limit $level, $chainref, 'allowinUPnP' , 'ACCEPT', '', $tag, 'add', '-p 6 --dport 49152 ';
}
add_rule $chainref, '-p 17 --dport 1900 -j ACCEPT';
add_rule $chainref, '-p 6 --dport 49152 -j ACCEPT';
}
sub Limit( $$$ ) {
my ($chainref, $level, $tag) = @_;
my @tag = split /,/, $tag;
fatal_error 'Limit rules must include <set name>,<max connections>,<interval> as the log tag (' . join( ':', 'Limit', $level eq '' ? 'none' : $level , $tag ) . ')' unless @tag == 3;
my $set = $tag[0];
for ( @tag[1,2] ) {
fatal_error 'Max connections and interval in Limit rules must be numeric (' . join( ':', 'Limit', $level eq '' ? 'none' : $level, $tag ) . ')' unless /^\d+$/
}
my $count = $tag[1] + 1;
require_capability( 'RECENT_MATCH' , 'Limit rules' , '' );
add_rule $chainref, "-m recent --name $set --set";
if ( $level ne '' ) {
my $xchainref = new_chain 'filter' , "$chainref->{name}%";
log_rule_limit $level, $xchainref, $tag[0], 'DROP', '', '', 'add', '';
add_rule $xchainref, '-j DROP';
add_jump $chainref, $xchainref, 0, "-m recent --name $set --update --seconds $tag[2] --hitcount $count ";
} else {
add_rule $chainref, "-m recent --update --name $set --seconds $tag[2] --hitcount $count -j DROP";
}
add_rule $chainref, '-j ACCEPT';
}
sub process_actions3 () {
my %builtinops = ( 'dropBcast' => \&dropBcast,
'allowBcast' => \&allowBcast,
'dropNotSyn' => \&dropNotSyn,
'rejNotSyn' => \&rejNotSyn,
'dropInvalid' => \&dropInvalid,
'allowInvalid' => \&allowInvalid,
'allowinUPnP' => \&allowinUPnP,
'forwardUPnP' => \&forwardUPnP,
'Limit' => \&Limit, );
for my $wholeaction ( keys %usedactions ) {
my $chainref = find_logactionchain $wholeaction;
my ( $action, $level, $tag ) = split /:/, $wholeaction;
$level = '' unless defined $level;
$tag = '' unless defined $tag;
if ( $targets{$action} & BUILTIN ) {
$level = '' if $level =~ /none!?/;
$builtinops{$action}->($chainref, $level, $tag);
} else {
process_action3 $chainref, $wholeaction, $action, $level, $tag;
}
}
}
1;

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2010,2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -21,51 +21,52 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
package Shorewall::Compiler;
require Exporter;
use Shorewall::Config qw(:DEFAULT :internal);
use Shorewall::Chains qw(:DEFAULT :internal);
use Shorewall::Zones;
use Shorewall::Policy;
use Shorewall::Nat;
use Shorewall::Providers;
use Shorewall::Tc;
use Shorewall::Tunnels;
use Shorewall::Actions;
use Shorewall::Accounting;
use Shorewall::Rules;
use Shorewall::Proc;
use Shorewall::Proxyarp;
use Shorewall::IPAddrs;
use Shorewall::Raw;
use Shorewall::Misc;
use strict;
our @ISA = qw(Exporter);
our @EXPORT = qw( compiler );
our @EXPORT_OK = qw( $export );
our $VERSION = 'MODULEVERSION';
our $VERSION = '4.4_9';
my $export;
our $export;
my $test;
our $test;
my $family;
our $family;
#
# Initilize the package-globals in the other modules
#
sub initialize_package_globals() {
Shorewall::Config::initialize($family);
Shorewall::Chains::initialize ($family, 1, $export );
Shorewall::Chains::initialize ($family);
Shorewall::Zones::initialize ($family);
Shorewall::Policy::initialize;
Shorewall::Nat::initialize;
Shorewall::Providers::initialize($family);
Shorewall::Tc::initialize($family);
Shorewall::Actions::initialize( $family );
Shorewall::Accounting::initialize;
Shorewall::Rules::initialize($family);
Shorewall::Proxyarp::initialize($family);
Shorewall::IPAddrs::initialize($family);
Shorewall::Misc::initialize($family);
}
#
@@ -83,25 +84,25 @@ sub generate_script_1( $ ) {
if ( $script ) {
if ( $test ) {
emit "#!$config{SHOREWALL_SHELL}\n#\n# Compiled firewall script generated by Shorewall-perl\n#";
emit "#!/bin/sh\n#\n# Compiled firewall script generated by Shorewall-perl\n#";
} else {
my $date = localtime;
emit "#!$config{SHOREWALL_SHELL}\n#\n# Compiled firewall script generated by Shorewall $globals{VERSION} - $date\n#";
emit "#!/bin/sh\n#\n# Compiled firewall script generated by Shorewall $globals{VERSION} - $date\n#";
if ( $family == F_IPV4 ) {
copy $globals{SHAREDIRPL} . 'prog.header';
} else {
copy $globals{SHAREDIRPL} . 'prog.header6';
}
copy2 $globals{SHAREDIR} . '/lib.common', 0;
}
}
my $lib = find_file 'lib.private';
copy2( $lib, $debug ) if -f $lib;
emit <<'EOF';
@@ -110,7 +111,7 @@ sub generate_script_1( $ ) {
################################################################################
EOF
for my $exit ( qw/init start tcclear started stop stopped clear refresh refreshed restored/ ) {
for my $exit qw/init start tcclear started stop stopped clear refresh refreshed restored/ {
emit "\nrun_${exit}_exit() {";
push_indent;
append_file $exit or emit 'true';
@@ -118,7 +119,7 @@ EOF
emit '}';
}
for my $exit ( qw/isusable findgw/ ) {
for my $exit qw/isusable findgw/ {
emit "\nrun_${exit}_exit() {";
push_indent;
append_file($exit, 1) or emit 'true';
@@ -228,11 +229,7 @@ sub generate_script_2() {
set_chain_variables;
if ( $config{EXPORTPARAMS} ) {
append_file 'params';
} else {
export_params;
}
append_file 'params' if $config{EXPORTPARAMS};
emit ( '',
"g_stopping=",
@@ -259,22 +256,22 @@ sub generate_script_2() {
push_indent;
if ( $global_variables ) {
emit( 'case $COMMAND in' );
push_indent;
if ( $global_variables & NOT_RESTORE ) {
emit( 'start|restart|refresh|disable|enable)' );
emit( 'start|restart|refresh)' );
} else {
emit( 'start|restart|refresh|disable|enable|restore)' );
emit( 'start|restart|refresh|restore)' );
}
push_indent;
set_global_variables(1);
handle_optional_interfaces(0);
handle_optional_interfaces;
emit ';;';
@@ -287,7 +284,7 @@ sub generate_script_2() {
set_global_variables(0);
handle_optional_interfaces(0);
handle_optional_interfaces;
emit ';;';
}
@@ -297,19 +294,21 @@ sub generate_script_2() {
emit ( 'esac' ) ,
} else {
emit( 'true' ) unless handle_optional_interfaces(1);
emit( 'true' ) unless handle_optional_interfaces;
}
pop_indent;
emit "\n}\n"; # End of detect_configuration()
}
#
# Final stage of script generation.
#
# Generate code for loading the various files in /var/lib/shorewall[6][-lite]
# Generate code to add IP addresses under ADD_IP_ALIASES and ADD_SNAT_ALIASES
#
# Generate the 'setup_netfilter()' function that runs iptables-restore.
# Generate the 'define_firewall()' function.
#
@@ -335,10 +334,10 @@ sub generate_script_3($) {
save_progress_message 'Initializing...';
if ( $export || $config{EXPORTMODULES} ) {
my $fn = find_file( $config{LOAD_HELPERS_ONLY} ? 'helpers' : 'modules' );
if ( $export ) {
my $fn = find_file $config{LOAD_HELPERS_ONLY} ? 'helpers' : 'modules';
if ( -f $fn && ( $config{EXPORTMODULES} || ( $export && ! $fn =~ "^$globals{SHAREDIR}/" ) ) ) {
if ( -f $fn && ! $fn =~ "^$globals{SHAREDIR}/" ) {
emit 'echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir';
emit 'cat > ${VARDIR}/.modules << EOF';
open_file $fn;
@@ -346,7 +345,7 @@ sub generate_script_3($) {
emit_unindented $currentline while read_a_line;
emit_unindented 'EOF';
emit '', 'reload_kernel_modules < ${VARDIR}/.modules';
emit 'reload_kernel_modules < ${VARDIR}/.modules';
} else {
emit 'load_kernel_modules Yes';
}
@@ -354,23 +353,84 @@ sub generate_script_3($) {
emit 'load_kernel_modules Yes';
}
emit '';
load_ipsets;
if ( $family == F_IPV4 ) {
my @ipsets = all_ipsets;
if ( @ipsets || $config{SAVE_IPSETS} ) {
emit ( '',
'local hack',
'',
'case $IPSET in',
' */*)',
' [ -x "$IPSET" ] || startup_error "IPSET=$IPSET does not exist or is not executable"',
' ;;',
' *)',
' IPSET="$(mywhich $IPSET)"',
' [ -n "$IPSET" ] || startup_error "The ipset utility cannot be located"' ,
' ;;',
'esac',
'',
'if [ "$COMMAND" = start ]; then' ,
' if [ -f ${VARDIR}/ipsets.save ]; then' ,
' $IPSET -F' ,
' $IPSET -X' ,
' $IPSET -R < ${VARDIR}/ipsets.save' ,
' fi' ,
'elif [ "$COMMAND" = restore -a -z "$g_recovering" ]; then' ,
' if [ -f $(my_pathname)-ipsets ]; then' ,
' if chain_exists shorewall; then' ,
' startup_error "Cannot restore $(my_pathname)-ipsets with Shorewall running"' ,
' else' ,
' $IPSET -F' ,
' $IPSET -X' ,
' $IPSET -R < $(my_pathname)-ipsets' ,
' fi' ,
' fi' ,
);
if ( @ipsets ) {
emit '';
emit ( " qt \$IPSET -L $_ -n || \$IPSET -N $_ iphash" ) for @ipsets;
emit ( '' ,
'elif [ "$COMMAND" = restart ]; then' ,
'' );
emit ( " qt \$IPSET -L $_ -n || \$IPSET -N $_ iphash" ) for @ipsets;
emit ( '' ,
' if [ -f /etc/debian_version ] && [ $(cat /etc/debian_version) = 5.0.3 ]; then' ,
' #',
' # The \'grep -v\' is a hack for a bug in ipset\'s nethash implementation when xtables-addons is applied to Lenny' ,
' #',
' hack=\'| grep -v /31\'' ,
' else' ,
' hack=' ,
' fi' ,
'',
' if eval $IPSET -S $hack > ${VARDIR}/ipsets.tmp; then' ,
' grep -q "^-N" ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${VARDIR}/ipsets.save' ,
' fi' );
}
emit ( 'fi',
'' );
}
emit ( 'if [ "$COMMAND" = refresh ]; then' ,
' run_refresh_exit' ,
'else' ,
' run_refresh_exit' );
emit ( " qt \$IPSET -L $_ -n || \$IPSET -N $_ iphash" ) for @ipsets;
emit ( 'else' ,
' run_init_exit',
'fi',
'' );
save_dynamic_chains;
mark_firewall_not_started;
emit ( '',
emit ('',
'delete_proxyarp',
''
);
@@ -388,20 +448,10 @@ sub generate_script_3($) {
emit "disable_ipv6\n" if $config{DISABLE_IPV6};
} else {
emit ( 'if [ "$COMMAND" = refresh ]; then' ,
' run_refresh_exit' ,
'else' ,
' run_init_exit',
'fi',
emit ( '[ "$COMMAND" = refresh ] && run_refresh_exit || run_init_exit',
'' );
save_dynamic_chains;
mark_firewall_not_started;
emit ('',
'delete_proxyndp',
''
);
emit '';
}
emit qq(delete_tc1\n) if $config{CLEAR_TC};
@@ -410,12 +460,7 @@ sub generate_script_3($) {
emit( 'setup_routing_and_traffic_shaping', '' );
if ( $family == F_IPV4 ) {
emit 'cat > ${VARDIR}/proxyarp << __EOF__';
} else {
emit 'cat > ${VARDIR}/proxyndp << __EOF__';
}
emit 'cat > ${VARDIR}/proxyarp << __EOF__';
dump_proxy_arp;
emit_unindented '__EOF__';
@@ -460,37 +505,33 @@ EOF
setup_forwarding( $family , 1 );
push_indent;
my $config_dir = $globals{CONFIGDIR};
emit<<"EOF";
set_state Started $config_dir
emit<<'EOF';
set_state "Started"
run_restored_exit
else
if [ \$COMMAND = refresh ]; then
if [ $COMMAND = refresh ]; then
chainlist_reload
EOF
setup_forwarding( $family , 0 );
emit<<"EOF";
emit<<'EOF';
run_refreshed_exit
do_iptables -N shorewall
set_state Started $config_dir
set_state "Started"
else
setup_netfilter
restore_dynamic_rules
conditionally_flush_conntrack
EOF
setup_forwarding( $family , 0 );
emit<<"EOF";
emit<<'EOF';
run_start_exit
do_iptables -N shorewall
set_state Started $config_dir
set_state "Started"
run_started_exit
fi
EOF
emit<<'EOF';
[ $0 = ${VARDIR}/firewall ] || cp -f $(my_pathname) ${VARDIR}/firewall
fi
@@ -518,15 +559,15 @@ EOF
}
#1
#
# The Compiler.
#
# Arguments are named -- see %parms below.
#
sub compiler {
my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview, $confess , $update , $annotate ) =
( '', '', -1, '', 0, '', '', -1, 0, 0, 0, 0, );
my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview ) =
( '', '', -1, '', 0, '', '', -1, 0 );
$export = 0;
$test = 0;
@@ -558,10 +599,7 @@ sub compiler {
log => { store => \$log },
log_verbosity => { store => \$log_verbosity, validate => \&validate_verbosity } ,
test => { store => \$test },
preview => { store => \$preview, validate=> \&validate_boolean } ,
confess => { store => \$confess, validate=> \&validate_boolean } ,
update => { store => \$update, validate=> \&validate_boolean } ,
annotate => { store => \$annotate, validate=> \&validate_boolean } ,
preview => { store => \$preview },
);
#
# P A R A M E T E R P R O C E S S I N G
@@ -591,11 +629,11 @@ sub compiler {
set_verbosity( $verbosity );
set_log($log, $log_verbosity) if $log;
set_timestamp( $timestamp );
set_debug( $debug , $confess );
set_debug( $debug );
#
# S H O R E W A L L . C O N F A N D C A P A B I L I T I E S
#
get_configuration( $export , $update , $annotate );
get_configuration( $export );
report_capabilities unless $config{LOAD_HELPERS_ONLY};
@@ -614,7 +652,8 @@ sub compiler {
# Chain table initialization depends on shorewall.conf and capabilities. So it must be deferred until
# shorewall.conf has been processed and the capabilities have been determined.
#
initialize_chain_table(1);
initialize_chain_table;
#
# Allow user to load Perl modules
#
@@ -639,12 +678,12 @@ sub compiler {
#
# Do action pre-processing.
#
process_actions;
process_actions1;
#
# P O L I C Y
# (Produces no output to the compiled script)
#
process_policies;
validate_policy;
#
# N O T R A C K
# (Produces no output to the compiled script)
@@ -696,7 +735,7 @@ sub compiler {
if ( $scriptfilename || $debug ) {
emit 'return 0';
pop_indent;
emit '}'; # End of setup_common_rules()
emit '}';
}
disable_script;
@@ -705,17 +744,7 @@ sub compiler {
# (Writes the setup_routing_and_traffic_shaping() function to the compiled script)
#
enable_script;
#
# Validate the TC files so that the providers will know what interfaces have TC
#
my $tcinterfaces = process_tc;
#
# Generate a function to bring up each provider
#
process_providers( $tcinterfaces );
#
# [Re-]establish Routing
#
if ( $scriptfilename || $debug ) {
emit( "\n#",
'# Setup routing and traffic shaping',
@@ -725,7 +754,9 @@ sub compiler {
push_indent;
}
#
# [Re-]establish Routing
#
setup_providers;
#
# TCRules and Traffic Shaping
@@ -734,7 +765,7 @@ sub compiler {
if ( $scriptfilename || $debug ) {
pop_indent;
emit "}\n"; # End of setup_routing_and_traffic_shaping()
emit "}\n";
}
disable_script;
@@ -776,6 +807,11 @@ sub compiler {
#
setup_tunnels;
#
# Post-rules action processing.
#
process_actions2;
process_actions3;
#
# MACLIST Filtration again
#
setup_mac_lists 2;
@@ -794,7 +830,7 @@ sub compiler {
#
generate_matrix;
if ( $config{OPTIMIZE} & 0xE ) {
if ( $config{OPTIMIZE} & 0xD ) {
progress_message2 'Optimizing Ruleset...';
#
# Optimize Policy Chains
@@ -821,19 +857,14 @@ sub compiler {
# We must reinitialize Shorewall::Chains before generating the iptables-restore input
# for stopping the firewall
#
Shorewall::Chains::initialize( $family, 0 , $export );
initialize_chain_table(0);
Shorewall::Chains::initialize( $family );
initialize_chain_table;
#
# S T O P _ F I R E W A L L
# (Writes the stop_firewall() function to the compiled script)
#
compile_stop_firewall( $test, $export );
#
# U P D O W N
# (Writes the updown() function to the compiled script)
#
compile_updown;
#
# Copy the footer to the script
#
unless ( $test ) {
@@ -863,7 +894,7 @@ sub compiler {
#
generate_matrix;
if ( $config{OPTIMIZE} & 0xE ) {
if ( $config{OPTIMIZE} & 6 ) {
progress_message2 'Optimizing Ruleset...';
#
# Optimize Policy Chains
@@ -872,7 +903,7 @@ sub compiler {
#
# Ruleset Optimization
#
optimize_ruleset if $config{OPTIMIZE} & 0xC;
optimize_ruleset if $config{OPTIMIZE} & 4;
}
enable_script if $debug;
@@ -885,8 +916,8 @@ sub compiler {
# Re-initialize the chain table so that process_routestopped() has the same
# environment that it would when called by compile_stop_firewall().
#
Shorewall::Chains::initialize( $family , 0 , $export );
initialize_chain_table(0);
Shorewall::Chains::initialize( $family );
initialize_chain_table;
if ( $debug ) {
compile_stop_firewall( $test, $export );

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2010,2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -34,8 +34,6 @@ use strict;
our @ISA = qw(Exporter);
our @EXPORT = qw( ALLIPv4
ALLIPv6
NILIPv4
NILIPv6
IPv4_MULTICAST
IPv6_MULTICAST
IPv6_LINKLOCAL
@@ -46,7 +44,6 @@ our @EXPORT = qw( ALLIPv4
IPv6_SITE_ALLNODES
IPv6_SITE_ALLRTRS
ALLIP
NILIP
ALL
TCP
UDP
@@ -59,7 +56,6 @@ our @EXPORT = qw( ALLIPv4
validate_address
validate_net
decompose_net
compare_nets
validate_host
validate_range
ip_range_explicit
@@ -67,9 +63,6 @@ our @EXPORT = qw( ALLIPv4
allipv4
allipv6
allip
nilipv4
nilipv6
nilip
rfc1918_networks
resolve_proto
proto_name
@@ -80,39 +73,32 @@ our @EXPORT = qw( ALLIPv4
validate_icmp6
);
our @EXPORT_OK = qw( );
our $VERSION = 'MODULEVERSION';
our $VERSION = '4.4_7';
#
# Some IPv4/6 useful stuff
#
my @allipv4 = ( '0.0.0.0/0' );
my @allipv6 = ( '::/0' );
my $allip;
my @allip;
my @nilipv4 = ( '0.0.0.0' );
my @nilipv6 = ( '::' );
my $nilip;
my @nilip;
my $valid_address;
my $validate_address;
my $validate_net;
my $validate_range;
my $validate_host;
my $family;
our @allipv4 = ( '0.0.0.0/0' );
our @allipv6 = ( '::/0' );
our $allip;
our @allip;
our $valid_address;
our $validate_address;
our $validate_net;
our $validate_range;
our $validate_host;
use constant { ALLIPv4 => '0.0.0.0/0' ,
ALLIPv6 => '::/0' ,
NILIPv4 => '0.0.0.0' ,
NILIPv6 => '::' ,
IPv4_MULTICAST => '224.0.0.0/4' ,
IPv6_MULTICAST => 'ff00::/8' ,
IPv6_LINKLOCAL => 'fe80::/10' ,
IPv6_SITELOCAL => 'feC0::/10' ,
IPv6_MULTICAST => 'FF00::/10' ,
IPv6_LINKLOCAL => 'FF80::/10' ,
IPv6_SITELOCAL => 'FFC0::/10' ,
IPv6_LOOPBACK => '::1' ,
IPv6_LINK_ALLNODES => 'ff01::1' ,
IPv6_LINK_ALLRTRS => 'ff01::2' ,
IPv6_SITE_ALLNODES => 'ff02::1' ,
IPv6_SITE_ALLRTRS => 'ff02::2' ,
IPv6_LINK_ALLNODES => 'FF01::1' ,
IPv6_LINK_ALLRTRS => 'FF01::2' ,
IPv6_SITE_ALLNODES => 'FF02::1' ,
IPv6_SITE_ALLRTRS => 'FF02::2' ,
ICMP => 1,
TCP => 6,
UDP => 17,
@@ -121,7 +107,7 @@ use constant { ALLIPv4 => '0.0.0.0/0' ,
SCTP => 132,
UDPLITE => 136 };
my @rfc1918_networks = ( "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16" );
our @rfc1918_networks = ( "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16" );
#
# Note: initialize() is declared at the bottom of the file
@@ -137,8 +123,8 @@ sub valid_4address( $ ) {
my @address = split /\./, $address;
return 0 unless @address == 4;
for ( @address ) {
return 0 unless /^\d+$/ && $_ < 256;
for my $a ( @address ) {
return 0 unless $a =~ /^\d+$/ && $a < 256;
}
1;
@@ -171,8 +157,8 @@ sub decodeaddr( $ ) {
my $result = shift @address;
for ( @address ) {
$result = ( $result << 8 ) | $_;
for my $a ( @address ) {
$result = ( $result << 8 ) | $a;
}
$result;
@@ -197,16 +183,7 @@ sub validate_4net( $$ ) {
$net = '' unless defined $net;
fatal_error "Missing address" if $net eq '';
if ( $net =~ /\+(\[?)/ ) {
if ( $1 ) {
fatal_error "An ipset list ($net) is not allowed in this context";
} elsif ( $net =~ /^\+[a-zA-Z][-\w]*$/ ) {
fatal_error "An ipset name ($net) is not allowed in this context";
} else {
fatal_error "Invalid ipset name ($net)";
}
}
fatal_error "An ipset name ($net) is not allowed in this context" if substr( $net, 0, 1 ) eq '+';
if ( defined $vlsm ) {
fatal_error "Invalid VLSM ($vlsm)" unless $vlsm =~ /^\d+$/ && $vlsm <= 32;
@@ -281,19 +258,10 @@ sub decompose_net( $ ) {
my $net = $_[0];
( $net, my $vlsm ) = validate_net( $net , 0 );
( ( $family == F_IPV4 ? encodeaddr( $net) : normalize_6addr( $net ) ) , $vlsm );
( encodeaddr( $net) , $vlsm );
}
sub compare_nets( $$ ) {
my ( @net1, @net2 );
@net1 = decompose_net( $_[0] );
@net2 = decompose_net( $_[1] );
$net1[0] eq $net2[0] && $net1[1] == $net2[1];
}
sub allipv4() {
@allipv4;
}
@@ -302,14 +270,6 @@ sub allipv6() {
@allipv6;
}
sub nilipv4() {
@nilipv4;
}
sub nilipv6() {
@nilipv6;
}
sub rfc1918_networks() {
@rfc1918_networks
}
@@ -330,13 +290,8 @@ sub resolve_proto( $ ) {
if ( $proto =~ /^\d+$/ || $proto =~ /^0x/ ) {
$number = numeric_value ( $proto );
defined $number && $number <= 255 ? $number : undef;
defined $number && $number <= 65535 ? $number : undef;
} else {
#
# Allow 'icmp' as a synonym for 'ipv6-icmp' in IPv6 compilations
#
$proto= 'ipv6-icmp' if $proto eq 'icmp' && $family == F_IPV6;
defined( $number = $nametoproto{$proto} ) ? $number : scalar getprotobyname $proto;
}
}
@@ -377,7 +332,7 @@ sub validate_portpair( $$ ) {
my @ports = split /:/, $portpair, 2;
$_ = validate_port( $proto, $_) for ( grep $_, @ports );
$_ = validate_port( $proto, $_) for ( @ports );
if ( @ports == 2 ) {
fatal_error "Invalid port range ($portpair)" unless $ports[0] < $ports[1];
@@ -484,7 +439,7 @@ sub expand_port_range( $$ ) {
#
# Validate the ports
#
( $first , $last ) = ( validate_port( $proto, $first || 1 ) , validate_port( $proto, $last ) );
( $first , $last ) = ( validate_port( $proto, $first ) , validate_port( $proto, $last ) );
$last++; #Increment last address for limit testing.
#
@@ -536,7 +491,6 @@ sub valid_6address( $ ) {
}
return 0 if @address > $max;
return 0 unless $address =~ /^[a-f:\d]+$/;
return 0 unless ( @address == $max ) || $address =~ /::/;
return 0 if $address =~ /:::/ || $address =~ /::.*::/;
@@ -547,7 +501,7 @@ sub valid_6address( $ ) {
unless ( $address =~ /::$/ ) {
return 0 if $address =~ /:$/;
}
for my $a ( @address ) {
return 0 unless $a eq '' || ( $a =~ /^[a-fA-f\d]+$/ && length $a < 5 );
}
@@ -580,15 +534,7 @@ sub validate_6net( $$ ) {
my ($net, $vlsm, $rest) = split( '/', $_[0], 3 );
my $allow_name = $_[1];
if ( $net =~ /\+(\[?)/ ) {
if ( $1 ) {
fatal_error "An ipset list ($net) is not allowed in this context";
} elsif ( $net =~ /^\+[a-zA-Z][-\w]*$/ ) {
fatal_error "An ipset name ($net) is not allowed in this context";
} else {
fatal_error "Invalid ipset name ($net)";
}
}
fatal_error "An ipset name ($net) is not allowed in this context" if substr( $net, 0, 1 ) eq '+';
if ( defined $vlsm ) {
fatal_error "Invalid VLSM ($vlsm)" unless $vlsm =~ /^\d+$/ && $vlsm <= 128;
@@ -597,16 +543,6 @@ sub validate_6net( $$ ) {
} else {
fatal_error "Invalid Network address ($_[0])" if $_[0] =~ '/' || ! defined $net;
validate_6address $net, $allow_name;
$vlsm = 128;
}
if ( defined wantarray ) {
assert ( ! $allow_name );
if ( wantarray ) {
( $net , $vlsm );
} else {
"$net/$vlsm";
}
}
}
@@ -634,7 +570,7 @@ sub normalize_6addr( $ ) {
1 while $addr =~ s/::/:0:/;
$addr =~ s/^0+:/0:/;
$addr;
}
}
@@ -715,14 +651,6 @@ sub allip() {
@allip;
}
sub NILIP() {
$nilip;
}
sub nilip() {
@nilip;
}
sub valid_address ( $ ) {
$valid_address->(@_);
}
@@ -754,13 +682,11 @@ sub validate_host ($$ ) {
# able to re-initialize its dependent modules' state.
#
sub initialize( $ ) {
$family = shift;
my $family = shift;
if ( $family == F_IPV4 ) {
$allip = ALLIPv4;
@allip = @allipv4;
$nilip = NILIPv4;
@nilip = @nilipv4;
$valid_address = \&valid_4address;
$validate_address = \&validate_4address;
$validate_net = \&validate_4net;
@@ -769,8 +695,6 @@ sub initialize( $ ) {
} else {
$allip = ALLIPv6;
@allip = @allipv6;
$nilip = NILIPv6;
@nilip = @nilipv6;
$valid_address = \&valid_6address;
$validate_address = \&validate_6address;
$validate_net = \&validate_6net;

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2010,2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -36,10 +36,10 @@ use strict;
our @ISA = qw(Exporter);
our @EXPORT = qw( setup_masq setup_nat setup_netmap add_addresses );
our @EXPORT_OK = ();
our $VERSION = 'MODULEVERSION';
our $VERSION = '4.4_9';
my @addresses_to_add;
my %addresses_to_add;
our @addresses_to_add;
our %addresses_to_add;
#
# Called by the compiler
@@ -49,6 +49,56 @@ sub initialize() {
%addresses_to_add = ();
}
#
# Handle IPSEC Options in a masq record
#
sub do_ipsec_options($)
{
my %validoptions = ( strict => NOTHING,
next => NOTHING,
reqid => NUMERIC,
spi => NUMERIC,
proto => IPSECPROTO,
mode => IPSECMODE,
"tunnel-src" => NETWORK,
"tunnel-dst" => NETWORK,
);
my $list=$_[0];
my $options = '-m policy --pol ipsec --dir out ';
my $fmt;
for my $e ( split_list $list, 'option' ) {
my $val = undef;
my $invert = '';
if ( $e =~ /([\w-]+)!=(.+)/ ) {
$val = $2;
$e = $1;
$invert = '! ';
} elsif ( $e =~ /([\w-]+)=(.+)/ ) {
$val = $2;
$e = $1;
}
$fmt = $validoptions{$e};
fatal_error "Invalid Option ($e)" unless $fmt;
if ( $fmt eq NOTHING ) {
fatal_error "Option \"$e\" does not take a value" if defined $val;
} else {
fatal_error "Missing value for option \"$e\"" unless defined $val;
fatal_error "Invalid value ($val) for option \"$e\"" unless $val =~ /^($fmt)$/;
}
$options .= $invert;
$options .= "--$e ";
$options .= "$val " if defined $val;
}
$options;
}
#
# Process a single rule from the the masq file
#
@@ -103,11 +153,11 @@ sub process_one_masq( )
fatal_error "Non-empty IPSEC column requires policy match support in your kernel and iptables" unless have_capability( 'POLICY_MATCH' );
if ( $ipsec =~ /^yes$/i ) {
$baserule .= do_ipsec_options 'out', 'ipsec', '';
$baserule .= '-m policy --pol ipsec --dir out ';
} elsif ( $ipsec =~ /^no$/i ) {
$baserule .= do_ipsec_options 'out', 'none', '';
$baserule .= '-m policy --pol none --dir out ';
} else {
$baserule .= do_ipsec_options 'out', 'ipsec', $ipsec;
$baserule .= do_ipsec_options $ipsec;
}
} elsif ( have_ipsec ) {
$baserule .= '-m policy --pol none --dir out ';
@@ -125,7 +175,7 @@ sub process_one_masq( )
for my $fullinterface (split_list $interfacelist, 'interface' ) {
my $rule = '';
my $target = 'MASQUERADE ';
my $target = '-j MASQUERADE ';
#
# Isolate and verify the interface part
#
@@ -155,7 +205,6 @@ sub process_one_masq( )
my $exceptionrule = '';
my $randomize = '';
my $persistent = '';
my $conditional = 0;
#
# Parse the ADDRESSES column
#
@@ -163,8 +212,8 @@ sub process_one_masq( )
if ( $addresses eq 'random' ) {
$randomize = '--random ';
} else {
$addresses =~ s/:persistent$// and $persistent = ' --persistent ';
$addresses =~ s/:random$// and $randomize = ' --random ';
$addresses =~ s/:persistent$// and $persistent = '--persistent ';
$addresses =~ s/:random$// and $randomize = '--random ';
require_capability 'PERSISTENT_SNAT', ':persistent', 's' if $persistent;
@@ -172,7 +221,7 @@ sub process_one_masq( )
fatal_error "The SAME target is no longer supported";
} elsif ( $addresses eq 'detect' ) {
my $variable = get_interface_address $interface;
$target = "SNAT --to-source $variable";
$target = "-j SNAT --to-source $variable";
if ( interface_is_optional $interface ) {
add_commands( $chainref,
@@ -182,20 +231,13 @@ sub process_one_masq( )
$detectaddress = 1;
}
} elsif ( $addresses eq 'NONAT' ) {
$target = 'RETURN';
$target = '-j RETURN';
$add_snat_aliases = 0;
} else {
my $addrlist = '';
for my $addr ( split_list $addresses , 'address' ) {
if ( $addr =~ /^&(.+)$/ ) {
$target = 'SNAT ';
if ( $conditional = conditional_rule( $chainref, $addr ) ) {
$addrlist .= '--to-source ' . get_interface_address $1;
} else {
$addrlist .= '--to-source ' . record_runtime_address $1;
}
} elsif ( $addr =~ /^.*\..*\..*\./ ) {
$target = 'SNAT ';
if ( $addr =~ /^.*\..*\..*\./ ) {
$target = '-j SNAT ';
my ($ipaddr, $rest) = split ':', $addr;
if ( $ipaddr =~ /^(.+)-(.+)$/ ) {
validate_range( $1, $2 );
@@ -205,12 +247,8 @@ sub process_one_masq( )
$addrlist .= "--to-source $addr ";
$exceptionrule = do_proto( $proto, '', '' ) if $addr =~ /:/;
} else {
my $ports = $addr;
$ports =~ s/^://;
my $portrange = $ports;
$portrange =~ s/-/:/;
validate_portpair( $proto, $portrange );
$addrlist .= "--to-ports $ports ";
$addr =~ s/^://;
$addrlist .= "--to-ports $addr ";
$exceptionrule = do_proto( $proto, '', '' );
}
}
@@ -238,7 +276,10 @@ sub process_one_masq( )
'' ,
$exceptionrule );
conditional_rule_end( $chainref ) if $detectaddress || $conditional;
if ( $detectaddress ) {
decr_cmd_level( $chainref );
add_commands( $chainref , 'fi' );
}
if ( $add_snat_aliases ) {
my ( $interface, $alias , $remainder ) = split( /:/, $fullinterface, 3 );
@@ -271,14 +312,14 @@ sub process_one_masq( )
#
sub setup_masq()
{
if ( my $fn = open_file 'masq' ) {
my $fn = open_file 'masq';
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , 'a non-empty masq file' , 's'; } );
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , 'a non-empty masq file' , 's'; } );
process_one_masq while read_a_line;
process_one_masq while read_a_line;
clear_comment;
clear_comment;
}
}
#
@@ -368,32 +409,32 @@ sub do_one_nat( $$$$$ )
#
sub setup_nat() {
if ( my $fn = open_file 'nat' ) {
my $fn = open_file 'nat';
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , 'a non-empty nat file' , 's'; } );
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , 'a non-empty nat file' , 's'; } );
while ( read_a_line ) {
while ( read_a_line ) {
my ( $external, $interfacelist, $internal, $allints, $localnat ) = split_line1 3, 5, 'nat file';
my ( $external, $interfacelist, $internal, $allints, $localnat ) = split_line1 3, 5, 'nat file';
if ( $external eq 'COMMENT' ) {
process_comment;
} else {
( $interfacelist, my $digit ) = split /:/, $interfacelist;
if ( $external eq 'COMMENT' ) {
process_comment;
} else {
( $interfacelist, my $digit ) = split /:/, $interfacelist;
$digit = defined $digit ? ":$digit" : '';
$digit = defined $digit ? ":$digit" : '';
for my $interface ( split_list $interfacelist , 'interface' ) {
fatal_error "Invalid Interface List ($interfacelist)" unless supplied $interface;
do_one_nat $external, "${interface}${digit}", $internal, $allints, $localnat;
}
progress_message " NAT entry \"$currentline\" $done";
for my $interface ( split_list $interfacelist , 'interface' ) {
fatal_error "Invalid Interface List ($interfacelist)" unless defined $interface && $interface ne '';
do_one_nat $external, "${interface}${digit}", $internal, $allints, $localnat;
}
progress_message " NAT entry \"$currentline\" $done";
}
clear_comment;
}
clear_comment;
}
#
@@ -401,88 +442,38 @@ sub setup_nat() {
#
sub setup_netmap() {
if ( my $fn = open_file 'netmap' ) {
my $fn = open_file 'netmap';
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , 'a non-empty netmap file' , 's'; } );
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , 'a non-empty netmap file' , 's'; } );
while ( read_a_line ) {
while ( read_a_line ) {
my ( $type, $net1, $interfacelist, $net2, $net3 ) = split_line 4, 5, 'netmap file';
my ( $type, $net1, $interfacelist, $net2 ) = split_line 4, 4, 'netmap file';
validate_net $net1, 0;
validate_net $net2, 0;
for my $interface ( split_list $interfacelist, 'interface' ) {
$net3 = ALLIP if $net3 eq '-';
my $rulein = '';
my $ruleout = '';
my $iface = $interface;
for my $interface ( split_list $interfacelist, 'interface' ) {
fatal_error "Unknown interface ($interface)" unless my $interfaceref = known_interface( $interface );
my $iface = $interface;
fatal_error "Unknown interface ($interface)" unless my $interfaceref = known_interface( $interface );
unless ( $type =~ /:/ ) {
my @rulein;
my @ruleout;
unless ( $interfaceref->{root} ) {
@rulein = imatch_source_dev( $interface );
@ruleout = imatch_dest_dev( $interface );
$interface = $interfaceref->{name};
}
if ( $type eq 'DNAT' ) {
add_ijump ensure_chain( 'nat' , input_chain $interface ) , j => "NETMAP --to $net2", @rulein , imatch_source_net( $net3 ), d => $net1;
} elsif ( $type eq 'SNAT' ) {
add_ijump ensure_chain( 'nat' , output_chain $interface ) , j => "NETMAP --to $net2", @ruleout , imatch_dest_net( $net3 ) , s => $net1;
} else {
fatal_error "Invalid type ($type)";
}
} elsif ( $type =~ /^(DNAT|SNAT):([POT])$/ ) {
my ( $target , $chain ) = ( $1, $2 );
my $table = 'raw';
my @match = ();
require_capability 'RAWPOST_TABLE', 'Stateless NAT Entries', '';
unless ( $interfaceref->{root} ) {
@match = imatch_dest_dev( $interface );
$interface = $interfaceref->{name};
}
if ( $chain eq 'P' ) {
$chain = prerouting_chain $interface;
@match = imatch_source_dev( $iface ) unless $iface eq $interface;
} elsif ( $chain eq 'O' ) {
$chain = output_chain $interface;
} else {
$chain = postrouting_chain $interface;
$table = 'rawpost';
}
if ( $target eq 'DNAT' ) {
add_ijump( ensure_chain( $table, $chain ) ,
j => 'RAWDNAT',
targetopts => "--to-dest $net2",
imatch_source_net( $net3 ) ,
imatch_dest_net( $net1 ) ,
@match );
} else {
add_ijump( ensure_chain( $table, $chain ) ,
j => 'RAWSNAT',
targetopts => "--to-source $net2",
imatch_dest_net( $net3 ) ,
imatch_source_net( $net1 ) ,
@match );
}
} else {
fatal_error "Invalid type ($type)";
}
progress_message " Network $net1 on $iface mapped to $net2 ($type)";
unless ( $interfaceref->{root} ) {
$rulein = match_source_dev $interface;
$ruleout = match_dest_dev $interface;
$interface = $interfaceref->{name};
}
}
clear_comment;
if ( $type eq 'DNAT' ) {
add_rule ensure_chain( 'nat' , input_chain $interface ) , $rulein . "-d $net1 -j NETMAP --to $net2";
} elsif ( $type eq 'SNAT' ) {
add_rule ensure_chain( 'nat' , output_chain $interface ) , $ruleout . "-s $net1 -j NETMAP --to $net2";
} else {
fatal_error "Invalid type ($type)";
}
progress_message " Network $net1 on $iface mapped to $net2 ($type)";
}
}
}

View File

@@ -0,0 +1,522 @@
#
# Shorewall 4.4 -- /usr/share/shorewall/Shorewall/Policy.pm
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# This module deals with the /etc/shorewall/policy file.
#
package Shorewall::Policy;
require Exporter;
use Shorewall::Config qw(:DEFAULT :internal);
use Shorewall::Zones;
use Shorewall::Chains qw( :DEFAULT :internal) ;
use Shorewall::Actions;
use strict;
our @ISA = qw(Exporter);
our @EXPORT = qw( validate_policy apply_policy_rules complete_standard_chain setup_syn_flood_chains save_policies optimize_policy_chains);
our @EXPORT_OK = qw( );
our $VERSION = '4.4_9';
# @policy_chains is a list of references to policy chains in the filter table
our @policy_chains;
#
# Called by the compiler
#
sub initialize() {
@policy_chains = ();
}
#
# Convert a chain into a policy chain.
#
sub convert_to_policy_chain($$$$$)
{
my ($chainref, $source, $dest, $policy, $provisional ) = @_;
$chainref->{is_policy} = 1;
$chainref->{policy} = $policy;
$chainref->{provisional} = $provisional;
$chainref->{policychain} = $chainref->{name};
$chainref->{policypair} = [ $source, $dest ];
}
#
# Create a new policy chain and return a reference to it.
#
sub new_policy_chain($$$$)
{
my ($source, $dest, $policy, $provisional) = @_;
my $chainref = new_chain( 'filter', rules_chain( ${source}, ${dest} ) );
convert_to_policy_chain( $chainref, $source, $dest, $policy, $provisional );
$chainref;
}
#
# Set the passed chain's policychain and policy to the passed values.
#
sub set_policy_chain($$$$$)
{
my ($source, $dest, $chain1, $chainref, $policy ) = @_;
my $chainref1 = $filter_table->{$chain1};
$chainref1 = new_chain 'filter', $chain1 unless $chainref1;
unless ( $chainref1->{policychain} ) {
if ( $config{EXPAND_POLICIES} ) {
#
# We convert the canonical chain into a policy chain, using the settings of the
# passed policy chain.
#
$chainref1->{policychain} = $chain1;
$chainref1->{loglevel} = $chainref->{loglevel} if defined $chainref->{loglevel};
if ( defined $chainref->{synparams} ) {
$chainref1->{synparams} = $chainref->{synparams};
$chainref1->{synchain} = $chainref->{synchain};
}
$chainref1->{default} = $chainref->{default} if defined $chainref->{default};
$chainref1->{is_policy} = 1;
push @policy_chains, $chainref1;
} else {
$chainref1->{policychain} = $chainref->{name};
}
$chainref1->{policy} = $policy;
$chainref1->{policypair} = [ $source, $dest ];
}
}
#
# Process the policy file
#
use constant { PROVISIONAL => 1 };
sub add_or_modify_policy_chain( $$ ) {
my ( $zone, $zone1 ) = @_;
my $chain = rules_chain( ${zone}, ${zone1} );
my $chainref = $filter_table->{$chain};
if ( $chainref ) {
unless( $chainref->{is_policy} ) {
convert_to_policy_chain( $chainref, $zone, $zone1, 'CONTINUE', PROVISIONAL );
push @policy_chains, $chainref;
}
} else {
push @policy_chains, ( new_policy_chain $zone, $zone1, 'CONTINUE', PROVISIONAL );
}
}
sub print_policy($$$$) {
my ( $source, $dest, $policy , $chain ) = @_;
unless ( ( $source eq 'all' ) || ( $dest eq 'all' ) ) {
if ( $policy eq 'CONTINUE' ) {
my ( $sourceref, $destref ) = ( find_zone($source) ,find_zone( $dest ) );
warning_message "CONTINUE policy between two un-nested zones ($source, $dest)" if ! ( @{$sourceref->{parents}} || @{$destref->{parents}} );
}
progress_message_nocompress " Policy for $source to $dest is $policy using chain $chain" unless $source eq $dest;
}
}
sub process_a_policy() {
our %validpolicies;
our @zonelist;
my ( $client, $server, $originalpolicy, $loglevel, $synparams, $connlimit ) = split_line 3, 6, 'policy file';
$loglevel = '' if $loglevel eq '-';
$synparams = '' if $synparams eq '-';
$connlimit = '' if $connlimit eq '-';
my $clientwild = ( "\L$client" eq 'all' );
fatal_error "Undefined zone ($client)" unless $clientwild || defined_zone( $client );
my $serverwild = ( "\L$server" eq 'all' );
fatal_error "Undefined zone ($server)" unless $serverwild || defined_zone( $server );
my ( $policy, $default, $remainder ) = split( /:/, $originalpolicy, 3 );
fatal_error "Invalid or missing POLICY ($originalpolicy)" unless $policy;
fatal_error "Invalid default action ($default:$remainder)" if defined $remainder;
( $policy , my $queue ) = get_target_param $policy;
if ( $default ) {
if ( "\L$default" eq 'none' ) {
$default = 'none';
} else {
my $defaulttype = $targets{$default} || 0;
if ( $defaulttype & ACTION ) {
unless ( $usedactions{$default} ) {
$usedactions{$default} = 1;
createactionchain $default;
}
} else {
fatal_error "Unknown Default Action ($default)";
}
}
} else {
$default = $default_actions{$policy} || '';
}
fatal_error "Invalid policy ($policy)" unless exists $validpolicies{$policy};
if ( defined $queue ) {
fatal_error "Invalid policy ($policy($queue))" unless $policy eq 'NFQUEUE';
require_capability( 'NFQUEUE_TARGET', 'An NFQUEUE Policy', 's' );
my $queuenum = numeric_value( $queue );
fatal_error "Invalid NFQUEUE queue number ($queue)" unless defined( $queuenum) && $queuenum <= 65535;
$policy = "NFQUEUE --queue-num $queuenum";
} elsif ( $policy eq 'NONE' ) {
fatal_error "NONE policy not allowed with \"all\""
if $clientwild || $serverwild;
fatal_error "NONE policy not allowed to/from firewall zone"
if ( zone_type( $client ) == FIREWALL ) || ( zone_type( $server ) == FIREWALL );
}
unless ( $clientwild || $serverwild ) {
if ( zone_type( $server ) == BPORT ) {
fatal_error "Invalid policy - DEST zone is a Bridge Port zone but the SOURCE zone is not associated with the same bridge"
unless find_zone( $client )->{bridge} eq find_zone( $server)->{bridge} || single_interface( $client ) eq find_zone( $server )->{bridge};
}
}
my $chain = rules_chain( ${client}, ${server} );
my $chainref;
if ( defined $filter_table->{$chain} ) {
$chainref = $filter_table->{$chain};
if ( $chainref->{is_policy} ) {
if ( $chainref->{provisional} ) {
$chainref->{provisional} = 0;
$chainref->{policy} = $policy;
} else {
fatal_error qq(Policy "$client $server $policy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
}
} elsif ( $chainref->{policy} ) {
fatal_error qq(Policy "$client $server $policy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
} else {
convert_to_policy_chain( $chainref, $client, $server, $policy, 0 );
push @policy_chains, ( $chainref ) unless $config{EXPAND_POLICIES} && ( $clientwild || $serverwild );
}
} else {
$chainref = new_policy_chain $client, $server, $policy, 0;
push @policy_chains, ( $chainref ) unless $config{EXPAND_POLICIES} && ( $clientwild || $serverwild );
}
$chainref->{loglevel} = validate_level( $loglevel ) if defined $loglevel && $loglevel ne '';
if ( $synparams ne '' || $connlimit ne '' ) {
my $value = '';
fatal_error "Invalid CONNLIMIT ($connlimit)" if $connlimit =~ /^!/;
$value = do_ratelimit $synparams, 'ACCEPT' if $synparams ne '';
$value .= do_connlimit $connlimit if $connlimit ne '';
$chainref->{synparams} = $value;
$chainref->{synchain} = $chain
}
$chainref->{default} = $default if $default;
if ( $clientwild ) {
if ( $serverwild ) {
for my $zone ( @zonelist ) {
for my $zone1 ( @zonelist ) {
set_policy_chain $client, $server, rules_chain( ${zone}, ${zone1} ), $chainref, $policy;
print_policy $zone, $zone1, $policy, $chain;
}
}
} else {
for my $zone ( all_zones ) {
set_policy_chain $client, $server, rules_chain( ${zone}, ${server} ), $chainref, $policy;
print_policy $zone, $server, $policy, $chain;
}
}
} elsif ( $serverwild ) {
for my $zone ( @zonelist ) {
set_policy_chain $client, $server, rules_chain( ${client}, ${zone} ), $chainref, $policy;
print_policy $client, $zone, $policy, $chain;
}
} else {
print_policy $client, $server, $policy, $chain;
}
}
sub save_policies() {
for my $zone1 ( all_zones ) {
for my $zone2 ( all_zones ) {
my $chainref = $filter_table->{ rules_chain( $zone1, $zone2 ) };
my $policyref = $filter_table->{ $chainref->{policychain} };
if ( $policyref->{referenced} ) {
emit_unindented "$zone1 \t=>\t$zone2\t" . $policyref->{policy} . ' using chain ' . $policyref->{name};
} elsif ( $zone1 ne $zone2 ) {
emit_unindented "$zone1 \t=>\t$zone2\t" . $policyref->{policy};
}
}
}
}
sub validate_policy()
{
our %validpolicies = (
ACCEPT => undef,
REJECT => undef,
DROP => undef,
CONTINUE => undef,
QUEUE => undef,
NFQUEUE => undef,
NONE => undef
);
our %map = ( DROP_DEFAULT => 'DROP' ,
REJECT_DEFAULT => 'REJECT' ,
ACCEPT_DEFAULT => 'ACCEPT' ,
QUEUE_DEFAULT => 'QUEUE' ,
NFQUEUE_DEFAULT => 'NFQUEUE' );
my $zone;
our @zonelist = $config{EXPAND_POLICIES} ? all_zones : ( all_zones, 'all' );
for my $option qw/DROP_DEFAULT REJECT_DEFAULT ACCEPT_DEFAULT QUEUE_DEFAULT NFQUEUE_DEFAULT/ {
my $action = $config{$option};
next if $action eq 'none';
my $actiontype = $targets{$action};
if ( defined $actiontype ) {
fatal_error "Invalid setting ($action) for $option" unless $actiontype & ACTION;
} else {
fatal_error "Default Action $option=$action not found";
}
unless ( $usedactions{$action} ) {
$usedactions{$action} = 1;
createactionchain $action;
}
$default_actions{$map{$option}} = $action;
}
for $zone ( all_zones ) {
push @policy_chains, ( new_policy_chain $zone, $zone, 'ACCEPT', PROVISIONAL );
push @policy_chains, ( new_policy_chain firewall_zone, $zone, 'NONE', PROVISIONAL ) if zone_type( $zone ) == BPORT;
if ( $config{IMPLICIT_CONTINUE} && ( @{find_zone( $zone )->{parents}} ) ) {
for my $zone1 ( all_zones ) {
unless( $zone eq $zone1 ) {
add_or_modify_policy_chain( $zone, $zone1 );
add_or_modify_policy_chain( $zone1, $zone );
}
}
}
}
my $fn = open_file 'policy';
first_entry "$doing $fn...";
process_a_policy while read_a_line;
for $zone ( all_zones ) {
for my $zone1 ( all_zones ) {
fatal_error "No policy defined from zone $zone to zone $zone1" unless $filter_table->{rules_chain( ${zone}, ${zone1} )}{policy};
}
}
}
#
# Policy Rule application
#
sub policy_rules( $$$$$ ) {
my ( $chainref , $target, $loglevel, $default, $dropmulticast ) = @_;
unless ( $target eq 'NONE' ) {
add_rule $chainref, "-d 224.0.0.0/4 -j RETURN" if $dropmulticast && $target ne 'CONTINUE' && $target ne 'ACCEPT';
add_jump $chainref, $default, 0 if $default && $default ne 'none';
log_rule $loglevel , $chainref , $target , '' if $loglevel ne '';
fatal_error "Null target in policy_rules()" unless $target;
add_jump( $chainref , $target eq 'REJECT' ? 'reject' : $target, 1 ) unless $target eq 'CONTINUE';
}
}
sub report_syn_flood_protection() {
progress_message_nocompress ' Enabled SYN flood protection';
}
sub default_policy( $$$ ) {
my $chainref = $_[0];
my $policyref = $filter_table->{$chainref->{policychain}};
my $synparams = $policyref->{synparams};
my $default = $policyref->{default};
my $policy = $policyref->{policy};
my $loglevel = $policyref->{loglevel};
assert( $policyref );
if ( $chainref eq $policyref ) {
policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
} else {
if ( $policy eq 'ACCEPT' || $policy eq 'QUEUE' || $policy =~ /^NFQUEUE/ ) {
if ( $synparams ) {
report_syn_flood_protection;
policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
} else {
add_jump $chainref, $policyref, 1;
$chainref = $policyref;
}
} elsif ( $policy eq 'CONTINUE' ) {
report_syn_flood_protection if $synparams;
policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
} else {
report_syn_flood_protection if $synparams;
add_jump $chainref , $policyref, 1;
$chainref = $policyref;
}
}
progress_message_nocompress " Policy $policy from $_[1] to $_[2] using chain $chainref->{name}";
}
sub apply_policy_rules() {
progress_message2 'Applying Policies...';
for my $chainref ( @policy_chains ) {
my $policy = $chainref->{policy};
my $loglevel = $chainref->{loglevel};
my $provisional = $chainref->{provisional};
my $default = $chainref->{default};
my $name = $chainref->{name};
my $synparms = $chainref->{synparms};
if ( $policy ne 'NONE' ) {
unless ( $chainref->{referenced} || $provisional || $policy eq 'CONTINUE' ) {
if ( $config{OPTIMIZE} & 2 ) {
#
# This policy chain is empty and the only thing that we would put in it is
# the policy-related stuff. Don't create it if all we are going to put in it
# is a single jump. Generate_matrix() will just use the policy target when
# needed.
#
ensure_filter_chain $name, 1 if $default ne 'none' || $loglevel || $synparms || $config{MULTICAST} || ! ( $policy eq 'ACCEPT' || $config{FASTACCEPT} );
} else {
ensure_filter_chain $name, 1;
}
}
if ( $name =~ /^all[-2]|[-2]all$/ ) {
run_user_exit $chainref;
policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
}
}
}
for my $zone ( all_zones ) {
for my $zone1 ( all_zones ) {
my $chainref = $filter_table->{rules_chain( ${zone}, ${zone1} )};
if ( $chainref->{referenced} ) {
run_user_exit $chainref;
default_policy $chainref, $zone, $zone1;
}
}
}
}
#
# Complete a standard chain
#
# - run any supplied user exit
# - search the policy file for an applicable policy and add rules as
# appropriate
# - If no applicable policy is found, add rules for an assummed
# policy of DROP INFO
#
sub complete_standard_chain ( $$$$ ) {
my ( $stdchainref, $zone, $zone2, $default ) = @_;
add_rule $stdchainref, "$globals{STATEMATCH} ESTABLISHED,RELATED -j ACCEPT" unless $config{FASTACCEPT};
run_user_exit $stdchainref;
my $ruleschainref = $filter_table->{rules_chain( ${zone}, ${zone2} ) } || $filter_table->{rules_chain( 'all', 'all' ) };
my ( $policy, $loglevel, $defaultaction ) = ( $default , 6, $config{$default . '_DEFAULT'} );
my $policychainref;
$policychainref = $filter_table->{$ruleschainref->{policychain}} if $ruleschainref;
( $policy, $loglevel, $defaultaction ) = @{$policychainref}{'policy', 'loglevel', 'default' } if $policychainref;
policy_rules $stdchainref , $policy , $loglevel, $defaultaction, 0;
}
#
# Create and populate the synflood chains corresponding to entries in /etc/shorewall/policy
#
sub setup_syn_flood_chains() {
for my $chainref ( @policy_chains ) {
my $limit = $chainref->{synparams};
if ( $limit && ! $filter_table->{syn_flood_chain $chainref} ) {
my $level = $chainref->{loglevel};
my $synchainref = new_chain 'filter' , syn_flood_chain $chainref;
add_rule $synchainref , "${limit}-j RETURN";
log_rule_limit $level , $synchainref , $chainref->{name} , 'DROP', '-m limit --limit 5/min --limit-burst 5 ' , '' , 'add' , ''
if $level ne '';
add_rule $synchainref, '-j DROP';
}
}
}
#
# Optimize Policy chains with ACCEPT policy
#
sub optimize_policy_chains() {
for my $chainref ( grep $_->{policy} eq 'ACCEPT', @policy_chains ) {
optimize_chain ( $chainref );
}
#
# Often, fw->all has an ACCEPT policy. This code allows optimization in that case
#
my $outputrules = $filter_table->{OUTPUT}{rules};
if ( @{$outputrules} && $outputrules->[-1] =~ /-j ACCEPT/ ) {
optimize_chain( $filter_table->{OUTPUT} );
}
progress_message ' Policy chains optimized';
progress_message '';
}
1;

View File

@@ -3,7 +3,7 @@
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2010,2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -40,8 +40,8 @@ our @EXPORT = qw(
setup_source_routing
setup_forwarding
);
our @EXPORT_OK = qw( setup_interface_proc );
our $VERSION = 'MODULEVERSION';
our @EXPORT_OK = qw( );
our $VERSION = '4.4_7';
#
# ARP Filtering
@@ -58,7 +58,7 @@ sub setup_arp_filtering() {
for my $interface ( @$interfaces ) {
my $value = get_interface_option $interface, 'arp_filter';
my $optional = interface_is_optional $interface;
$interface = get_physical $interface;
my $file = "/proc/sys/net/ipv4/conf/$interface/arp_filter";
@@ -74,7 +74,7 @@ sub setup_arp_filtering() {
for my $interface ( @$interfaces1 ) {
my $value = get_interface_option $interface, 'arp_ignore';
my $optional = interface_is_optional $interface;
$interface = get_physical $interface;
my $file = "/proc/sys/net/ipv4/conf/$interface/arp_ignore";
@@ -106,7 +106,7 @@ sub setup_route_filtering() {
my $val = '';
if ( $config ne '' ) {
if ( $config{ROUTE_FILTER} ne '' ) {
$val = $config eq 'on' ? 1 : $config eq 'off' ? 0 : $config;
emit ( 'for file in /proc/sys/net/ipv4/conf/*; do',
@@ -118,7 +118,7 @@ sub setup_route_filtering() {
for my $interface ( @$interfaces ) {
my $value = get_interface_option $interface, 'routefilter';
my $optional = interface_is_optional $interface;
$interface = get_physical $interface;
my $file = "/proc/sys/net/ipv4/conf/$interface/rp_filter";
@@ -169,7 +169,7 @@ sub setup_martian_logging() {
for my $interface ( @$interfaces ) {
my $value = get_interface_option $interface, 'logmartians';
my $optional = interface_is_optional $interface;
$interface = get_physical $interface;
my $file = "/proc/sys/net/ipv4/conf/$interface/log_martians";
@@ -227,10 +227,6 @@ sub setup_forwarding( $$ ) {
}
emit '';
emit ( ' echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables' ,
''
) if have_bridges;
} else {
if ( $config{IP_FORWARDING} eq 'on' ) {
emit ' echo 1 > /proc/sys/net/ipv6/conf/all/forwarding';
@@ -242,10 +238,6 @@ sub setup_forwarding( $$ ) {
emit '';
emit ( ' echo 1 > /proc/sys/net/bridge/bridge-nf-call-ip6tables' ,
''
) if have_bridges;
my $interfaces = find_interfaces_by_option 'forward';
if ( @$interfaces ) {
@@ -277,45 +269,4 @@ sub setup_forwarding( $$ ) {
}
}
sub setup_interface_proc( $ ) {
my $interface = shift;
my $physical = get_physical $interface;
my $value;
my @emitted;
if ( interface_has_option( $interface, 'arp_filter' , $value ) ) {
push @emitted, "echo $value > /proc/sys/net/ipv4/conf/$physical/arp_filter";
}
if ( interface_has_option( $interface, 'arp_ignore' , $value ) ) {
push @emitted, "echo $value > /proc/sys/net/ipv4/conf/$physical/arp_ignore";
}
if ( interface_has_option( $interface, 'routefilter' , $value ) ) {
push @emitted, "echo $value > /proc/sys/net/ipv4/conf/$physical/rp_filter";
}
if ( interface_has_option( $interface, 'logmartians' , $value ) ) {
push @emitted, "echo $value > /proc/sys/net/ipv4/conf/$physical/log_martians";
}
if ( interface_has_option( $interface, 'sourceroute' , $value ) ) {
push @emitted, "echo $value > /proc/sys/net/ipv4/conf/$physical/accept_source_route";
}
if ( interface_has_option( $interface, 'sourceroute' , $value ) ) {
push @emitted, "echo $value > /proc/sys/net/ipv4/conf/$physical/accept_source_route";
}
if ( @emitted ) {
emit( '',
'if [ $COMMAND = enable ]; then' );
push_indent;
emit "$_" for @emitted;
pop_indent;
emit "fi\n";
}
}
1;

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2011,2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -35,7 +35,7 @@ our @EXPORT = qw(
);
our @EXPORT_OK = qw( initialize );
our $VERSION = 'MODULEVERSION';
our $VERSION = '4.4_9';
our @proxyarp;
@@ -56,10 +56,8 @@ sub initialize( $ ) {
@proxyarp = ();
}
sub setup_one_proxy_arp( $$$$$$$ ) {
my ( $address, $interface, $physical, $external, $extphy, $haveroute, $persistent) = @_;
my $proto = $family == F_IPV4 ? 'ARP' : 'NDP';
sub setup_one_proxy_arp( $$$$$ ) {
my ( $address, $interface, $external, $haveroute, $persistent) = @_;
if ( "\L$haveroute" eq 'no' || $haveroute eq '-' ) {
$haveroute = '';
@@ -78,105 +76,105 @@ sub setup_one_proxy_arp( $$$$$$$ ) {
}
unless ( $haveroute ) {
fatal_error "HAVEROUTE=No requires an INTERFACE" if $interface eq '-';
if ( $family == F_IPV4 ) {
emit "[ -n \"\$g_noroutes\" ] || run_ip route replace $address/32 dev $physical";
} else {
emit( 'if [ -z "$g_noroutes" ]; then',
" qt \$IP -6 route del $address/128 dev $physical".
" run_ip route add $address/128 dev $physical",
'fi'
);
}
emit "[ -n \"\$g_noroutes\" ] || run_ip route replace $address dev $interface";
$haveroute = 1 if $persistent;
}
emit ( "run_ip neigh add proxy $address nud permanent dev $extphy" ,
qq(progress_message " Host $address connected to $interface added to $proto on $extphy"\n) );
emit ( "if ! arp -i $external -Ds $address $external pub; then",
" fatal_error \"Command 'arp -i $external -Ds $address $external pub' failed\"" ,
'fi' ,
'',
"progress_message \" Host $address connected to $interface added to ARP on $external\"\n" );
push @proxyarp, "$address $interface $external $haveroute";
progress_message " Host $address connected to $interface added to $proto on $external";
progress_message " Host $address connected to $interface added to ARP on $external";
}
#
# Setup Proxy ARP/NDP
# Setup Proxy ARP
#
sub setup_proxy_arp() {
my $proto = $family == F_IPV4 ? 'arp' : 'ndp'; # Protocol
my $file_opt = 'proxy' . $proto; # Name of config file and of the interface option
my $proc_file = 'proxy_' . $proto; # Name of the corresponding file in /proc
if ( $family == F_IPV4 ) {
my $interfaces= find_interfaces_by_option $file_opt;
my $fn = open_file $file_opt;
my $interfaces= find_interfaces_by_option 'proxyarp';
my $fn = open_file 'proxyarp';
if ( @$interfaces || $fn ) {
if ( @$interfaces || $fn ) {
my $first_entry = 1;
my $first_entry = 1;
save_progress_message 'Setting up Proxy ' . uc($proto) . '...';
save_progress_message "Setting up Proxy ARP...";
my ( %set, %reset );
my ( %set, %reset );
while ( read_a_line ) {
while ( read_a_line ) {
my ( $address, $interface, $external, $haveroute, $persistent ) = split_line 3, 5, $file_opt;
my ( $address, $interface, $external, $haveroute, $persistent ) = split_line 3, 5, 'proxyarp file';
if ( $first_entry ) {
progress_message2 "$doing $fn...";
$first_entry = 0;
}
if ( $first_entry ) {
progress_message2 "$doing $fn...";
$first_entry = 0;
}
fatal_error "Unknown interface ($external)" unless known_interface $external;
fatal_error "Wildcard interface ($external) not allowed" if $external =~ /\+$/;
$reset{$external} = 1 unless $set{$external};
$interface = get_physical $interface;
$external = get_physical $external;
my $extphy = get_physical $external;
my $physical = '-';
if ( $interface ne '-' ) {
fatal_error "Unknown interface ($interface)" unless known_interface $interface;
fatal_error "Wildcard interface ($interface) not allowed" if $interface =~ /\+$/;
$physical = physical_name $interface;
$set{$interface} = 1;
$reset{$external} = 1 unless $set{$external};
setup_one_proxy_arp( $address, $interface, $external, $haveroute, $persistent );
}
setup_one_proxy_arp( $address, $interface, $physical, $external, $extphy, $haveroute, $persistent );
}
emit '';
emit '';
for my $interface ( keys %reset ) {
unless ( $set{interface} ) {
emit ( "if [ -f /proc/sys/net/ipv4/conf/$interface/proxy_arp ]; then" ,
" echo 0 > /proc/sys/net/ipv4/conf/$interface/proxy_arp" );
emit "fi\n";
}
}
for my $interface ( keys %reset ) {
unless ( $set{interface} ) {
my $physical = get_physical $interface;
emit ( "if [ -f /proc/sys/net/ipv$family/conf/$physical/$proc_file ]; then" ,
" echo 0 > /proc/sys/net/ipv$family/conf/$physical/$proc_file" );
for my $interface ( keys %set ) {
emit ( "if [ -f /proc/sys/net/ipv4/conf/$interface/proxy_arp ]; then" ,
" echo 1 > /proc/sys/net/ipv4/conf/$interface/proxy_arp" );
emit ( 'else' ,
" error_message \" WARNING: Cannot set the 'proxy_arp' option for interface $interface\"" ) unless interface_is_optional( $interface );
emit "fi\n";
}
for my $interface ( @$interfaces ) {
my $value = get_interface_option $interface, 'proxyarp';
my $optional = interface_is_optional $interface;
$interface = get_physical $interface;
emit ( "if [ -f /proc/sys/net/ipv4/conf/$interface/proxy_arp ] ; then" ,
" echo $value > /proc/sys/net/ipv4/conf/$interface/proxy_arp" );
emit ( 'else' ,
" error_message \"WARNING: Unable to set/reset proxy ARP on $interface\"" ) unless $optional;
emit "fi\n";
}
}
} else {
my $interfaces= find_interfaces_by_option 'proxyndp';
for my $interface ( keys %set ) {
my $physical = get_physical $interface;
emit ( "if [ -f /proc/sys/net/ipv$family/conf/$physical/$proc_file ]; then" ,
" echo 1 > /proc/sys/net/ipv$family/conf/$physical/$proc_file" );
emit ( 'else' ,
" error_message \" WARNING: Cannot set the '$file_opt' option for interface $physical\"" ) unless interface_is_optional( $interface );
emit "fi\n";
}
if ( @$interfaces ) {
save_progress_message "Setting up Proxy NDP...";
for my $interface ( @$interfaces ) {
my $value = get_interface_option $interface, $file_opt;
my $optional = interface_is_optional $interface;
for my $interface ( @$interfaces ) {
my $value = get_interface_option $interface, 'proxyndp';
my $optional = interface_is_optional $interface;
$interface = get_physical $interface;
$interface = get_physical $interface;
emit ( "if [ -f /proc/sys/net/ipv$family/conf/$interface/$proc_file ] ; then" ,
" echo $value > /proc/sys/net/ipv$family/conf/$interface/$proc_file" );
emit ( 'else' ,
" error_message \"WARNING: Unable to set/reset the '$file_opt' option on $interface\"" ) unless $optional;
emit "fi\n";
emit ( "if [ -f /proc/sys/net/ipv6/conf/$interface/proxy_ndp ] ; then" ,
" echo $value > /proc/sys/net/ipv6/conf/$interface/proxy_ndp" );
emit ( 'else' ,
" error_message \"WARNING: Unable to set/reset Proxy NDP on $interface\"" ) unless $optional;
emit "fi\n";
}
}
}
}

View File

@@ -3,7 +3,7 @@
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2009,2010,2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2009 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -34,7 +34,7 @@ use strict;
our @ISA = qw(Exporter);
our @EXPORT = qw( setup_notrack );
our @EXPORT_OK = qw( );
our $VERSION = 'MODULEVERSION';
our $VERSION = '4.3_7';
#
# Notrack
@@ -50,9 +50,9 @@ sub process_notrack_rule( $$$$$$ ) {
( my $zone, $source) = split /:/, $source, 2;
my $zoneref = find_zone $zone;
my $chainref = ensure_raw_chain( notrack_chain $zone );
my $restriction = $zoneref->{type} == FIREWALL || $zoneref->{type} == VSERVER ? OUTPUT_RESTRICT : PREROUTE_RESTRICT;
my $restriction = $zone eq firewall_zone ? OUTPUT_RESTRICT : PREROUTE_RESTRICT;
fatal_error 'USER/GROUP is not allowed unless the SOURCE zone is $FW or a Vserver zone' if $user ne '-' && $restriction != OUTPUT_RESTRICT;
fatal_error 'USER/GROUP is not allowed unless the SOURCE zone is $FW' if $user ne '-' && $restriction != OUTPUT_RESTRICT;
require_capability 'RAW_TABLE', 'Notrack rules', '';
my $rule = do_proto( $proto, $ports, $sports ) . do_user ( $user );
@@ -64,7 +64,7 @@ sub process_notrack_rule( $$$$$$ ) {
$source ,
$dest ,
'' ,
'NOTRACK' ,
'-j NOTRACK' ,
'' ,
'NOTRACK' ,
'' ;
@@ -76,25 +76,24 @@ sub process_notrack_rule( $$$$$$ ) {
sub setup_notrack() {
if ( my $fn = open_file 'notrack' ) {
my $fn = open_file 'notrack';
first_entry "$doing $fn...";
first_entry "$doing $fn...";
my $nonEmpty = 0;
my $nonEmpty = 0;
while ( read_a_line ) {
while ( read_a_line ) {
my ( $source, $dest, $proto, $ports, $sports, $user ) = split_line1 1, 6, 'Notrack File';
my ( $source, $dest, $proto, $ports, $sports, $user ) = split_line1 1, 6, 'Notrack File';
if ( $source eq 'COMMENT' ) {
process_comment;
} else {
process_notrack_rule $source, $dest, $proto, $ports, $sports, $user;
}
if ( $source eq 'COMMENT' ) {
process_comment;
} else {
process_notrack_rule $source, $dest, $proto, $ports, $sports, $user;
}
clear_comment;
}
clear_comment;
}
1;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2010,2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -28,14 +28,13 @@ use Shorewall::Config qw(:DEFAULT :internal);
use Shorewall::Zones;
use Shorewall::IPAddrs;
use Shorewall::Chains qw(:DEFAULT :internal);
use Shorewall::Rules;
use strict;
our @ISA = qw(Exporter);
our @EXPORT = qw( setup_tunnels );
our @EXPORT_OK = ( );
our $VERSION = 'MODULEVERSION';
our $VERSION = '4.4_9';
#
# Here starts the tunnel stuff -- we really should get rid of this crap...
@@ -62,47 +61,47 @@ sub setup_tunnels() {
}
}
my @options = $globals{UNTRACKED} ? state_imatch 'NEW,UNTRACKED' : state_imatch 'NEW';
my $options = $globals{UNTRACKED} ? "$globals{STATEMATCH} NEW,UNTRACKED -j ACCEPT" : "$globals{STATEMATCH} NEW -j ACCEPT";
add_tunnel_rule $inchainref, p => 50, @$source;
add_tunnel_rule $outchainref, p => 50, @$dest;
add_tunnel_rule $inchainref, "-p 50 $source -j ACCEPT";
add_tunnel_rule $outchainref, "-p 50 $dest -j ACCEPT";
unless ( $noah ) {
add_tunnel_rule $inchainref, p => 51, @$source;
add_tunnel_rule $outchainref, p => 51, @$dest;
add_tunnel_rule $inchainref, "-p 51 $source -j ACCEPT";
add_tunnel_rule $outchainref, "-p 51 $dest -j ACCEPT";
}
if ( $kind eq 'ipsec' ) {
add_tunnel_rule $inchainref, p => 'udp --dport 500', @$source, @options;
add_tunnel_rule $outchainref, p => 'udp --dport 500', @$dest, @options;
add_tunnel_rule $inchainref, "-p udp $source --dport 500 $options";
add_tunnel_rule $outchainref, "-p udp $dest --dport 500 $options";
} else {
add_tunnel_rule $inchainref, p => 'udp', @$source, multiport => '--dports 500,4500', @options;
add_tunnel_rule $outchainref, p => 'udp', @$dest, multiport => '--dports 500,4500', @options;
add_tunnel_rule $inchainref, "-p udp $source -m multiport --dports 500,4500 $options";
add_tunnel_rule $outchainref, "-p udp $dest -m multiport --dports 500,4500 $options";
}
unless ( $gatewayzones eq '-' ) {
for my $zone ( split_list $gatewayzones, 'zone' ) {
my $type = zone_type( $zone );
fatal_error "Invalid zone ($zone) for GATEWAY ZONE" if $type == FIREWALL || $type == BPORT;
$inchainref = ensure_rules_chain( rules_chain( ${zone}, ${fw} ) );
$outchainref = ensure_rules_chain( rules_chain( ${fw}, ${zone} ) );
$inchainref = ensure_filter_chain rules_chain( ${zone}, ${fw} ), 1;
$outchainref = ensure_filter_chain rules_chain( ${fw}, ${zone} ), 1;
unless ( have_ipsec ) {
add_tunnel_rule $inchainref, p => 50, @$source;
add_tunnel_rule $outchainref, p => 50, @$dest;
add_tunnel_rule $inchainref, "-p 50 $source -j ACCEPT";
add_tunnel_rule $outchainref, "-p 50 $dest -j ACCEPT";
unless ( $noah ) {
add_tunnel_rule $inchainref, p => 51, @$source;
add_tunnel_rule $outchainref, p => 51, @$dest;
add_tunnel_rule $inchainref, "-p 51 $source -j ACCEPT";
add_tunnel_rule $outchainref, "-p 51 $dest -j ACCEPT";
}
}
if ( $kind eq 'ipsec' ) {
add_tunnel_rule $inchainref, p => 'udp --dport 500', @$source, @options;
add_tunnel_rule $outchainref, p => 'udp --dport 500', @$dest, @options;
add_tunnel_rule $inchainref, "-p udp $source --dport 500 $options";
add_tunnel_rule $outchainref, "-p udp $dest --dport 500 $options";
} else {
add_tunnel_rule $inchainref, p => 'udp', @$source, multiport => '--dports 500,4500', @options;
add_tunnel_rule $outchainref, p => 'udp', @$dest, multiport => '--dports 500,4500', @options;
add_tunnel_rule $inchainref, "-p udp $source -m multiport --dports 500,4500 $options";
add_tunnel_rule $outchainref, "-p udp $dest -m multiport --dports 500,4500 $options";
}
}
}
@@ -111,24 +110,24 @@ sub setup_tunnels() {
sub setup_one_other {
my ($inchainref, $outchainref, $source, $dest , $protocol) = @_;
add_tunnel_rule $inchainref , p => $protocol, @$source;
add_tunnel_rule $outchainref , p => $protocol, @$dest;
add_tunnel_rule $inchainref , "-p $protocol $source -j ACCEPT";
add_tunnel_rule $outchainref , "-p $protocol $dest -j ACCEPT";
}
sub setup_pptp_client {
my ($inchainref, $outchainref, $kind, $source, $dest ) = @_;
add_tunnel_rule $outchainref, p => 47, @$dest;
add_tunnel_rule $inchainref, p => 47, @$source;
add_tunnel_rule $outchainref, p => 'tcp --dport 1723', @$dest;
}
add_tunnel_rule $outchainref, "-p 47 $dest -j ACCEPT";
add_tunnel_rule $inchainref, "-p 47 $source -j ACCEPT";
add_tunnel_rule $outchainref, "-p tcp --dport 1723 $dest -j ACCEPT"
}
sub setup_pptp_server {
my ($inchainref, $outchainref, $kind, $source, $dest ) = @_;
add_tunnel_rule $inchainref, p => 47, @$dest;
add_tunnel_rule $outchainref, p => 47, @$source;
add_tunnel_rule $inchainref, p => 'tcp --dport 1723', @$dest
add_tunnel_rule $inchainref, "-p 47 $dest -j ACCEPT";
add_tunnel_rule $outchainref, "-p 47 $source -j ACCEPT";
add_tunnel_rule $inchainref, "-p tcp --dport 1723 $dest -j ACCEPT"
}
sub setup_one_openvpn {
@@ -141,10 +140,10 @@ sub setup_tunnels() {
fatal_error "Invalid port ($p:$remainder)" if defined $remainder;
if ( supplied $p ) {
if ( defined $p && $p ne '' ) {
$port = $p;
$protocol = $proto;
} elsif ( supplied $proto ) {
} elsif ( defined $proto && $proto ne '' ) {
if ( "\L$proto" =~ /udp|tcp/ ) {
$protocol = $proto;
} else {
@@ -152,8 +151,8 @@ sub setup_tunnels() {
}
}
add_tunnel_rule $inchainref, p => "$protocol --dport $port", @$source;
add_tunnel_rule $outchainref, p => "$protocol --dport $port", @$dest;;
add_tunnel_rule $inchainref, "-p $protocol $source --dport $port -j ACCEPT";
add_tunnel_rule $outchainref, "-p $protocol $dest --dport $port -j ACCEPT";
}
sub setup_one_openvpn_client {
@@ -166,10 +165,10 @@ sub setup_tunnels() {
fatal_error "Invalid port ($p:$remainder)" if defined $remainder;
if ( supplied $p ) {
if ( defined $p && $p ne '' ) {
$port = $p;
$protocol = $proto;
} elsif ( supplied $proto ) {
} elsif ( defined $proto && $proto ne '' ) {
if ( "\L$proto" =~ /udp|tcp/ ) {
$protocol = $proto;
} else {
@@ -177,8 +176,8 @@ sub setup_tunnels() {
}
}
add_tunnel_rule $inchainref, p => "$protocol --sport $port", @$source;
add_tunnel_rule $outchainref, p => "$protocol --dport $port", @$dest;
add_tunnel_rule $inchainref, "-p $protocol $source --sport $port -j ACCEPT";
add_tunnel_rule $outchainref, "-p $protocol $dest --dport $port -j ACCEPT";
}
sub setup_one_openvpn_server {
@@ -191,10 +190,10 @@ sub setup_tunnels() {
fatal_error "Invalid port ($p:$remainder)" if defined $remainder;
if ( supplied $p ) {
if ( defined $p && $p ne '' ) {
$port = $p;
$protocol = $proto;
} elsif ( supplied $proto ) {
} elsif ( defined $proto && $proto ne '' ) {
if ( "\L$proto" =~ /udp|tcp/ ) {
$protocol = $proto;
} else {
@@ -202,8 +201,8 @@ sub setup_tunnels() {
}
}
add_tunnel_rule $inchainref, p => "$protocol --dport $port" , @$source;
add_tunnel_rule $outchainref, p => "$protocol --sport $port", @$dest;
add_tunnel_rule $inchainref, "-p $protocol $source --dport $port -j ACCEPT";
add_tunnel_rule $outchainref, "-p $protocol $dest --sport $port -j ACCEPT";
}
sub setup_one_l2tp {
@@ -211,8 +210,8 @@ sub setup_tunnels() {
fatal_error "Unknown option ($1)" if $kind =~ /^.*?:(.*)$/;
add_tunnel_rule $inchainref, p => 'udp --sport 1701 --dport 1701', @$source;
add_tunnel_rule $outchainref, p => 'udp --sport 1701 --dport 1701', @$dest;
add_tunnel_rule $inchainref, "-p udp $source --sport 1701 --dport 1701 -j ACCEPT";
add_tunnel_rule $outchainref, "-p udp $dest --sport 1701 --dport 1701 -j ACCEPT";
}
sub setup_one_generic {
@@ -229,8 +228,8 @@ sub setup_tunnels() {
( $kind, $protocol ) = split /:/ , $kind if $kind =~ /.*:.*/;
}
add_tunnel_rule $inchainref, p => "$protocol $port", @$source;
add_tunnel_rule $outchainref, p => "$protocol $port", @$dest;
add_tunnel_rule $inchainref, "-p $protocol $source $port -j ACCEPT";
add_tunnel_rule $outchainref, "-p $protocol $dest $port -j ACCEPT";
}
sub setup_one_tunnel($$$$) {
@@ -240,26 +239,26 @@ sub setup_tunnels() {
fatal_error "Invalid tunnel ZONE ($zone)" if $zonetype == FIREWALL || $zonetype == BPORT;
my $inchainref = ensure_rules_chain( rules_chain( ${zone}, ${fw} ) );
my $outchainref = ensure_rules_chain( rules_chain( ${fw}, ${zone} ) );
my $inchainref = ensure_filter_chain rules_chain( ${zone}, ${fw} ), 1;
my $outchainref = ensure_filter_chain rules_chain( ${fw}, ${zone} ), 1;
$gateway = ALLIP if $gateway eq '-';
my @source = imatch_source_net $gateway;
my @dest = imatch_dest_net $gateway;
my $source = match_source_net $gateway;
my $dest = match_dest_net $gateway;
my %tunneltypes = ( 'ipsec' => { function => \&setup_one_ipsec , params => [ $kind, \@source, \@dest , $gatewayzones ] } ,
'ipsecnat' => { function => \&setup_one_ipsec , params => [ $kind, \@source, \@dest , $gatewayzones ] } ,
'ipip' => { function => \&setup_one_other, params => [ \@source, \@dest , 4 ] } ,
'gre' => { function => \&setup_one_other, params => [ \@source, \@dest , 47 ] } ,
'6to4' => { function => \&setup_one_other, params => [ \@source, \@dest , 41 ] } ,
'pptpclient' => { function => \&setup_pptp_client, params => [ $kind, \@source, \@dest ] } ,
'pptpserver' => { function => \&setup_pptp_server, params => [ $kind, \@source, \@dest ] } ,
'openvpn' => { function => \&setup_one_openvpn, params => [ $kind, \@source, \@dest ] } ,
'openvpnclient' => { function => \&setup_one_openvpn_client, params => [ $kind, \@source, \@dest ] } ,
'openvpnserver' => { function => \&setup_one_openvpn_server, params => [ $kind, \@source, \@dest ] } ,
'l2tp' => { function => \&setup_one_l2tp , params => [ $kind, \@source, \@dest ] } ,
'generic' => { function => \&setup_one_generic , params => [ $kind, \@source, \@dest ] } ,
my %tunneltypes = ( 'ipsec' => { function => \&setup_one_ipsec , params => [ $kind, $source, $dest , $gatewayzones ] } ,
'ipsecnat' => { function => \&setup_one_ipsec , params => [ $kind, $source, $dest , $gatewayzones ] } ,
'ipip' => { function => \&setup_one_other, params => [ $source, $dest , 4 ] } ,
'gre' => { function => \&setup_one_other, params => [ $source, $dest , 47 ] } ,
'6to4' => { function => \&setup_one_other, params => [ $source, $dest , 41 ] } ,
'pptpclient' => { function => \&setup_pptp_client, params => [ $kind, $source, $dest ] } ,
'pptpserver' => { function => \&setup_pptp_server, params => [ $kind, $source, $dest ] } ,
'openvpn' => { function => \&setup_one_openvpn, params => [ $kind, $source, $dest ] } ,
'openvpnclient' => { function => \&setup_one_openvpn_client, params => [ $kind, $source, $dest ] } ,
'openvpnserver' => { function => \&setup_one_openvpn_server, params => [ $kind, $source, $dest ] } ,
'l2tp' => { function => \&setup_one_l2tp , params => [ $kind, $source, $dest ] } ,
'generic' => { function => \&setup_one_generic , params => [ $kind, $source, $dest ] } ,
);
$kind = "\L$kind";
@@ -278,23 +277,22 @@ sub setup_tunnels() {
#
# Setup_Tunnels() Starts Here
#
if ( my $fn = open_file 'tunnels' ) {
my $fn = open_file 'tunnels';
first_entry "$doing $fn...";
first_entry "$doing $fn...";
while ( read_a_line ) {
while ( read_a_line ) {
my ( $kind, $zone, $gateway, $gatewayzones ) = split_line1 2, 4, 'tunnels file';
my ( $kind, $zone, $gateway, $gatewayzones ) = split_line1 2, 4, 'tunnels file';
if ( $kind eq 'COMMENT' ) {
process_comment;
} else {
setup_one_tunnel $kind, $zone, $gateway, $gatewayzones;
}
if ( $kind eq 'COMMENT' ) {
process_comment;
} else {
setup_one_tunnel $kind, $zone, $gateway, $gatewayzones;
}
clear_comment;
}
clear_comment;
}
1;

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2007,2008,2009,2010,2011 - Tom Eastep (teastep@shorewall.net)
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
@@ -54,15 +54,12 @@ sub usage( $ ) {
[ --verbose={-1|0-2} ]
[ --timestamp ]
[ --debug ]
[ --confess ]
[ --refresh=<chainlist> ]
[ --log=<filename> ]
[ --log-verbose={-1|0-2} ]
[ --test ]
[ --preview ]
[ --family={4|6} ]
[ --annotate ]
[ --updatee ]
';
exit shift @_;
@@ -76,16 +73,13 @@ my $shorewall_dir = '';
my $verbose = 0;
my $timestamp = 0;
my $debug = 0;
my $confess = 0;
my $chains = ':none:';
my $chains = '';
my $log = '';
my $log_verbose = 0;
my $help = 0;
my $test = 0;
my $family = 4; # F_IPV4
my $preview = 0;
my $annotate = 0;
my $update = 0;
Getopt::Long::Configure ('bundling');
@@ -109,12 +103,6 @@ my $result = GetOptions('h' => \$help,
'preview' => \$preview,
'f=i' => \$family,
'family=i' => \$family,
'c' => \$confess,
'confess' => \$confess,
'a' => \$annotate,
'annotate' => \$annotate,
'u' => \$update,
'update' => \$update,
);
usage(1) unless $result && @ARGV < 2;
@@ -131,8 +119,4 @@ compiler( script => $ARGV[0] || '',
log_verbosity => $log_verbose,
test => $test,
preview => $preview,
family => $family,
confess => $confess,
update => $update,
annotate => $annotate,
);
family => $family );

View File

@@ -1,40 +0,0 @@
#!/bin/sh
#
# The Shoreline Firewall Packet Filtering Firewall Param File Helper - V4.4
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2010,2011 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
if [ "$3" = 6 ]; then
. /usr/share/shorewall6/lib.base
. /usr/share/shorewall6/lib.cli
else
. /usr/share/shorewall/lib.base
. /usr/share/shorewall/lib.cli
fi
CONFIG_PATH="$2"
set -a
. $1 >&2 # Avoid spurious output on STDOUT
set +a
export -p

View File

@@ -5,22 +5,8 @@
# Give Usage Information
#
usage() {
echo "Usage: $0 [ options ] <command>"
echo "Usage: $0 [ options ] [ start|stop|clear|reset|refresh|restart|status|version ]"
echo
echo "<command> is one of:"
echo " start"
echo " stop"
echo " clear"
echo " disable <interface>"
echo " down <interface>"
echo " enable <interface>"
echo " reset"
echo " refresh"
echo " restart"
echo " status"
echo " up <interface>"
echo " version"
echo
echo "Options are:"
echo
echo " -v and -q Standard Shorewall verbosity controls"
@@ -99,7 +85,7 @@ while [ $finished -eq 0 -a $# -gt 0 ]; do
t*)
g_timestamp=Yes
option=${option#t}
;;
;;
p*)
g_purge=Yes
option=${option#p}
@@ -140,7 +126,7 @@ while [ $finished -eq 0 -a $# -gt 0 ]; do
if [ -n "$option" ]; then
case $option in
*/*)
*/*)
startup_error "-R must specify a simple file name: $option"
;;
.safe|.try|NONE)
@@ -183,10 +169,8 @@ case "$COMMAND" in
detect_configuration
define_firewall
status=$?
if [ $status -eq 0 ]; then
[ -n "$SUBSYSLOCK" ] && touch $SUBSYSLOCK
progress_message3 "done."
fi
[ -n "$SUBSYSLOCK" -a $status -eq 0 ] && touch $SUBSYSLOCK
progress_message3 "done."
fi
;;
stop)
@@ -234,16 +218,15 @@ case "$COMMAND" in
else
error_message "$g_product is not running"
progress_message3 "Starting $g_product...."
COMMAND=start
fi
detect_configuration
define_firewall
status=$?
if [ -n "$SUBSYSLOCK" ]; then
[ $status -eq 0 ] && touch $SUBSYSLOCK || rm -f $SUBSYSLOCK
fi
[ $status -eq 0 ] && progress_message3 "done."
[ $status -eq 0 ] && touch $SUBSYSLOCK || rm -f $SUBSYSLOCK
fi
progress_message3 "done."
;;
refresh)
[ $# -ne 1 ] && usage 2
@@ -252,7 +235,7 @@ case "$COMMAND" in
detect_configuration
define_firewall
status=$?
[ $status -eq 0 ] && progress_message3 "done."
progress_message3 "done."
else
echo "$g_product is not running" >&2
status=2
@@ -272,10 +255,8 @@ case "$COMMAND" in
progress_message3 "Clearing $g_product...."
clear_firewall
status=0
if [ $status -eq 0 ]; then
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
progress_message3 "done."
fi
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
progress_message3 "done."
;;
status)
[ $# -ne 1 ] && usage 2
@@ -292,7 +273,7 @@ case "$COMMAND" in
if [ -f ${VARDIR}/state ]; then
state="$(cat ${VARDIR}/state)"
case $state in
Stopped*|lClear*)
Stopped*|Clear*)
status=3
;;
esac
@@ -302,33 +283,6 @@ case "$COMMAND" in
echo "State:$state"
echo
;;
up|down)
[ $# -eq 1 ] && exit 0
shift
[ $# -ne 1 ] && usage 2
updown $@
status=0;
;;
enable)
[ $# -eq 1 ] && exit 0
shift
[ $# -ne 1 ] && usage 2
if shorewall_is_started; then
detect_configuration
enable_provider $1
fi
status=0
;;
disable)
[ $# -eq 1 ] && exit 0
shift
[ $# -ne 1 ] && usage 2
if shorewall_is_started; then
detect_configuration
disable_provider $1
fi
status=0
;;
version)
[ $# -ne 1 ] && usage 2
echo $SHOREWALL_VERSION

View File

@@ -5,8 +5,8 @@
# Give Usage Information
#
usage() {
echo "Usage: $0 [ options ] [ start|stop|clear|down|reset|refresh|restart|status|up|version ]"
echo
echo "Usage: $0 [ options ] [ start|stop|clear|reset|refresh|restart|status|version ]"
echo
echo "Options are:"
echo
echo " -v and -q Standard Shorewall verbosity controls"
@@ -17,28 +17,6 @@ usage() {
echo " -R <file> Override RESTOREFILE setting"
exit $1
}
checkkernelversion() {
local kernel
kernel=$(uname -r 2> /dev/null | sed -e 's/-.*//')
case "$kernel" in
*.*.*)
kernel=$(printf "%d%02d%02d" $(echo $kernel | sed -e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/\1 \2 \3/g'))
;;
*)
kernel=$(printf "%d%02d00" $(echo $kernel | sed -e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/\1 \2/g'))
;;
esac
if [ $kernel -lt 20624 ]; then
error_message "ERROR: $g_product requires Linux kernel 2.6.24 or later"
return 1
else
return 0
fi
}
################################################################################
# E X E C U T I O N B E G I N S H E R E #
################################################################################
@@ -107,7 +85,7 @@ while [ $finished -eq 0 -a $# -gt 0 ]; do
t*)
g_timestamp=Yes
option=${option#t}
;;
;;
p*)
g_purge=Yes
option=${option#p}
@@ -148,7 +126,7 @@ while [ $finished -eq 0 -a $# -gt 0 ]; do
if [ -n "$option" ]; then
case $option in
*/*)
*/*)
startup_error "-R must specify a simple file name: $option"
;;
.safe|.try|NONE)
@@ -177,43 +155,40 @@ done
COMMAND="$1"
case "$COMMAND" in
start)
[ $# -ne 1 ] && usage 2
if shorewall6_is_started; then
error_message "$g_product is already Running"
status=0
else
progress_message3 "Starting $g_product...."
if checkkernelversion; then
kernel=$(printf "%2d%02d%02d" $(uname -r 2> /dev/null | sed -e 's/-.*//' -e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/\1 \2 \3/g'))
if [ $kernel -lt 20624 ]; then
error_message "ERROR: $g_product requires Linux kernel 2.6.24 or later"
status=2
else
case "$COMMAND" in
start)
[ $# -ne 1 ] && usage 2
if shorewall6_is_started; then
error_message "$g_product is already Running"
status=0
else
progress_message3 "Starting $g_product...."
detect_configuration
define_firewall
status=$?
if [ $status -eq 0 ]; then
[ -n "$SUBSYSLOCK" ] && touch $SUBSYSLOCK
progress_message3 "done."
fi
[ -n "$SUBSYSLOCK" -a $status -eq 0 ] && touch $SUBSYSLOCK
progress_message3 "done."
fi
fi
;;
stop)
[ $# -ne 1 ] && usage 2
if checkkernelversion; then
;;
stop)
[ $# -ne 1 ] && usage 2
progress_message3 "Stopping $g_product...."
detect_configuration
stop_firewall
status=0
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
progress_message3 "done."
fi
;;
reset)
if ! shorewall6_is_started ; then
error_message "$g_product is not running"
status=2
elif checkkernelversion; then
if [ $# -eq 1 ]; then
;;
reset)
if ! shorewall6_is_started ; then
error_message "$g_product is not running"
status=2
elif [ $# -eq 1 ]; then
$IP6TABLES -Z
$IP6TABLES -t mangle -Z
date > ${VARDIR}/restarted
@@ -236,112 +211,92 @@ case "$COMMAND" in
fi
done
fi
fi
;;
restart)
[ $# -ne 1 ] && usage 2
if shorewall6_is_started; then
progress_message3 "Restarting $g_product...."
else
error_message "$g_product is not running"
progress_message3 "Starting $g_product...."
COMMAND=start
fi
;;
restart)
[ $# -ne 1 ] && usage 2
if shorewall6_is_started; then
progress_message3 "Restarting $g_product...."
else
error_message "$g_product is not running"
progress_message3 "Starting $g_product...."
fi
if checkkernelversion; then
detect_configuration
define_firewall
status=$?
if [ -n "$SUBSYSLOCK" ]; then
[ $status -eq 0 ] && touch $SUBSYSLOCK || rm -f $SUBSYSLOCK
fi
[ $status -eq 0 ] && progress_message3 "done."
fi
;;
refresh)
[ $# -ne 1 ] && usage 2
if shorewall6_is_started; then
progress_message3 "Refreshing $g_product...."
if checkkernelversion; then
progress_message3 "done."
;;
refresh)
[ $# -ne 1 ] && usage 2
if shorewall6_is_started; then
progress_message3 "Refreshing $g_product...."
detect_configuration
define_firewall
status=$?
[ $status -eq 0 ] && progress_message3 "done."
progress_message3 "done."
else
echo "$g_product is not running" >&2
status=2
fi
else
echo "$g_product is not running" >&2
status=2
fi
;;
restore)
[ $# -ne 1 ] && usage 2
if checkkernelversion; then
;;
restore)
[ $# -ne 1 ] && usage 2
detect_configuration
define_firewall
status=$?
if [ -n "$SUBSYSLOCK" ]; then
[ $status -eq 0 ] && touch $SUBSYSLOCK || rm -f $SUBSYSLOCK
fi
[ $status -eq 0 ] && progress_message3 "done."
fi
;;
clear)
[ $# -ne 1 ] && usage 2
progress_message3 "Clearing $g_product...."
if checkkernelversion; then
;;
clear)
[ $# -ne 1 ] && usage 2
progress_message3 "Clearing $g_product...."
clear_firewall
status=0
if [ -n "$SUBSYSLOCK" ]; then
rm -f $SUBSYSLOCK
fi
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
progress_message3 "done."
fi
;;
status)
[ $# -ne 1 ] && usage 2
echo "$g_product-$SHOREWALL_VERSION Status at $(hostname) - $(date)"
echo
if shorewall6_is_started; then
echo "$g_product is running"
status=0
else
echo "$g_product is stopped"
status=4
fi
;;
status)
[ $# -ne 1 ] && usage 2
echo "$g_product-$SHOREWALL_VERSION Status at $(hostname) - $(date)"
echo
if shorewall6_is_started; then
echo "$g_product is running"
status=0
else
echo "$g_product is stopped"
status=4
fi
if [ -f ${VARDIR}/state ]; then
state="$(cat ${VARDIR}/state)"
case $state in
Stopped*|Clear*)
status=3
;;
esac
else
state=Unknown
fi
echo "State:$state"
echo
;;
up|down)
[ $# -eq 1 ] && exit 0
shift
[ $# -ne 1 ] && usage 2
updown $1
status=0
;;
version)
[ $# -ne 1 ] && usage 2
echo $SHOREWALL_VERSION
status=0
;;
help)
[ $# -ne 1 ] && usage 2
usage 0
;;
*)
usage 2
;;
esac
if [ -f ${VARDIR}/state ]; then
state="$(cat ${VARDIR}/state)"
case $state in
Stopped*|Clear*)
status=3
;;
esac
else
state=Unknown
fi
echo "State:$state"
echo
;;
version)
[ $# -ne 1 ] && usage 2
echo $SHOREWALL_VERSION
status=0
;;
help)
[ $# -ne 1 ] && usage 2
usage 0
;;
*)
usage 2
;;
esac
fi
exit $status

View File

@@ -1,6 +1,8 @@
#!/bin/sh
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 1999-2011 - Tom Eastep (teastep@shorewall.net)
# (c) 1999-2010 - Tom Eastep (teastep@shorewall.net)
#
# Options are:
#
@@ -87,17 +89,35 @@ setpolicy() # $1 = name of chain, $2 = policy
}
#
# Generate a list of all network interfaces on the system
# Set a standard chain to enable established and related connections
#
find_all_interfaces() {
${IP:-ip} link list | egrep '^[[:digit:]]+:' | cut -d ' ' -f2 | sed -r 's/(@.*)?:$//'
setcontinue() # $1 = name of chain
{
run_iptables -A $1 -m state --state ESTABLISHED,RELATED -j ACCEPT
}
#
# Generate a list of all network interfaces on the system that have an ipv4 address
# Flush one of the NAT table chains
#
find_all_interfaces1() {
${IP:-ip} -4 addr list | egrep '^[[:digit:]]+:' | cut -d ' ' -f2 | sed -r 's/(@.*)?:$//'
flushnat() # $1 = name of chain
{
run_iptables -t nat -F $1
}
#
# Flush one of the Mangle table chains
#
flushmangle() # $1 = name of chain
{
run_iptables -t mangle -F $1
}
#
# Flush and delete all user-defined chains in the filter table
#
deleteallchains() {
run_iptables -F
run_iptables -X
}
#
@@ -111,17 +131,6 @@ find_device() {
done
}
#
# Find the value 'weight' in the passed arguments then echo the next value
#
find_weight() {
while [ $# -gt 1 ]; do
[ "x$1" = xweight ] && echo $2 && return
shift
done
}
#
# Find the value 'via' in the passed arguments then echo the next value
#
@@ -281,7 +290,7 @@ get_interface_bcasts() # $1 = interface
#
del_ip_addr() # $1 = address, $2 = interface
{
[ $(find_first_interface_address_if_any $2) = $1 ] || qtnoin $IP addr del $1 dev $2
[ $(find_first_interface_address_if_any $2) = $1 ] || qt $IP addr del $1 dev $2
}
# Add IP Aliases
@@ -492,8 +501,6 @@ get_device_mtu1() # $1 = device
# Undo changes to routing
#
undo_routing() {
local undofiles
local f
if [ -z "$g_noroutes" ]; then
#
@@ -506,72 +513,48 @@ undo_routing() {
#
# Restore the rest of the routing table
#
undofiles="$(ls ${VARDIR}/undo_*routing 2> /dev/null)"
if [ -n "$undofiles" ]; then
for f in $undofiles; do
. $f
done
rm -f $undofiles
progress_message "Shorewall-generated routing tables and routing rules removed"
if [ -f ${VARDIR}/undo_routing ]; then
. ${VARDIR}/undo_routing
progress_message "Shorewall-generated routing tables and routing rules removed"
rm -f ${VARDIR}/undo_routing
fi
fi
}
#
# Save the default route
#
save_default_route() {
awk \
'BEGIN {defroute=0;};
/^default / {deroute=1; print; next};
/nexthop/ {if (defroute == 1 ) {print ; next} };
{ defroute=0; };'
}
#
# Restore the default route that was in place before the initial 'shorewall start'
#
replace_default_route() # $1 = USE_DEFAULT_RT
{
#
# default_route and result are inherited from the caller
#
if [ -n "$default_route" ]; then
case "$default_route" in
*metric*)
#
# Don't restore a default route with a metric unless USE_DEFAULT_RT=Yes. Otherwise, we only replace the one with metric 0
#
[ -n "$1" ] && qt $IP -4 route replace $default_route && progress_message "Default Route (${default_route# }) restored"
default_route=
;;
*)
qt $IP -4 route replace $default_route && progress_message "Default Route (${default_route# }) restored"
result=0
default_route=
;;
esac
fi
}
restore_default_route() # $1 = USE_DEFAULT_RT
{
local result
result=1
restore_default_route() {
if [ -z "$g_noroutes" -a -f ${VARDIR}/default_route ]; then
local default_route
default_route=
local route
local result
result=1
while read route ; do
case $route in
default*)
replace_default_route $1
if [ -n "$default_route" ]; then
case "$default_route" in
*metric*)
#
# Don't restore a route with a metric -- we only replace the one with metric == 0
#
qt $IP -4 route delete default metric 0 && \
progress_message "Default Route with metric 0 deleted"
;;
*)
qt $IP -4 route replace $default_route && \
result=0 && \
progress_message "Default Route (${default_route# }) restored"
;;
esac
break
fi
default_route="$default_route $route"
;;
*)
@@ -580,80 +563,12 @@ restore_default_route() # $1 = USE_DEFAULT_RT
esac
done < ${VARDIR}/default_route
replace_default_route $1
if [ $result = 1 ]; then
#
# We didn't restore a default route with metric 0
#
if $IP -4 -o route list 2> /dev/null | fgrep default | fgrep -qv metric; then
#
# But we added a default route with metric 0
#
qt $IP -4 route del default metric 0 && progress_message "Default route with metric 0 deleted"
fi
fi
rm -f ${VARDIR}/default_route
fi
return $result
}
#
# Add an additional gateway to the default route
#
add_gateway() # $1 = Delta $2 = Table Number
{
local route
local weight
local delta
local dev
route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/default //; s/[\]//g'`
if [ -z "$route" ]; then
run_ip route add default scope global table $2 $1
else
delta=$1
if ! echo $route | fgrep -q ' nexthop '; then
route=`echo $route | sed 's/via/nexthop via/'`
dev=$(find_device $route)
if [ -f ${VARDIR}/${dev}_weight ]; then
weight=`cat ${VARDIR}/${dev}_weight`
route="$route weight $weight"
fi
fi
run_ip route replace default scope global table $2 $route $delta
fi
}
#
# Remove a gateway from the default route
#
delete_gateway() # $! = Description of the Gateway $2 = table number $3 = device
{
local route
local gateway
local dev
route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/[\]//g'`
gateway=$1
if [ -n "$route" ]; then
if echo $route | fgrep -q ' nexthop '; then
gateway="nexthop $gateway"
eval route=\`echo $route \| sed \'s/$gateway/ /\'\`
run_ip route replace table $2 $route
else
dev=$(find_device $route)
[ "$dev" = "$3" ] && run_ip route delete default table $2
fi
fi
}
#
# Determine the MAC address of the passed IP through the passed interface
#
@@ -695,14 +610,14 @@ conditionally_flush_conntrack() {
delete_proxyarp() {
if [ -f ${VARDIR}/proxyarp ]; then
while read address interface external haveroute; do
qtnoin $IP -4 neigh del proxy $address dev $external
[ -z "${haveroute}${g_noroutes}" ] && qtnoin $IP -4 route del $address/32 dev $interface
qt arp -i $external -d $address pub
[ -z "${haveroute}${g_noroutes}" ] && qt $IP -4 route del $address dev $interface
f=/proc/sys/net/ipv4/conf/$interface/proxy_arp
[ -f $f ] && echo 0 > $f
done < ${VARDIR}/proxyarp
rm -f ${VARDIR}/proxyarp
fi
rm -f ${VARDIR}/proxyarp
}
#
@@ -716,7 +631,6 @@ clear_firewall() {
setpolicy OUTPUT ACCEPT
run_iptables -F
qt $IPTABLES -t raw -F
echo 1 > /proc/sys/net/ipv4/ip_forward
@@ -742,7 +656,7 @@ fatal_error()
{
echo " ERROR: $@" >&2
if [ $LOG_VERBOSITY -ge 0 ]; then
if [ $LOG_VERBOSITY -gt 1 ]; then
timestamp="$(date +'%_b %d %T') "
echo "${timestamp} ERROR: $@" >> $STARTUP_LOG
fi
@@ -758,12 +672,6 @@ fatal_error()
startup_error() # $* = Error Message
{
echo " ERROR: $@: Firewall state not changed" >&2
if [ $LOG_VERBOSITY -ge 0 ]; then
timestamp="$(date +'%_b %d %T') "
echo "${timestamp} ERROR: $@" >> $STARTUP_LOG
fi
case $COMMAND in
start)
logger -p kern.err "ERROR:$g_product start failed:Firewall state not changed"
@@ -776,7 +684,7 @@ startup_error() # $* = Error Message
;;
esac
if [ $LOG_VERBOSITY -ge 0 ]; then
if [ $LOG_VERBOSITY -gt 1 ]; then
timestamp="$(date +'%_b %d %T') "
case $COMMAND in
@@ -853,6 +761,34 @@ run_tc() {
fi
}
#
# Restore the rules generated by 'drop','reject','logdrop', etc.
#
restore_dynamic_rules() {
if [ -f ${VARDIR}/save ]; then
progress_message2 "Setting up dynamic rules..."
rangematch='source IP range'
while read target ignore1 ignore2 address ignore3 rest; do
case $target in
DROP|reject|logdrop|logreject)
case $rest in
$rangematch*)
run_iptables -A dynamic -m iprange --src-range ${rest#source IP range} -j $target
;;
*)
if [ -z "$rest" ]; then
run_iptables -A dynamic -s $address -j $target
else
error_message "WARNING: Unable to restore dynamic rule \"$target $ignore1 $ignore2 $address $ignore3 $rest\""
fi
;;
esac
;;
esac
done < ${VARDIR}/save
fi
}
#
# Get a list of all configured broadcast addresses on the system
#
@@ -876,17 +812,13 @@ debug_restore_input() {
qt1 $IPTABLES -t mangle -P $chain ACCEPT
done
qt1 $IPTABLES -t raw -F
qt1 $IPTABLES -t raw -X
qt1 $IPTABLES -t rawpost -F
qt1 $IPTABLES -t rawpost -X
qt1 $IPTABLES -t raw -F
qt1 $IPTABLES -t raw -X
for chain in PREROUTING OUTPUT; do
qt1 $IPTABLES -t raw -P $chain ACCEPT
done
qt1 $iptables -T rawpost -P POSTROUTING ACCEPT
run_iptables -t nat -F
run_iptables -t nat -X
@@ -936,9 +868,6 @@ debug_restore_input() {
'*'raw)
table=raw
;;
'*'rawpost)
table=rawpost
;;
'*'mangle)
table=mangle
;;

View File

@@ -1,6 +1,8 @@
#!/bin/sh
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 1999-2011- Tom Eastep (teastep@shorewall.net)
# (c) 1999-2010- Tom Eastep (teastep@shorewall.net)
#
# Options are:
#
@@ -87,17 +89,27 @@ setpolicy() # $1 = name of chain, $2 = policy
}
#
# Generate a list of all network interfaces on the system
# Set a standard chain to enable established and related connections
#
find_all_interfaces() {
${IP:-ip} link list | egrep '^[[:digit:]]+:' | cut -d ' ' -f2 | sed -r 's/(@.*)?:$//'
setcontinue() # $1 = name of chain
{
run_iptables -A $1 -m state --state ESTABLISHED,RELATED -j ACCEPT
}
#
# Generate a list of all network interfaces on the system that have an ipv6 address
# Flush one of the Mangle table chains
#
find_all_interfaces1() {
${IP:-ip} -6 addr list | egrep '^[[:digit:]]+:' | cut -d ' ' -f2 | sed -r 's/(@.*)?:$//'
flushmangle() # $1 = name of chain
{
run_iptables -t mangle -F $1
}
#
# Flush and delete all user-defined chains in the filter table
#
deleteallchains() {
run_iptables -F
run_iptables -X
}
#
@@ -166,7 +178,7 @@ find_default_interface() {
# Determine if Interface is up
#
interface_is_up() {
[ -n "$($IP -6 link list dev $1 2> /dev/null | grep -e '[<,]UP[,>]')" ]
[ -n "$($IP link list dev $1 2> /dev/null | grep -e '[<,]UP[,>]')" ]
}
#
@@ -484,63 +496,45 @@ undo_routing() {
if [ -f ${VARDIR}/undo_routing ]; then
. ${VARDIR}/undo_routing
progress_message "Shorewall-generated routing tables and routing rules removed"
rm -f ${VARDIR}/undo_*routing
rm -f ${VARDIR}/undo_routing
fi
fi
}
#
# Save the default route
#
save_default_route() {
awk \
'BEGIN {defroute=0;};
/^default / {defroute=1; print; next};
/nexthop/ {if (defroute == 1 ) {print ; next} };
{ defroute=0; };'
}
#
# Restore the default route that was in place before the initial 'shorewall start'
#
replace_default_route() # $1 = USE_DEFAULT_RT
{
#
# default_route and result are inherited from the caller
#
if [ -n "$default_route" ]; then
case "$default_route" in
*metric*)
#
# Don't restore a default route with a metric unless USE_DEFAULT_RT=Yes. Otherwise, we only replace the one with metric 0
#
[ -n "$1" ] && qt $IP -6 route replace $default_route && progress_message "Default Route (${default_route# }) restored"
default_route=
;;
*)
qt $IP -6 route replace $default_route && progress_message "Default Route (${default_route# }) restored"
result=0
default_route=
;;
esac
fi
}
restore_default_route() # $1 = USE_DEFAULT_RT
{
local result
result=1
restore_default_route() {
if [ -z "$g_noroutes" -a -f ${VARDIR}/default_route ]; then
local default_route
default_route=
local route
local result
result=1
while read route ; do
case $route in
default*)
replace_default_route $1
default)
if [ -n "$default_route" ]; then
case "$default_route" in
*metric*)
#
# Don't restore a route with a metric -- we only replace the one with metric == 0
#
qt $IP -6 route delete default metric 0 && \
progress_message "Default Route with metric 0 deleted"
;;
*)
qt $IP -6 route replace $default_route && \
result=0 && \
progress_message "Default Route (${default_route# }) restored"
;;
esac
break
fi
default_route="$default_route $route"
;;
*)
@@ -549,20 +543,6 @@ restore_default_route() # $1 = USE_DEFAULT_RT
esac
done < ${VARDIR}/default_route
replace_default_route $1
if [ $result = 1 ]; then
#
# We didn't restore a default route with metric 0
#
if $IP -6 -o route list 2> /dev/null | fgrep default | fgrep -qv metric; then
#
# But we added a default route with metric 0
#
qt $IP -6 route del default metric 0 && progress_message "Default route with metric 0 deleted"
fi
fi
rm -f ${VARDIR}/default_route
fi
@@ -602,22 +582,6 @@ conditionally_flush_conntrack() {
fi
}
#
# Clear Proxy NDP
#
delete_proxyndp() {
if [ -f ${VARDIR}/proxyndp ]; then
while read address interface external haveroute; do
qt $IP -6 neigh del proxy $address dev $external
[ -z "${haveroute}${g_noroutes}" ] && qt $IP -6 route del $address/128 dev $interface
f=/proc/sys/net/ipv6/conf/$interface/proxy_ndp
[ -f $f ] && echo 0 > $f
done < ${VARDIR}/proxyndp
rm -f ${VARDIR}/proxyndp
fi
}
#
# Remove all Shorewall-added rules
#
@@ -629,7 +593,6 @@ clear_firewall() {
setpolicy OUTPUT ACCEPT
run_iptables -F
qt $IP6TABLES -t raw -F
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
@@ -663,12 +626,6 @@ fatal_error()
startup_error() # $* = Error Message
{
echo " ERROR: $@: Firewall state not changed" >&2
if [ $LOG_VERBOSITY -ge 0 ]; then
timestamp="$(date +'%_b %d %T') "
echo "${timestamp} ERROR: $@" >> $STARTUP_LOG
fi
case $COMMAND in
start)
logger -p kern.err "ERROR:$g_product start failed:Firewall state not changed"
@@ -758,6 +715,34 @@ run_tc() {
fi
}
#
# Restore the rules generated by 'drop','reject','logdrop', etc.
#
restore_dynamic_rules() {
if [ -f ${VARDIR}/save ]; then
progress_message2 "Setting up dynamic rules..."
rangematch='source IP range'
while read target ignore1 ignore2 address ignore3 rest; do
case $target in
DROP|reject|logdrop|logreject)
case $rest in
$rangematch*)
run_iptables -A dynamic -m iprange --src-range ${rest#source IP range} -j $target
;;
*)
if [ -z "$rest" ]; then
run_iptables -A dynamic -s $address -j $target
else
error_message "WARNING: Unable to restore dynamic rule \"$target $ignore1 $ignore2 $address $ignore3 $rest\""
fi
;;
esac
;;
esac
done < ${VARDIR}/save
fi
}
#
# Run the .iptables_restore_input as a set of discrete iptables commands
#
@@ -822,9 +807,6 @@ debug_restore_input() {
'*'raw)
table=raw
;;
'*'rawpost)
table=rawpost
;;
'*'mangle)
table=mangle
;;

View File

@@ -1,56 +0,0 @@
#
# Shorewall version 4 - Drop Action
#
# /usr/share/shorewall/action.A_Drop
#
# The audited default DROP common rules
#
# This action is invoked before a DROP policy is enforced. The purpose
# of the action is:
#
# a) Avoid logging lots of useless cruft.
# b) Ensure that 'auth' requests are rejected, even if the policy is
# DROP. Otherwise, you may experience problems establishing
# connections with servers that use auth.
# c) Ensure that certain ICMP packets that are necessary for successful
# internet operation are always ACCEPTed.
#
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
#
###############################################################################
#TARGET SOURCE DEST PROTO DPORT SPORT
#
# Count packets that come through here
#
COUNT
#
# Reject 'auth'
#
Auth(A_REJECT)
#
# Don't log broadcasts
#
dropBcast(audit)
#
# ACCEPT critical ICMP types
#
A_AllowICMPs - - icmp
#
# Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log.
#
dropInvalid(audit)
#
# Drop Microsoft noise so that it doesn't clutter up the log.
#
SMB(A_DROP)
A_DropUPnP
#
# Drop 'newnotsyn' traffic so that it doesn't get logged.
#
dropNotSyn(audit) - - tcp
#
# Drop late-arriving DNS replies. These are just a nuisance and clutter up
# the log.
#
A_DropDNSrep

View File

@@ -1,54 +0,0 @@
#
# Shorewall version 4 - Reject Action
#
# /usr/share/shorewall/action.A_Reject
#
# The audited default REJECT action common rules
#
# This action is invoked before a REJECT policy is enforced. The purpose
# of the action is:
#
# a) Avoid logging lots of useless cruft.
# b) Ensure that certain ICMP packets that are necessary for successful
# internet operation are always ACCEPTed.
#
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
###############################################################################
#TARGET SOURCE DEST PROTO
#
# Count packets that come through here
#
COUNT
#
# Don't log 'auth' -- REJECT
#
Auth(A_REJECT)
#
# Drop Broadcasts so they don't clutter up the log
# (broadcasts must *not* be rejected).
#
dropBcast(audit)
#
# ACCEPT critical ICMP types
#
A_AllowICMPs - - icmp
#
# Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log (these ICMPs cannot be
# rejected).
#
dropInvalid(audit)
#
# Reject Microsoft noise so that it doesn't clutter up the log.
#
SMB(A_REJECT)
A_DropUPnP
#
# Drop 'newnotsyn' traffic so that it doesn't get logged.
#
dropNotSyn(audit) - - tcp
#
# Drop late-arriving DNS replies. These are just a nuisance and clutter up
# the log.
#
A_DropDNSrep

View File

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

View File

@@ -15,49 +15,9 @@
# c) Ensure that certain ICMP packets that are necessary for successful
# internet operation are always ACCEPTed.
#
# The action accepts five optional parameters:
#
# 1 - 'audit' or '-'. Default is '-' which means don't audit in builtin
# actions.
# 2 - Action to take with Auth requests. Default is REJECT or A_REJECT,
# depending on the setting of the first parameter.
# 3 - Action to take with SMB requests. Default is DROP or A_DROP,
# depending on the setting of the first parameter.
# 4 - Action to take with required ICMP packets. Default is ACCEPT or
# A_ACCEPT depending on the first parameter.
# 5 - Action to take with late UDP replies (UDP source port 53). Default
# is DROP or A_DROP depending on the first parameter.
#
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
#
###############################################################################
FORMAT 2
#
# The following magic provides different defaults for $2 thru $5, when $1 is
# 'audit'.
#
BEGIN PERL;
use Shorewall::Config;
my ( $p1, $p2, $p3 , $p4, $p5 ) = get_action_params( 5 );
if ( defined $p1 ) {
if ( $p1 eq 'audit' ) {
set_action_param( 2, 'A_REJECT') unless supplied $p2;
set_action_param( 3, 'A_DROP') unless supplied $p3;
set_action_param( 4, 'A_ACCEPT' ) unless supplied $p4;
set_action_param( 5, 'A_DROP' ) unless supplied $p5;
} else {
fatal_error "Invalid value ($p1) for first Drop parameter" if supplied $p1;
}
}
1;
END PERL;
DEFAULTS -,REJECT,DROP,ACCEPT,DROP
#TARGET SOURCE DEST PROTO DPORT SPORT
#
# Count packets that come through here
@@ -66,31 +26,31 @@ COUNT
#
# Reject 'auth'
#
Auth($2)
Auth(REJECT)
#
# Don't log broadcasts
#
Broadcast(DROP,$1)
dropBcast
#
# ACCEPT critical ICMP types
#
AllowICMPs($4) - - icmp
AllowICMPs - - icmp
#
# Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log.
#
Invalid(DROP,$1)
dropInvalid
#
# Drop Microsoft noise so that it doesn't clutter up the log.
#
SMB($3)
DropUPnP($5)
SMB(DROP)
DropUPnP
#
# Drop 'newnotsyn' traffic so that it doesn't get logged.
#
NotSyn(DROP,$1) - - tcp
dropNotSyn - - tcp
#
# Drop late-arriving DNS replies. These are just a nuisance and clutter up
# the log.
#
DropDNSrep($5)
DropDNSrep

View File

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

View File

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

View File

@@ -12,48 +12,8 @@
# b) Ensure that certain ICMP packets that are necessary for successful
# internet operation are always ACCEPTed.
#
# The action accepts five optional parameters:
#
# 1 - 'audit' or '-'. Default is '-' which means don't audit in builtin
# actions.
# 2 - Action to take with Auth requests. Default is REJECT or A_REJECT,
# depending on the setting of the first parameter.
# 3 - Action to take with SMB requests. Default is REJECT or A_REJECT,
# depending on the setting of the first parameter.
# 4 - Action to take with required ICMP packets. Default is ACCEPT or
# A_ACCEPT depending on the first parameter.
# 5 - Action to take with late UDP replies (UDP source port 53). Default
# is DROP or A_DROP depending on the first parameter.
#
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
###############################################################################
FORMAT 2
#
# The following magic provides different defaults for $2 thru $5, when $1 is
# 'audit'.
#
BEGIN PERL;
use Shorewall::Config;
my ( $p1, $p2, $p3 , $p4, $p5 ) = get_action_params( 5 );
if ( defined $p1 ) {
if ( $p1 eq 'audit' ) {
set_action_param( 2, 'A_REJECT') unless supplied $p2;
set_action_param( 3, 'A_REJECT') unless supplied $p3;
set_action_param( 4, 'A_ACCEPT' ) unless supplied $p4;
set_action_param( 5, 'A_DROP' ) unless supplied $p5;
} else {
fatal_error "Invalid value ($p1) for first Reject parameter" if supplied $p1;
}
}
1;
END PERL;
DEFAULTS -,REJECT,REJECT,ACCEPT,DROP
#TARGET SOURCE DEST PROTO
#
# Count packets that come through here
@@ -62,33 +22,33 @@ COUNT
#
# Don't log 'auth' -- REJECT
#
Auth($2)
Auth(REJECT)
#
# Drop Broadcasts so they don't clutter up the log
# (broadcasts must *not* be rejected).
#
Broadcast(DROP,$1)
dropBcast
#
# ACCEPT critical ICMP types
#
AllowICMPs($4) - - icmp
AllowICMPs - - icmp
#
# Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log (these ICMPs cannot be
# rejected).
#
Invalid(DROP,$1)
dropInvalid
#
# Reject Microsoft noise so that it doesn't clutter up the log.
#
SMB($3)
DropUPnP($5)
SMB(REJECT)
DropUPnP
#
# Drop 'newnotsyn' traffic so that it doesn't get logged.
#
NotSyn(DROP,$1) - - tcp
dropNotSyn - - tcp
#
# Drop late-arriving DNS replies. These are just a nuisance and clutter up
# the log.
#
DropDNSrep($5)
DropDNSrep

View File

@@ -16,11 +16,184 @@
# Please see http://shorewall.net/Actions.html for additional
# information.
#
# Columns are the same as in /etc/shorewall/rules.
# Columns are:
#
#######################################################################################################
# DO NOT REMOVE THE FOLLOWING LINE
FORMAT 2
####################################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS
# PORT PORT(S) DEST LIMIT GROUP
#
# TARGET ACCEPT, DROP, REJECT, LOG, QUEUE, CONTINUE, a <macro>
# or a previously-defined <action>
#
# ACCEPT -- allow the connection request
# DROP -- ignore the request
# REJECT -- disallow the request and return an
# icmp-unreachable or an RST packet.
# LOG -- Simply log the packet and continue.
# QUEUE -- Queue the packet to a user-space
# application such as p2pwall.
# CONTINUE -- Stop processing this action and
# return to the point where the
# action was invoked.
# <action> -- An <action> defined in
# /etc/shorewall/actions.
# The <action> must appear in that
# file BEFORE the one being defined
# in this file.
# <macro> -- The name of a macro defined in a
# file named macro.<macro-name>. If
# the macro accepts an action
# parameter (Look at the macro
# source to see if it has PARAM in
# the TARGET column) then the macro
# name is followed by "/" and the
# action (ACCEPT, DROP, REJECT, ...)
# to be substituted for the
# parameter. Example: FTP/ACCEPT.
#
# The TARGET may optionally be followed
# by ":" and a syslog log level (e.g, REJECT:info or
# ACCEPT:debugging). This causes the packet to be
# logged at the specified level.
#
# The special log level 'none' does not result in logging
# but rather exempts the rule from being overridden by a
# non-forcing log level when the action is invoked.
#
# You may also specify ULOG (must be in upper case) as a
# log level.This will log to the ULOG target for routing
# to a separate log through use of ulogd
# (http://www.gnumonks.org/projects/ulogd).
#
# Actions specifying logging may be followed by a
# log tag (a string of alphanumeric characters)
# are appended to the string generated by the
# LOGPREFIX (in /etc/shorewall/shorewall.conf).
#
# Example: ACCEPT:info:ftp would include 'ftp '
# at the end of the log prefix generated by the
# LOGPREFIX setting.
#
# SOURCE Source hosts to which the rule applies.
# A comma-separated list of subnets
# and/or hosts. Hosts may be specified by IP or MAC
# address; mac addresses must begin with "~" and must use
# "-" as a separator.
#
# 192.168.2.2 Host 192.168.2.2
#
# 155.186.235.0/24 Subnet 155.186.235.0/24
#
# 10.0.0.4-10.0.0.9 Range of IP addresses; your
# kernel and iptables must have
# iprange match support.
#
# +remote The name of an ipset prefaced
# by "+". Your kernel and
# iptables must have set match
# support
#
# +remote[4] The name of the ipset may
# followed by a number of
# levels of ipset bindings
# enclosed in square brackets.
#
# 192.168.1.1,192.168.1.2
# Hosts 192.168.1.1 and
# 192.168.1.2.
# ~00-A0-C9-15-39-78 Host with
# MAC address 00:A0:C9:15:39:78.
#
# Alternatively, clients may be specified by interface
# name. For example, eth1 specifies a
# client that communicates with the firewall system
# through eth1. This may be optionally followed by
# another colon (":") and an IP/MAC/subnet address
# as described above (e.g., eth1:192.168.1.5).
#
# DEST Location of destination host. Same as above with
# the exception that MAC addresses are not allowed and
# that you cannot specify an ipset name in both the
# SOURCE and DEST columns.
#
# PROTO Protocol - Must be "tcp", "tcp:syn", "udp", "icmp",
# "ipp2p", "ipp2p:udp", "ipp2p:all", a number, or "all".
# "ipp2p*" requires ipp2p match support in your kernel
# and iptables.
#
# "tcp:syn" implies "tcp" plus the SYN flag must be
# set and the RST, ACK and FIN flags must be reset.
#
# DEST PORT(S) Destination Ports. A comma-separated list of Port
# names (from /etc/services), port numbers or port
# ranges; if the protocol is "icmp", this column is
# interpreted as the destination icmp-type(s).
#
# A port range is expressed as <low port>:<high port>.
#
# This column is ignored if PROTOCOL = all but must be
# entered if any of the following fields are supplied.
# In that case, it is suggested that this field contain
# "-"
#
# If your kernel contains multi-port match support, then
# only a single Netfilter rule will be generated if in
# this list and the CLIENT PORT(S) list below:
# 1. There are 15 or less ports listed.
# 2. No port ranges are included.
# Otherwise, a separate rule will be generated for each
# port.
#
# SOURCE PORT(S) (Optional) Port(s) used by the client. If omitted,
# any source port is acceptable. Specified as a comma-
# separated list of port names, port numbers or port
# ranges.
#
# If you don't want to restrict client ports but need to
# specify an ADDRESS in the next column, then place "-"
# in this column.
#
# If your kernel contains multi-port match support, then
# only a single Netfilter rule will be generated if in
# this list and the DEST PORT(S) list above:
# 1. There are 15 or less ports listed.
# 2. No port ranges are included.
# Otherwise, a separate rule will be generated for each
# port.
#
# RATE LIMIT You may rate-limit the rule by placing a value in
# this column:
#
# <rate>/<interval>[:<burst>]
#
# where <rate> is the number of connections per
# <interval> ("sec" or "min") and <burst> is the
# largest burst permitted. If no <burst> is given,
# a value of 5 is assumed. There may be no
# no whitespace embedded in the specification.
#
# Example: 10/sec:20
#
# USER/GROUP This column may only be non-empty if the SOURCE is
# the firewall itself.
#
# The column may contain:
#
# [!][<user name or number>][:<group name or number>][+<program name>]
#
# When this column is non-empty, the rule applies only
# if the program generating the output is running under
# the effective <user> and/or <group> specified (or is
# NOT running under that id if "!" is given).
#
# Examples:
#
# joe #program must be run by joe
# :kids #program must be run by a member of
# #the 'kids' group
# !:kids #program must not be run by a member
# #of the 'kids' group
# +upnpd #program named upnpd (This feature was
# #removed from Netfilter in kernel
# #version 2.6.14).
#
###############################################################################
#TARGET SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/
# PORT PORT(S) DEST LIMIT GROUP

View File

@@ -8,9 +8,6 @@
#
# Builtin Actions are:
#
# A_ACCEPT # Audits then accepts a connection request
# A_DROP # Audits then drops a connection request
# A_REJECT # Audits then drops a connection request
# allowBcast # Silently Allow Broadcast/multicast
# dropBcast # Silently Drop Broadcast/multicast
# dropNotSyn # Silently Drop Non-syn TCP packets
@@ -33,10 +30,5 @@
#
###############################################################################
#ACTION
A_Drop # Audited Default Action for DROP policy
A_Reject # Audited Default action for REJECT policy
Broadcast # Handles Broadcast/Multicast/Anycast
Drop # Default Action for DROP policy
Invalid # Handles packets in the INVALID conntrack state
NotSyn # Handles TCP packets which do not have SYN=1 and ACK=0
Reject # Default Action for REJECT policy

515
Shorewall/changelog.txt Normal file
View File

@@ -0,0 +1,515 @@
Changes in Shorewall 4.4.9
1) Auto-detection of bridges.
2) Correct handling of a logical interface name in the EXTERNAL column
of proxyarp.
3) More robust 'trace'.
4) Added IPv6 mDNS macro.
5) Fix find_first_interface_address() error reporting.
6) Fix propagation of zero-valued config variables.
7) Fix OPTIMIZE 4 bug.
8) Deallocate unused rules.
9) Keep rule arrays compressed during optimization.
10) Remove remaining fallback scripts.
11) Rationalize startup logs.
12) Optimize 8.
13) Don't create output chains for BPORT zones.
14) Implement 'show log ip-addr' in /sbin/shorewall and
/sbin/shorewall-lite/
15) Restore lone ACCEPT rule to the OUTPUT chain under OPTIMIZE 2.
16) Change chain policy on OUTPUT chain with lone ACCEPT rule.
17) Set IP before sourcing the params file.
18) Fix rare optimization bug.
19) Allow definition of an addressless bridge without a zone.
20) In the routestopped file, assume 'routeback' if the interface has
'routeback'.
21) Make Shorewall and Shorewall6 installable on OS X.
Changes in Shorewall 4.4.8
1) Correct handling of RATE LIMIT on NAT rules.
2) Don't create a logging chain for rules with '-j RETURN'.
3) Avoid duplicate SFQ class numbers.
4) Fix low per-IP rate limits.
5) Fix Debian init script exit status
6) Fix NFQUEUE(queue-num) in policy
7) Implement -s option in install.sh
8) Add HKP Macro
9) Fix multiple policy matches with OPTIMIZE 4 and not KLUDGEFREE
10) Eliminate up-cased variable names that aren't documented options.
11) Don't show 'OLD' capabilities if they are not available.
12) Attempt to flag use of '-' as a port-range separator.
13) Add undocumented OPTIMIZE=-1 setting.
14) Replace OPTIMIZE=-1 with undocumented optimize 4096 which DISABLES
default optimizations.
15) Add support for UDPLITE
16) Distinguish between 'Started' and 'Restored' in ${VARDIR}/state
17) Issue warnings when 'blacklist' but no blacklist file entries.
18) Don't optimize 'blacklst'.
Changes in Shorewall 4.4.7
1) Backport optimization changes from 4.5.
2) Backport two new options from 4.5.
3) Backport TPROXY from 4.5
4) Add TC_PRIOMAP to shorewall*.conf
5) Implement LOAD_HELPERS_ONLY
6) Avoid excessive module loading with LOAD_HELPERS_ONLY=Yes
7) Fix case where MARK target is unavailable.
8) Change default to ADD_IP_ALIASES=No
9) Correct defects in generate_matrix().
10) Fix and optimize 'nosmurfs'.
11) Use 'OLD_HL_MATCH' to suppress use of 'flow' in Simple TC.
Changes in Shorewall 4.4.6
1) Fix for rp_filter and kernel 2.6.31.
2) Add a hack to work around a bug in Lenny + xtables-addons
3) Re-enable SAVE_IPSETS
4) Allow both <...> and [...] for IPv6 Addresses.
5) Port mark geometry change from 4.5.
6) Add Macro patch from Tuomo Soini
7) Add 'show macro' command.
8) Add -r option to check.
9) Port simplified TC from 4.5.
Changes in Shorewall 4.4.5
1) Fix 15-port limit removal change.
2) Fix handling of interfaces with the 'bridge' option.
3) Generate error for port number 0
4) Allow zone::serverport in rules DEST column.
5) Fix 'show policies' in Shorewall6.
6) Auto-load tc modules.
7) Allow LOGFILE=/dev/null
8) Fix shorewall6-lite/shorecap
9) Fix MODULE_SUFFIX.
10) Fix ENHANCED_REJECT detection for IPv4.
11) Fix DONT_LOAD vs 'reload -c'
12) Fix handling of SOURCE and DEST vs macros.
13) Remove silly logic in expand_rule().
14) Add current and limit to Conntrack Table Heading.
Changes in Shorewall 4.4.4
1) Change STARTUP_LOG and LOG_VERBOSITY in default shorewall6.conf.
2) Fix access to uninitialized variable.
3) Add logrotate scripts.
4) Allow long port lists in /etc/shorewall/routestopped.
5) Implement 'physical' interface option.
6) Implement ZONE2ZONE option.
7) Suppress duplicate COMMENT warnings.
8) Implement 'show policies' command.
9) Fix route_rule suppression for down provider.
10) Suppress redundant tests for provider availability in route rules
processing.
11) Implement the '-l' option to the 'show' command.
12) Fix class number assignment when WIDE_TC_MARKS=Yes
13) Allow wide marks in tcclasses when WIDE_TC_MARKS=Yes
Changes in Shorewall 4.4.3
1) Move Debian INITLOG initialization to /etc/default/shorewall
2) Fix 'routeback' in /etc/shorewall/routestopped.
3) Rename 'object' to 'script' in compiler and config modules.
4) Correct RETAIN_ALIASES=No.
5) Fix detection of IP config.
6) Fix nested zones.
7) Move all function declarations from prog.footer to prog.header
8) Remove superfluous variables from generated script
9) Make 'track' the default.
10) Add TRACK_PROVIDERS option.
11) Fix IPv6 address parsing bug.
12) Add hack to work around iproute IPv6 bug in route handling
13) Correct messages issued when an optional provider is not usable.
14) Fix optional interfaces.
15) Add 'limit' option to tcclasses.
Changes in Shorewall 4.4.2
1) BUGFIX: Correct detection of Persistent SNAT support
2) BUGFIX: Fix chain table initialization
3) BUGFIX: Validate routestopped file on 'check'
4) Let the Actions module add the builtin actions to
%Shorewall::Chains::targets. Much better modularization that way.
5) Some changes to make Lenny->Squeeze less painful.
6) Allow comments at the end of continued lines.
7) Call process_routestopped() during 'check' rather than
'compile_stop_firewall()'.
8) Don't look for an extension script for built-in actions.
9) Apply Jesse Shrieve's patch for SNAT range.
10) Add -<family> to 'ip route del default' command.
11) Add three new columns to macro body.
12) Change 'wait4ifup' so that it requires no PATH
13) Allow extension scripts for accounting chains.
14) Allow per-ip LIMIT to work on ancient iptables releases.
15) Add 'MARK' column to action body.
Changes in Shorewall 4.4.1
1) Deleted extra 'use ...IPAddrs.pm' from Nat.pm.
2) Deleted superfluous export from Chains.pm.
3) Added support for --persistent.
4) Don't do module initialization in an INIT block.
5) Minor performance improvements.
6) Add 'clean' target to Makefile.
7) Redefine 'full' for sub-classes.
8) Fix log level in rules at the end of INPUT and OUTPUT chains.
9) Fix nested ipsec zones.
10) Change one-interface sample to IP_FORWARDING=Off.
11) Allow multicast to non-dynamic zones defined with nets=.
12) Allow zones with nets= to be extended by /etc/shorewall/hosts
entries.
13) Don't allow nets= in a multi-zone interface definition.
14) Fix rule generated by MULTICAST=Yes
15) Fix silly hole in zones file parsing.
16) Tighen up zone membership checking.
17) Combine portlist-spitting routines into a single function.
Changes in Shorewall 4.4.0
1) Fix 'compile ... -' so that it no longer requires '-v-1'
2) Fix rule generation for logging nat rules with no exclusion.
3) Fix log record formatting.
4) Restore ipset binding
5) Fix 'upnpclient' with required interfaces.
6) Fix provider number in masq file.
Changes in Shorewall 4.4.0-RC2
1) Fix capabilities file with Shorewall6.
2) Allow Shorewall6 to recognize TC, IP and IPSET
3) Make 'any' a reserved zone name.
4) Correct handling of an ipsec zone nested in a non-ipsec zone.
Changes in Shorewall 4.4.0-RC1
1) Delete duplicate Git macro.
2) Fix routing when no providers.
3) Add 'any' as a SOURCE/DEST in rules.
4) Fix NONAT on child zone.
5) Fix rpm -U from earlier versions
6) Generate error on 'status' by non-root.
7) Get rid of prog.functions and prog.functions6
Changes in Shorewall 4.4.0-Beta4
1) Add more macros.
2) Correct broadcast address detection
3) Fix 'show dynamic'
4) Fix BGP and OSFP macros.
5) Change DISABLE_IPV6 default and use 'correct' ip6tables.
Changes in Shorewall 4.4.0-Beta3
1) Add new macros.
2) Work around mis-configured interfaces.
3) Fix 'show dynamic'.
4) Check for xt_LOG.
5) Fix 'findgw'
Changes in Shorewall 4.4.0-Beta2
1) The 'find_first_interface_address()' and
'find_first_interface_address_if_any()' functions have been restored to
lib.base.
2) Integerize r2q before inserting it into 'tc qdisc add root'
command.
3) Remove '-h' from the help text for install.sh in Shorewall and
Shorewall6.
4) Delete the 'continue' file from the Shorewall package.
5) Add 'upnpclient' interface option.
6) Fix handling of optional interfaces.
7) Add 'iptrace' and 'noiptrace' command.
8) Add 'USER/GROUP' column to masq file.
9) Added lib.private.
Changes in Shorewall 4.4.0-Beta1
1) Correct typo in Shorewall6 two-interface sample shorewall.conf.
2) Fix TOS mnemonic handling in /etc/shorewall/tcfilters.
Changes in Shorewall 4.3.12
1) Eliminate 'large quantum' warnings.
2) Add HFSC support.
3) Delete support for ipset binding. Jozsef has removed the capability
from ipset.
4) Add TOS and LENGTH columns to tcfilters file.
5) Fix 'reset' command.
6) Fix 'findgw'.
7) Remove 'norfc1918' support.
Changes in Shorewall 4.3.11
1) Reduce the number of arguments passed in may cases.
2) Fix SCTP source port handling in tcfilters.
3) Add 'findgw' user exit.
4) Add macro.Trcrt
Changes in Shorewall 4.3.10
1) Fix handling of shared optional providers.
2) Add WIDE_TC_MARKS option.
3) Allow compile to STDOUT.
4) Fix handling of class IDs.
5) Deprecate use of an interface in the SOURCE column of
/etc/shorewall/masq.
6) Fix handling of 'all' in the SOURCE of DNAT- rules.
7) Fix compile for export.
8) Optimize IPMARK.
9) Implement nested HTB classes.
10) Fix 'iprange' command.
11) Make traffic shaping work better with IPv6.
12) Externalize 'flow'.
13) Fix 'start' with AUTOMAKE=Yes
Changes in Shorewall 4.3.9
1) Logging rules now create separate chain.
2) Fix netmask genereation in tcfilters.
3) Allow Shorewall6 with kernel 2.6.24
4) Avoid 'Invalid BROADCAST address' errors.
5) Allow Shorewall6 on kernel 4.2.24:Shorewall/changelog.txt
6) Add IP, TC and IPSET options in shorewall.conf and shorewall6.conf.
7) Add IPMARK support
Changes in Shorewall 4.3.8
1) Apply Tuomo Soini's patch for USE_DEFAULT_RT.
2) Use 'startup_error' for those errors caught early.
3) Fix swping
4) Detect gateway via dhclient leases file.
5) Suppress leading whitespace on certain continuation lines.
6) Use iptables[6]-restore to stop the firewall.
7) Add AUTOMAKE option
8) Remove SAME support.
9) Allow 'compile' without a pathname.
10) Fix LOG_MARTIANS=Yes.
11) Adapt I. Buijs's hashlimit patch.
Changes in Shorewall 4.3.7
1) Fix forward treatment of interface options.
2) Replace $VARDIR/.restore with $VARDIR/firewall
3) Fix DNAT- parsing of DEST column.
4) Implement dynamic zones
5) Allow 'HOST' options on bridge ports.
6) Deprecate old macro parameter syntax.
Changes in Shorewall 4.3.6
1) Add SAME tcrules target.
2) Make 'dump' display the raw table. Fix shorewall6 dump anomalies.
3) Fix split_list1()
4) Fix Shorewall6 file location bugs.
Changes in Shorewall 4.3.5
1) Remove support for shorewall-shell.
2) Combine shorewall-common and shorewall-perl to produce shorewall.
3) Add nets= OPTION in interfaces file.

View File

@@ -6,6 +6,6 @@
# Please see http://shorewall.net/Accounting.html for examples and
# additional information about how to use this file.
#
#################################################################################################################
#ACTION CHAIN SOURCE DESTINATION PROTO DEST SOURCE USER/ MARK IPSEC
#####################################################################################
#ACTION CHAIN SOURCE DESTINATION PROTO DEST SOURCE USER/ MARK
# PORT(S) PORT(S) GROUP

View File

@@ -7,5 +7,4 @@
# information.
#
###############################################################################
#ADDRESS/SUBNET PROTOCOL PORT OPTIONS
#ADDRESS/SUBNET PROTOCOL PORT

View File

@@ -3,11 +3,11 @@
#
# /etc/shorewall/findgw
#
# The code in this file is executed when Shorewall is trying to detect the
# The code in this file is executed when Shorewall is trying to detect the
# gateway through an interface in /etc/shorewall/providers that has GATEWAY
# specified as 'detect'.
#
# The function should echo the IP address of the gateway if it knows what
# The function should echo the IP address of the gateway if it knows what
# it is; the name of the interface is in $1.
#
# See http://shorewall.net/shorewall_extension_scripts.htm for additional

View File

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

View File

@@ -7,4 +7,4 @@
# information.
#
###############################################################################
#TYPE NET1 INTERFACE NET2 NET3
#TYPE NET1 INTERFACE NET2

View File

@@ -4,7 +4,7 @@
# /etc/shorewall/restored
#
# Add commands below that you want to be executed after shorewall has
# completed a 'restore' command.
# completed a 'restore' command.
#
# See http://shorewall.net/shorewall_extension_scripts.htm for additional
# information.

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