From owner-freebsd-questions@freebsd.org Fri Mar 31 00:02:06 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 59ECCD220AC for ; Fri, 31 Mar 2017 00:02:06 +0000 (UTC) (envelope-from dave.mehler@gmail.com) Received: from mail-wr0-x229.google.com (mail-wr0-x229.google.com [IPv6:2a00:1450:400c:c0c::229]) (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 E53469 for ; Fri, 31 Mar 2017 00:02:05 +0000 (UTC) (envelope-from dave.mehler@gmail.com) Received: by mail-wr0-x229.google.com with SMTP id w11so81531617wrc.3 for ; Thu, 30 Mar 2017 17:02:05 -0700 (PDT) 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=dtGQBBYNlvHjb7LLco9scDxyfG/HQg5sr2htKlfwsAI=; b=Ki5UJPb08xKHkqnVpyybsKcKzyElltlPeg0FTvu58MTi1DqZC0MhUtwylFinBLLB57 Rn8zpVYlKlU0lQDqzZI/e9kHBnWKPDM2XYraWAdvK2BZ0P4V464IWb2uVsfYl5cuICd4 uKNr1Nz77wCzuckwlTvHU9E2fDkfrGqaz9JQSUGrH604Zs6UTEKlCo2C2PjNv61Jq96e CCDzXHYq5Zeey7VNkfIRCsL69XdhR9lhUgfK7D5Y6VOOxzxLkXpUDbRUcn/mYCXMiv2X SgYVeDI43fpGmKmw/rZrbONcYQLNTIpJb2VgVFVJ4NtRRPf0udJMC4AkAXtCnNvkEI/b E+xw== 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=dtGQBBYNlvHjb7LLco9scDxyfG/HQg5sr2htKlfwsAI=; b=P8VaH7TFjLoU7g5LeDEGXhgajgEeNjur9nSOkGygYK8QmSMBZg+ZHTV+eKvrmL4QaN qlbPPbEXnTJcEvbAmhxRBqIPsz3pRbbO1GZiAPbR9dFv2xWKNeX8K0Z26YghhfZa53qN JNvce+s48/IfXrKljLExquBoNS17K8a+8SRrXzYID6xvgJHbAHiss1vvZadADX82RYQL Si7lVvq+S2AKHRoiEaXBrnANnWk3125+fybiGCW4uIEyicIakAJNxpbqD7dPtInjmvha 2TzjWch63nP4avU89Ev55D+cpXUo7cT+7csu1GQec6mtiXAgKtfP6qb+g3bZUyYWpk6w gjbw== X-Gm-Message-State: AFeK/H1f1b986LyaSvWRI2IHMQ0i90ILhjRn9QP5WsSUrlHvDVshPkU33Y2qjZ+YOk/lNVO7kP87bIHdI3/buA== X-Received: by 10.223.160.5 with SMTP id k5mr73271wrk.123.1490918524237; Thu, 30 Mar 2017 17:02:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.148.35 with HTTP; Thu, 30 Mar 2017 17:02:03 -0700 (PDT) In-Reply-To: References: From: David Mehler Date: Thu, 30 Mar 2017 20:02:03 -0400 Message-ID: Subject: Re: shell script guru To: Rajarajan Rajamani Cc: freebsd-questions Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Mar 2017 00:02:06 -0000 Hello, My question is regarding a shell script and pf. What I'm wanting to do is take a selected list of countries and cat them in to a file and use that as pf input. Here's a sequential example: #!/bin/sh # PATH=/bin:/usr/local/bin:/sbin cd /tmp mkdir zones cd zones # -4 = use IPv4 only # --no-proxy = don't care for proxies # --no-cookies = don't accept cookies # --no-cache = no cached files wget -4 --no-proxy --no-cookies --no-cache \ http://ipdeny.com/ipblocks/data/countries/cn.zone # CHINA sleep 2 wget -4 --no-proxy --no-cookies --no-cache \ http://ipdeny.com/ipblocks/data/countries/az.zone # AZERBAIJAN sleep 2 wget -4 --no-proxy --no-cookies --no-cache \ http://ipdeny.com/ipblocks/data/countries/by.zone # BELARUS sleep 2 wget -4 --no-proxy --no-cookies --no-cache \ http://ipdeny.com/ipblocks/data/countries/kz.zone # KAZAKHSTAN sleep 2 wget -4 --no-proxy --no-cookies --no-cache \ http://ipdeny.com/ipblocks/data/countries/kg.zone # KYRGYZSTAN sleep 2 wget -4 --no-proxy --no-cookies --no-cache \ http://ipdeny.com/ipblocks/data/countries/ru.zone # RUSSIAN FEDERATION sleep 2 wget -4 --no-proxy --no-cookies --no-cache \ http://ipdeny.com/ipblocks/data/countries/tj.zone # TAJIKISTAN sleep 2 wget -4 --no-proxy --no-cookies --no-cache \ http://ipdeny.com/ipblocks/data/countries/tm.zone # TURKMENISTAN sleep 2 wget -4 --no-proxy --no-cookies --no-cache \ http://ipdeny.com/ipblocks/data/countries/uz.zone # UZBEKISTAN sleep 2 wget -4 --no-proxy --no-cookies --no-cache \ http://ipdeny.com/ipblocks/data/countries/vn.zone # VIET NAM # cat cn.zone > blocked_zones cat az.zone >> blocked_zones cat by.zone >> blocked_zones cat kz.zone >> blocked_zones cat kg.zone >> blocked_zones cat ru.zone >> blocked_zones cat tj.zone >> blocked_zones cat tm.zone >> blocked_zones cat uz.zone >> blocked_zones cat vn.zone >> blocked_zones # rm *.zone # mv blocked_zones /etc/pf/ pfctl -f /etc/pf.conf There are 250 plus zones just in the ipv4 space, and about the same in the ipv6 space. I do not want to manually take down each domain, three times, that's error prown and very easy to miss one. I thought about doing an array, and feeding that to a loop which would cut down the number of lines of repeative code. Help appreciated. Thanks. Dave. On 3/30/17, Rajarajan Rajamani wrote: > Ask your question and I am sure someone will answer! > > On Mar 30, 2017 7:37 PM, "David Mehler" wrote: > >> Hello, >> >> Any shell scripting gurus here please contact me offlist. I have a >> question that I can't figure out. >> >> Thanks. >> Dave. >> _______________________________________________ >> 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" >> >