rules.pl: apply location filter to ppp0 if configured

Message ID 06d3845b-348d-ca6b-d1cf-a12157e85bae@ipfire.org
State Accepted
Commit 2293e1de0bef48e607ff4701bad07863d9ed57ee
Headers
Series rules.pl: apply location filter to ppp0 if configured |

Commit Message

Peter Müller 3 Nov 2020, 10:48 a.m. UTC
  In order to prevent collateral damage to internal traffic, commit
c69c820025c21713cdb77eae3dd4fa61ca71b5fb introduced applying location
block on red0 as a sanity check.

On systems configured to use PPPoE, however, traffic appears on the ppp0
interface instead. This patch checks if a system is configured to use
this connection method, and applies the location filter to this
interface. red0 is used otherwise.

Fixes: #12519

Cc: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
---
 config/firewall/rules.pl | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
  

Patch

diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl
index c2641a92d..bc6187052 100644
--- a/config/firewall/rules.pl
+++ b/config/firewall/rules.pl
@@ -2,7 +2,7 @@ 
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2019  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2020  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # 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        #
@@ -628,8 +628,11 @@  sub locationblock {
 		return;
 	}
 
-	# Only check the RED interface
-	if ($defaultNetworks{'RED_DEV'} ne "") {
+	# Only check the RED interface, which is ppp0 in case of RED_TYPE being
+	# set to "PPPOE", and red0 in case of RED_TYPE not being empty otherwise.
+	if ($defaultNetworks{'RED_TYPE'} eq "PPPOE") {
+		run("$IPTABLES -A LOCATIONBLOCK ! -i ppp0 -j RETURN");
+	} elsif ($defaultNetworks{'RED_DEV'} ne "") {
 		run("$IPTABLES -A LOCATIONBLOCK ! -i $defaultNetworks{'RED_DEV'} -j RETURN");
 	}