From owner-freebsd-questions@freebsd.org Wed Nov 15 22:13:43 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2F043DE8D87 for ; Wed, 15 Nov 2017 22:13:43 +0000 (UTC) (envelope-from rosettas@gmail.com) Received: from mail-wr0-x236.google.com (mail-wr0-x236.google.com [IPv6:2a00:1450:400c:c0c::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AF0A07E29E; Wed, 15 Nov 2017 22:13:42 +0000 (UTC) (envelope-from rosettas@gmail.com) Received: by mail-wr0-x236.google.com with SMTP id 15so21698521wrb.5; Wed, 15 Nov 2017 14:13:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=pmyjU6+W/Jg0ps5LsEvwAANg4XLScp637fRA35dpsbc=; b=UH5bjG5e7b8FheHJZev63Ni+fOOi+ipdukUAqPYJe5OFiC9o7oYojqPcM30C7LAVB/ AwtNORpvptDyuH8b9ruba4RxibXbdIYx7IayaOmQv1zrN7V85aVeRAabZSVIK7uMfkKJ STWe/HBoPcYwrMY7H8BVFcGE/dE9gJOL2NboZi9anBLGpX5tGNMAbMQsUiumysPw2avP uPRdflZPd5et4jcoSYxrGXz1VdUSy+ukxoLlIgZOrFXsa7KcLs4y36FXCpThrlZxWsiB XAcrezKzvbnjgO9QH3NgOg2bZ+/r2ViyVbb45NCVuBCneWGzqE2GgL6KPf/oSzeh47Mu cmuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=pmyjU6+W/Jg0ps5LsEvwAANg4XLScp637fRA35dpsbc=; b=AYuscqAtAtDDrAqIY5XoY4F+eP2toi4KPrOc8E2a/3N2kgCAnEKrS73ymLpiIEKxKR Kt3CBSxpCzB3URvonegd3wTehQzE7n+QCa9BxzP2/XDYp7I+gLQ/yiOEzVvxpHKieraX ou+/KX0tAABsr2Bdg3xzLzpYb2bu4RfcfRwQwk9k3HxID38Md2mhbPtHpAT4qn85swrq tA56HfEOxVo+V4VitdiFDlVfu7uk4V+28Hrd3GwLbzNfY8BFH8oUZHlJrnWkeda/LLkk Wuq3TwO/3zlJCKA86Xi59kmnhVvL6PbLoWSWRvU8UW/nxzQ+bB3oqpIMCQUflXIDFb6U dUPg== X-Gm-Message-State: AJaThX5N2O7Q+v5QNVIk5ripwYfLsv+S9Gytq5BlFsUoF4ocmIyftEMM KEyIudJo5SXUoOW6qiFeMp9OBn/TLNk5EtVW0wWkZK9W X-Google-Smtp-Source: AGs4zMa4NnmXB2XQKQHFDbV/mUlUed9BZAWcIu2VNsaNVcjYCVaghw4NmE+ZApNTaie1ckir0aTj2M8cJjDDuL2NiWE= X-Received: by 10.223.132.129 with SMTP id 1mr13373577wrg.136.1510784020637; Wed, 15 Nov 2017 14:13:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.125.8 with HTTP; Wed, 15 Nov 2017 14:13:39 -0800 (PST) In-Reply-To: <7961d19a-bc0c-6dc4-771e-f702ce741144@FreeBSD.org> References: <20171106235944.U9710@sola.nimnet.asn.au> <20171107033226.M9710@sola.nimnet.asn.au> <20171107162914.G9710@sola.nimnet.asn.au> <20171108012948.A9710@sola.nimnet.asn.au> <20171111213759.I72828@sola.nimnet.asn.au> <7961d19a-bc0c-6dc4-771e-f702ce741144@FreeBSD.org> From: Cos Chan Date: Wed, 15 Nov 2017 23:13:39 +0100 Message-ID: Subject: Re: How to setup IPFW working with blacklistd To: Kurt Lidl Cc: Ian Smith , freebsd-questions , Michael Ross Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Nov 2017 22:13:43 -0000 On Mon, Nov 13, 2017 at 6:37 PM, Kurt Lidl wrote: > Greetings all! > > Sorry for not being response to your request for help sooner. > > I had a bit of a hardware crisis here last week, where > what I thought was merely a blown power supply turned > out to be a failed motherboard. Getting the 2.5" SAS > drives back up and running in a different machine took > far longer than I would have guessed. That, along with > a secondary MX host that was offline for the first 36 > hours after the main mail server went down was a cause > for additional excitement. > > Anyway. > > I've read through the mail exchange, although its a bit > hard to follow all of it. > > I'll offer a couple of observations about blacklistd > and how it operates, and maybe that will shed some light > on the problem at hand. If not, well, I'd like to start > fresh with the current configuration, and what you're > seeing on your host. > Sorry I didn't get this email before, thanks Ian forward me this mail. > > Observations that might help: > > 1) The blacklistd support in 11.0 was broken in a couple > of significant ways. The blacklistd support in 11.1 is > thought to be fully functional. If you're not running 11.1, > you will need to update to 11.1. > The FreeBSD is: 11.1-RELEASE-p1 FreeBSD 11.1-RELEASE-p1 #0: Wed Aug 9 11:17:49 UTC 2017 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC i386 > > 2) I only use blacklistd with 'pf' in my day-to-day usage. > I extended the support in blacklistd-helper to hopefully > handle both ipfw and ipf, and it seemed to work OK for my > test setup. HOWEVER, it is entirely possible that the way > I did the ipf/ipfw support has a flaw (or more) in it. > > 3) The changes to the various daemons to support the > blacklist just enable sending messages (and a copy of the > fd of socket) to the blacklist daemon. The blacklist daemon > will extract information from the kernel about the socket's > other end (ie, the information about the remote system), > and stores that information in a database. > > 4) After the information is stored in the database, the > blacklist daemon calls the blacklistd-helper script and > that script is responsible for modifying the firewall > rules that are in effect. If the script has a bug, it's > entirely possible that the information in the database > will be out of sync with the current firewall rules in > effect. > > 5) If you're experiencing a situation where the number > of login attempts is greater than the cutoff for the > service (e.g., the "1662/1" noted in the email thread), > that means that whatever firewall rule that is supposed > to be blocking the service isn't blocking the traffic. > (See next item for a case where the right rules are in > the filter, but you still get a "modest" overage of > attempts vs the cutoff.) > > 6) On a slow-ish single-CPU host (like the sparc64 that I use > as my gateway), it's possible to get more attempts than > the cutoff for a persist, high-speed attacker. > > Basically, it takes so long before the system context switches > to the blacklist daemon, and the entry gets added to the pf table. > Where "so long" is still less than a second, but the machine has > already seen 10 or 12 attempts! > > For example, here's a partial list of what my gateway is reporting > right now: > > root@gatekeeper-130: blacklistctl dump -a > address/ma:port id nfail last access > [...] > 61.126.187.219/32:22 OK 3/3 2017/11/12 17:31:40 > 156.212.51.78/32:22 OK 23/3 2017/11/12 19:09:38 > 179.53.156.109/32:22 OK 3/3 2017/11/12 19:58:57 > 220.174.236.220/32:22 2/3 2017/11/12 23:39:58 > 198.245.63.120/32:22 OK 3/3 2017/11/13 10:36:15 > > You can see a couple of "normally blocked" attempts (3/3), > a single IP address that has 2 of 3 attempts, and a very, > very persistent/fast host that got in 23 attempts before > it got blocked. > I understand. but you may see my problem is the number increased after blocked. > > 7) There was a note about different usernames from the same > remote host. The blacklist support currently does not > differentiate between usernames. It is just counting the > number of attempts from a remote IP address. > > There's unfinished support for having a "known bad" set of usernames, > where a single login attempt for that username will block > the remote address. This will allow (when finished), easy > blocking of the twenty or so most common usernames that are > probed. That is great. My problem is one connection one fail from sshd was not registered into blacklistd as one fail. > Hopefully this will help. > > -Kurt > > >> -- with kind regards