From patchwork Mon Feb 14 18:42:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 5155 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4JyClz4HBlz3wsl for ; Mon, 14 Feb 2022 18:43:27 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4JyClq0Gn9z5NR; Mon, 14 Feb 2022 18:43:19 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4JyClp2GCwz30H8; Mon, 14 Feb 2022 18:43:18 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4JyClm2VfXz2xVx for ; Mon, 14 Feb 2022 18:43:16 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4JyClm0GRNz3gG; Mon, 14 Feb 2022 18:43:15 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1644864196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZmBkYfzKw546PBXaYxBW3ZipP41lRWUXJ2Ow9DX20/o=; b=O/LNlHucp3AK9Z4LHyWaqvbwz+BZzYx0grq3L0XpcZ4db+T/poAvAJNiHhpYt9Y2NHReLp kgKfFZMqN4Wc1jCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1644864196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZmBkYfzKw546PBXaYxBW3ZipP41lRWUXJ2Ow9DX20/o=; b=p9yBqaZmToNLJWdIc7BfNDVOPoUOonjZG3DSjJ7vrlZ/3pZQZaYWTwyxrkI58Hy8oQq0lG sbT88Iq+s0xFWAAH6ONYuPmFB5lzlJ1YNjodKD8P66nB6EzRu1k+pRl9HeXaobi6Awq6s2 p4offGWLCemhb9WhwlIw71oVLTjpwYfIZbx9bBkXkfrfVkpl0cQUF4K0RrD0NKS2U/H16h glM8EwSJt+Cq0nouGu+oIJVDeAfjaLq7aUT3aQLxlsPylXChhyWzda0Zsh7maaf8RnXcO5 8L1f/yA0jA08MBwVajX/6GsyRFWrqBSLTBkAPTfSqBPidE2tsFTAe2CDjPBOWA== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 06/12] rules.pl: Move to ipset based data for LOCATIONBLOCK feature. Date: Mon, 14 Feb 2022 19:42:50 +0100 Message-Id: <20220214184257.2406-6-stefan.schantl@ipfire.org> In-Reply-To: <20220214184257.2406-1-stefan.schantl@ipfire.org> References: <20220214184257.2406-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Stefan Schantl Reviewed-by: Peter Müller Reviewed-by: Michael Tremer --- config/firewall/rules.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl index 5b1153b08..e009c1838 100644 --- a/config/firewall/rules.pl +++ b/config/firewall/rules.pl @@ -671,7 +671,11 @@ sub locationblock { # is enabled. foreach my $location (@locations) { if(exists $locationsettings{$location} && $locationsettings{$location} eq "on") { - run("$IPTABLES -A LOCATIONBLOCK -m geoip --src-cc $location -j DROP"); + # Call function to load the networks list for this country. + &ipset_restore($location); + + # Call iptables and create rule to use the loaded ipset list. + run("$IPTABLES -A LOCATIONBLOCK -m set --match-set CC_$location src -j DROP"); } } }