Commit Graph

117 Commits

Author SHA1 Message Date
Michael Tremer
249839b0ca firewall: Fix source/destination interface settings
When a forwarding rule is being created, we sometimes create
INPUT/OUTPUT rules, too. Those were slightly invalid because
the source and destination interfaces where passed, too.

This could render some rules in certain circumstances useless.

This patch fixes this and only adds -i for INPUT and -o for
OUTPUT rules.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-04-30 10:56:05 +01:00
Michael Tremer
ae93dd3deb firewall: Add more rules to input/output when adding rules to forward
The special_input/output_targets array assumed that firewall access
will always be denied. However, rules also need to be created when
access is granted. Therefore the ACCEPT target needs to be included
in this list and rules must be created in INPUTFW/OUTGOINGFW too
when ACCEPT rules are created in FORWARDFW.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-04-30 10:45:34 +01:00
Michael Tremer
7ba652af8c firewall: Write correct rules bound to interface for routes IPsec tunnels
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-02-04 18:20:36 +00:00
Michael Tremer
6826364580 ipsec-*: Name some more configuration variables
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-02-04 18:20:36 +00:00
Michael Tremer
c32fc72e36 ipsec-policy: Correct open ports for connections on aliases
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-02-04 18:20:36 +00:00
Michael Tremer
5a9c9ff312 ipsec-policy: Don't install any block rules for connections with an interface
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-02-04 18:20:36 +00:00
Michael Tremer
b54cd874b9 ipsec-policy: Permit GRE traffic for GRE connections
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-02-04 18:20:36 +00:00
Michael Tremer
2704dbbc28 ipsec-policy: Variables don't match those from the CGI
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-02-04 18:20:36 +00:00
Michael Tremer
4cf4f8f623 ipsec-policy: Parse all configuration settings
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-02-04 18:20:36 +00:00
Michael Tremer
6cf8bc9161 IPsec: Move opening ports from ipsecctrl into ipsec-policy script
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-02-04 18:20:36 +00:00
Michael Tremer
6c920b19cd IPsec: Rename ipsec-block script to ipsec-policy
This is a more general name for a script that will be extended
soon to do more than just add blocking rules.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-02-04 18:20:36 +00:00
Michael Tremer
5cf83d56fa firewall-lib.pl: Fix incorrect path to geoip-functions.pl
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-13 11:53:41 +01:00
Stefan Schantl
8ff42d82c4 firewall-lib.pl: Use get_geoip_locations from geoip-functions.pl
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-10 22:43:00 +00:00
Michael Tremer
9f60aa9679 syslog: Listen to network and block access from anywhere but localhost
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-11-07 20:07:53 +00:00
Michael Tremer
475ae4b3db firewall: Suppress more warnings when initialising without GREEN
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-07-01 11:49:57 +01:00
Alexander Marx
8b20ca2de4 BUG11559: firewall-lib
When creating firewallrules or using firewall groups,
it should be possible to select a single IpSec subnet if there is more than one.

This patch has neccessary changes for the firewall-lib. While the network name of the IpSec changes
on save (subnet is added to name) we need to split the name or normalise the field before using it.
Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
Tested-by: Peter Müller <peter.mueller@link38.eu>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-05-09 14:48:42 +01:00
Michael Tremer
1f91201011 firewall: Suppress warning about uninitialized array in GeoIP code
Fixes #11597

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-01-22 13:20:04 +00:00
Michael Tremer
cda384a280 ipsec: Do not reject connections in on-demand mode
When an on-demand VPN connection is not up, the packets will
traverse the firewall and be rejected by the IPSECBLOCK chain
which will cause that an ICMP error message will be sent to
the client. If that does not happen and the packet is being
silently dropped, the client will retransmit and by then
the VPN connection will hopefully be up.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2017-03-24 13:24:42 +01:00
Michael Tremer
645378fbb9 firewall: Fix MAC filter
Packets destined for the firewall coming in from the blue
device where accepted too early to be processed by the
firewall input chain rules.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2016-02-05 10:24:03 +00:00
Alexander Marx
306098a498 BUG10994: SNAT rules are missing the outgoing interface
When creating SNAT rules, the outgoing interface is not set. As a side
effect, traffic that should be send unnatted to a vpn tunnel can be
natted which is a BUG.
With this patch the SNAT rules are getting a outgoing interface
according to the configuration. When selecting the RED Target network,
all SNAT rules will be configured with "-o red0". Otherwise if "all" is
selected, there is no interface in the rule, which matches all networks.

Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2015-12-15 13:53:03 +00:00
Alexander Marx
0cf6bacad2 BUG10984: Fix portforwardconverter for upgrades before core 77
When upgrading from a post core-77 installation, the portforwarding
rules seem to get broken. With this patch the sourceports and the
subnetmasks from the rules are converted correctly.

Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2015-11-19 12:53:38 +00:00
Michael Tremer
80fbd89949 ipsec: Add block rules to avoid conntrack entries
If an IPsec VPN connections is not established, there are
rare cases when packets are supposed to be sent through
that said tunnel and incorrectly handled.

Those packets are sent to the default gateway an entry
for this connection is created in the connection tracking
table (usually only happens to UDP). All following packets
are sent the same route even after the tunnel has been
brought up. That leads to SIP phones not being able to
register among other things.

This patch adds firewall rules that these packets are
rejected. That will sent a notification to the client
that the tunnel is not up and avoid the connection to
be added to the connection tracking table.

Apart from a small performance penalty there should
be no other side-effects.

