From owner-freebsd-questions@freebsd.org Mon Feb 17 14:51:13 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 32E3D23B211 for ; Mon, 17 Feb 2020 14:51:13 +0000 (UTC) (envelope-from tundra@tundraware.com) Received: from oceanview.tundraware.com (oceanview.tundraware.com [45.55.60.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mailman.tundraware.com", Issuer "mailman.tundraware.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 48Ln3z3tYvz3xD0 for ; Mon, 17 Feb 2020 14:51:11 +0000 (UTC) (envelope-from tundra@tundraware.com) Received: from chimpchange.tundraware.com (75-146-98-62-Illinnois.hfc.comcastbusiness.net [75.146.98.62]) (authenticated bits=0) by oceanview.tundraware.com (8.15.2/8.15.2) with ESMTPSA id 01HEnkf0086831 (version=TLSv1.2 cipher=AES128-SHA bits=128 verify=NO) for ; Mon, 17 Feb 2020 08:49:47 -0600 (CST) (envelope-from tundra@tundraware.com) Subject: Re: Blacklist IP file for IPFW? To: FreeBSD Mailing List References: From: Tim Daneliuk Openpgp: preference=signencrypt Message-ID: <9585fce4-b48d-a210-d62f-a2100c0cf929@tundraware.com> Date: Mon, 17 Feb 2020 08:49:41 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (oceanview.tundraware.com [45.55.60.57]); Mon, 17 Feb 2020 08:49:47 -0600 (CST) X-TundraWare-MailScanner-Information: Please contact the ISP for more information X-TundraWare-MailScanner-ID: 01HEnkf0086831 X-TundraWare-MailScanner: Found to be clean X-TundraWare-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (not cached, timed out) X-TundraWare-MailScanner-From: tundra@tundraware.com X-Spam-Status: No X-Rspamd-Queue-Id: 48Ln3z3tYvz3xD0 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of tundra@tundraware.com designates 45.55.60.57 as permitted sender) smtp.mailfrom=tundra@tundraware.com X-Spamd-Result: default: False [0.71 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+a]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; NEURAL_SPAM_MEDIUM(0.34)[0.335,0]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-0.96)[-0.957,0]; DMARC_NA(0.00)[tundraware.com]; TO_DN_ALL(0.00)[]; IP_SCORE(0.63)[ip: (-2.08), ipnet: 45.55.32.0/19(3.84), asn: 14061(1.47), country: US(-0.05)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:14061, ipnet:45.55.32.0/19, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Feb 2020 14:51:13 -0000 On 2/17/20 8:36 AM, Andreas X wrote: > The list dramatically grows each week. How may I create a text file so that > IPFW would fetch these IPs from there directly? What's the simplest way to > do this please? Looping through a file and running an ipfw command each time gets super slow as the list gets long. ipfw tables are the better way to do this: FWCMD="ipfw -q" # Firewall command OIF=em0 # NIC to outside world # Address spaces we want blocked entirely are listed in this file NAUGHTYFILE=/usr/local/etc/firewall/naughtyIPs # Use ipfw tables for efficiency ipfw table 10 flush for addr in `cat ${NAUGHTYFILE}` do ${FWCMD} table 10 add ${addr} done ${FWCMD} add deny all from table\(10\) to any via ${OIF} The "naughty" file can have specific IPs or CIDR blocks in it, one per line: 95.87.0.0/18 95.87.192.0/18 96.246.220.34 96.30.64.0/18 98.143.148.107 HTH, ---------------------------------------------------------------------------- Tim Daneliuk tundra@tundraware.com PGP Key: http://www.tundraware.com/PGP/