From owner-freebsd-questions@freebsd.org Mon Feb 17 15:55:09 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 D6A2D23CEC0 for ; Mon, 17 Feb 2020 15:55:09 +0000 (UTC) (envelope-from hamdi20193d@gmail.com) Received: from mail-ua1-x931.google.com (mail-ua1-x931.google.com [IPv6:2607:f8b0:4864:20::931]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48LpTm0vvrz43C8 for ; Mon, 17 Feb 2020 15:55:07 +0000 (UTC) (envelope-from hamdi20193d@gmail.com) Received: by mail-ua1-x931.google.com with SMTP id o42so6292102uad.10 for ; Mon, 17 Feb 2020 07:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=+Pwn0xfGhAlDZJyHpkELV9+n+55yh1kHj4iY/Iey/uE=; b=h/eYIhYLcYU9E0zV2UjHCsN0ydi9cLxJDNq6kO8gGBV+02zd4Fbuq8ljNqUJmc0rDP fK+0FuBIvvuaaYGerC/ShAWlNRda/EzmhHM44/6FatmJwGNsJ/UKyEcT/NsW6+V4noWf yetWlUdQv4w/l62Q+z7gkXkoWutTBZLTjSMDqcOqAmp6jkp76aP888P9PSx/8nNHcHZY dD5Hjurr32qQRR6D5SxqxVcb4gYizoaY3fw4ql6Qa3xJplAg/hErQLjllT8V+2g90sfW noyLR2avlN1KkkTZcrk6iOGLOCeYJQNwTuKQwWJD7FyDluxeexxaTxbiMJZzI5ThP3OW R85A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=+Pwn0xfGhAlDZJyHpkELV9+n+55yh1kHj4iY/Iey/uE=; b=X8pDmHz6Ups5HN6qxSee95RDRVisZGemjQwDK2iKH6pEhIyKVDlLODtaQlYM9tYqdz 2znqImoyVM20rHftv9qhxG1JLYZ1MsjsTUDJs+7VCLQHwyXkpNKKC8pzQ7r5LmhZZDAX 3R6QMjjPd3uGUUIhH9ohiK5ReqiuldmZsGHbS9qJUDKAHZv2fCKStgrdUeYZXSjFzgqc caOK58FeBjQRMMXAooJRsSqXZfz5yY5SVEvYqKz7vxQFRPCq22sIGvDp5ki3jdCxpi6V z8q5TldeKH9w21ElpcZ9sykrsSGHD0CC02ROT0pe0QSWln7OApelpiCGNwuA7YaMa9JF rPFw== X-Gm-Message-State: APjAAAVWciRzETD/CTFP7E8tbhvCjZsgK8vlS+dYGcdJSgZ/d5IUdJzl EeQhQn+tasSXuAPPPXTIcHew6yr8DB6RJn3CBlrbY9ZM X-Google-Smtp-Source: APXvYqzkVswiPkzoyV9vCPapN6QL68FUvOF97N1TFqpZeZZjMIT7pYmCVv3kdkDizUgRIUReH466RWSlllQRqx6dH3U= X-Received: by 2002:ab0:3415:: with SMTP id z21mr8346413uap.9.1581954906896; Mon, 17 Feb 2020 07:55:06 -0800 (PST) MIME-Version: 1.0 References: <9585fce4-b48d-a210-d62f-a2100c0cf929@tundraware.com> In-Reply-To: <9585fce4-b48d-a210-d62f-a2100c0cf929@tundraware.com> From: Andreas X Date: Mon, 17 Feb 2020 18:54:55 +0300 Message-ID: Subject: Re: Blacklist IP file for IPFW? To: Tim Daneliuk , FreeBSD Mailing List X-Rspamd-Queue-Id: 48LpTm0vvrz43C8 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=h/eYIhYL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of hamdi20193d@gmail.com designates 2607:f8b0:4864:20::931 as permitted sender) smtp.mailfrom=hamdi20193d@gmail.com X-Spamd-Result: default: False [0.00 / 15.00]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; URI_COUNT_ODD(1.00)[9]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; FROM_EQ_ENVFROM(0.00)[]; IP_SCORE(0.00)[ip: (-8.73), ipnet: 2607:f8b0::/32(-1.89), asn: 15169(-1.68), country: US(-0.05)]; SUBJECT_ENDS_QUESTION(1.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; IP_SCORE_FREEMAIL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[1.3.9.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; HTTP_TO_IP(1.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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 15:55:09 -0000 Dear Tim, I applied your suggestion, however it seems IPFW doesn't ban the IP addresses in the list. (I've added a useless VPS IP of mine in the list, to test it, but I could still ping the server from that IP) Here's my script as per your suggestion: #!/bin/sh FWCMD=3D"ipfw -q" LISTX=3D/usr/local/etc/fw/banlist.txt ipfw table 10 create ipfw table 10 flush for addr in `cat ${LISTX}` do ${FWCMD} table 10 add ${addr} done ${FWCMD} add deny all from table\(10\) to any And ipfw show | grep "table" command outputs: "65500 0 0 deny ip from table(10) to any" so it seems the IPs are added. But none of them are blocked. I restarted IPFW too, and re-run the script again, no solution. Any idea? Thank you. Tim Daneliuk , 17 =C5=9Eub 2020 Pzt, 17:51 tarihinde= =C5=9Funu yazd=C4=B1: > 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=3D"ipfw -q" # Firewall command > OIF=3Dem0 # NIC to outside world > > # Address spaces we want blocked entirely are listed in this file > NAUGHTYFILE=3D/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/ > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to " > freebsd-questions-unsubscribe@freebsd.org" >