Fixes: #10908

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Cc: tomvend@rymes.com
Cc: daniel.weismueller@ipfire.org
Cc: morlix@morlix.de
Reviewed-by: Timo Eissler <timo.eissler@ipfire.org>
2015-10-15 22:44:47 +01:00
Michael Tremer
7c8e022c4b firewall: Support multiple subnets per IPsec tunnel
Fixes #10929

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2015-09-22 00:26:37 +01:00
Michael Tremer
7af1cf3949 firewall: Disable the P2P blocker by default
P2P networks have come a bit out of fashion. Disabling
the P2P blocker by default will save us some CPU cycles
for each packet that goes through the firewall.

The P2P blocker has also caused lots of false-positives
and has therefore become a bit more of a problem than
a solution.
2015-05-20 13:37:35 +02:00
Arne Fitzenreiter
0505af9dc0 rules.pl: fix geoip initialisation. 2015-04-20 23:14:11 +02:00
Stefan Schantl
0bb4b135d1 rules.pl: Flush GEOIPBLOCK chain when the feature will be switched off.
Otherwise existing rules still remain in the chain and will be processed
even geoipblock has been disabled.
2015-03-15 11:40:46 +01:00
Stefan Schantl
93bfe63d55 Merge branch 'seventeen-geoip' into next-geoip 2015-03-15 11:38:45 +01:00
Alexander Marx
2d0c7a9f7b BUG10620: move reload of firewall.local to main() 2015-03-11 17:11:59 +01:00
Alexander Marx
b9ca2fa60f Add support for generating GeoIP-based firewall rules.
This commit adds support to the rules.pl and firewall-lib.pl to generate
correct iptables commands for inserting GeoIP-based firewall rules
into the kernel.
2015-02-17 18:00:52 +01:00
Stefan Schantl
bc9446c65f Merge branch 'master' of ssh://git.ipfire.org/pub/git/ipfire-2.x into seventeen-geoip
Conflicts:
	make.sh
2015-02-14 12:34:31 +01:00
Michael Tremer
1b34f6cd64 firewall: Fix SNAT rules that use a default network as source
In the POSTROUTING chain using -i intf0 does not work at all.
We now only use the -s parameter to figure out if the rule applied.
The filter chain still uses -i and -o to match patches not only
by the network address, but also by the incoming/outgoing interface.
2015-01-22 16:06:25 +01:00
Stefan Schantl
192a8266e2 geoip-block.cgi: Requires firewall-lib.pl. 2015-01-04 14:07:06 +01:00
Stefan Schantl
211694e588 firewall: Add support for geoipblock to rules.pl. 2015-01-04 01:05:45 +01:00
Stefan Schantl
593c32275a Move "sub get_geoip_locations" to firewall-lib. 2015-01-04 01:03:21 +01:00
Stefan Schantl
484e01fc37 Add default config file for geoipblock. 2015-01-04 00:56:00 +01:00
Michael Tremer
d840d02aee firewall: Fix off-by-one error in configuration parser
The configuration parser determines how many comma-separated
values there are in a line. If new values are added we need
to check first if those are set in every line to avoid any
undefined behaviour. A wrong comparison parameter was used
which caused that the limit feature was never enabled in
the rule generation.
2015-01-02 12:27:16 +01:00
Arne Fitzenreiter
52dae2ba3f Merge branch 'next' 2014-10-10 18:13:13 +02:00
Michael Tremer
a21f2f6a76 firewall: Use correct interface for RED 2014-10-07 14:54:12 +02:00
Arne Fitzenreiter
24d36c80a6 p2pblock: fix flush rules if all p2p's are allowed. 2014-10-05 15:12:44 +02:00
Arne Fitzenreiter
2a5b19c56f p2pblock: ipp2p must run before CONNTRACK.
And can only used for blocking, not for accept conenections bacause connections must already established for detecting protocol types.
2014-10-04 17:39:51 +02:00
Michael Tremer
791c2b45d8 firewall: fix rules.pl for old rules without ratelimiting. 2014-10-04 13:52:15 +02:00
Michael Tremer
7e09a94a81 Merge remote-tracking branch 'amarx/BUG10620' into next 2014-09-26 13:03:22 +02:00
Michael Tremer
60bce6ba6a Merge remote-tracking branch 'amarx/BUG10615' into next 2014-09-26 13:02:28 +02:00
Michael Tremer
df6649b0fe Merge remote-tracking branch 'amarx/firewall-dnat' into next
Conflicts:
	config/firewall/rules.pl
2014-09-26 12:55:55 +02:00
Alexander Marx
ca4259a758 BUG10620: reload firewall.local in rules.pl, no longer in initscript 2014-09-11 17:13:07 +02:00
Alexander Marx
d2793ea805 BUG10615 part3: adapt rules.pl to use connectionlimit and ratelimit 2014-09-11 15:06:26 +02:00
Michael Tremer
4e9a2b5732 general-functions.pl: Replace lots of broken network code.
The state of some code especially in general-functions.pl
is in such a bad shape and faulty.
This is a first step that replaces some of the network
functions with those who have been tested and work for
undefined inputs.

The old functions have been left in place as stubs
and must be removed at some time.
2014-07-27 22:46:20 +02:00
Alexander Marx
48f07c1957 Firewall: make DNAT only accessible from selected source network
We added RED to the standard networks and now portforwardings are only
useable from the selected source. If selected "all" the portforwarding
can be used from any internal network. Else the access is only grnated
from the selected source network.
2014-07-18 08:44:45 +02:00
Michael Tremer
c0e0848f99 firewall: Allow blocking access to GREEN from GREEN. 2014-05-20 11:41:23 +02:00
Alexander Marx
a43c9b6a64 Firewall: outgoingconverter fix for ipfire-src 2014-04-28 14:27:54 +02:00