From patchwork Fri Feb 18 05:03:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 5179 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) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4K0KNg1L18z3wtR for ; Fri, 18 Feb 2022 05:04:03 +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 4K0KNd0HH9z1dX; Fri, 18 Feb 2022 05:04:01 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4K0KNc5z00z2yNY; Fri, 18 Feb 2022 05:04:00 +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) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4K0KNb4nHLz2xhV for ; Fri, 18 Feb 2022 05:03:59 +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 4K0KNZ74NZzNw; Fri, 18 Feb 2022 05:03:58 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1645160639; 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; bh=PFe6975tV8m76/aXQomr0szAZE4sciKDDbC8vBUoti0=; b=fboJFwnq9Xw4l7VdQiMzFNM6zWwgI2Nm2zybiChKuO1HuNX10ulUR5u2SZ8nEwOuTvrHBH EmHvvaAufK8aRBCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1645160639; 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; bh=PFe6975tV8m76/aXQomr0szAZE4sciKDDbC8vBUoti0=; b=vFX945zSDgqYA7x4p0iDIN1kLTXiSKafqc8ivFNy0BMKzcsufvs8qUsbXJ5fHtKLJdpNk/ toOdJy1FOj65XSKYygKosaKZvLFNE5CU+OaM0YJmI/Wxx5NC0p07dkz4wsfuEBx3Jf4b6f 5izcEOOYli7QgpkQ0s076OJzRABp4LTR/Yfst6XMW87Ut33sJbkLpvrYIccYBj3ymlbfhD 5eGhwXbJl0bcHihqyCyONgQCJ3l7UiWrOeyX2zT9KqqEPVGrdol6OSJQdWMPA9HU0T6T+M gFDwlNIX8qjo/lqqk8XSZkG9WbWeKYTXM99GrCasjfYhZZPbPxb+vcuxJztbjg== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH] firewall: Load ipset list before creating rules for DROP_HOSTILE. Date: Fri, 18 Feb 2022 06:03:51 +0100 Message-Id: <20220218050351.9708-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" Otherwise there is no ipset list use-able and the feature will not work. Signed-off-by: Stefan Schantl Reviewed-by: Michael Tremer --- src/initscripts/system/firewall | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/initscripts/system/firewall b/src/initscripts/system/firewall index adb2240bb..2ae6157aa 100644 --- a/src/initscripts/system/firewall +++ b/src/initscripts/system/firewall @@ -22,6 +22,8 @@ IPS_REPEAT_MASK="0x80000000" IPS_BYPASS_MARK="0x40000000" IPS_BYPASS_MASK="0x40000000" +IPSET_DB_DIR="/var/lib/location/ipset" + function iptables() { /sbin/iptables --wait "$@" } @@ -146,6 +148,9 @@ iptables_init() { # a technical threat to our users (i. e. listed at Spamhaus DROP et al.) iptables -N HOSTILE if [ "$DROPHOSTILE" == "on" ]; then + # Call ipset and load the list which contains the hostile networks. + ipset restore < $IPSET_DB_DIR/CC_XD.ipset4 + iptables -A HOSTILE -m limit --limit 10/second -j LOG --log-prefix "DROP_HOSTILE " iptables -A INPUT -i $IFACE -m set --match-set CC_XD src -j HOSTILE iptables -A FORWARD -i $IFACE -m set --match-set CC_XD src -j HOSTILE