From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6171CC432BE for ; Thu, 2 Sep 2021 13:46:31 +0000 (UTC) Received: from lists.zx2c4.com (lists.zx2c4.com [165.227.139.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4914360525 for ; Thu, 2 Sep 2021 13:46:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4914360525 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lonnie.abelbeck.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.zx2c4.com Received: by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTP id b1f5649c; Thu, 2 Sep 2021 13:46:28 +0000 (UTC) Received: from ibughas.pair.com (ibughas.pair.com [209.68.5.177]) by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTPS id 0cbb4e9f (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Thu, 2 Sep 2021 13:46:24 +0000 (UTC) Received: from ibughas.pair.com (localhost [127.0.0.1]) by ibughas.pair.com (Postfix) with ESMTP id 6E03E1E3057; Thu, 2 Sep 2021 09:46:23 -0400 (EDT) Received: from [10.4.1.148] (wsip-70-184-211-81.om.om.cox.net [70.184.211.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ibughas.pair.com (Postfix) with ESMTPSA id 4D0241E304D; Thu, 2 Sep 2021 09:46:23 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: Suggestion for WireGuard From: Lonnie Abelbeck In-Reply-To: Date: Thu, 2 Sep 2021 08:46:22 -0500 Cc: WireGuard mailing list Content-Transfer-Encoding: 7bit Message-Id: References: To: Kassem Omega X-Mailer: Apple Mail (2.3445.104.21) X-BeenThere: wireguard@lists.zx2c4.com X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: Development discussion of WireGuard List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: wireguard-bounces@lists.zx2c4.com Sender: "WireGuard" > On Aug 30, 2021, at 8:19 AM, Kassem Omega wrote: > > snip... > > The use case: allowing all traffic to go through WireGuard except > specific ranges. > > Right now to do this I must use this long list of ranges to achieve this: > > AllowedIPs = 0.0.0.0/5, 8.0.0.0/7, 11.0.0.0/8, 12.0.0.0/6, 16.0.0.0/4, > 32.0.0.0/3, 64.0.0.0/2, 128.0.0.0/3, 160.0.0.0/5, 168.0.0.0/6, > 172.0.0.0/12, 172.16.0.0/24, 172.32.0.0/11, 172.64.0.0/10, > 172.128.0.0/9, 173.0.0.0/8, 174.0.0.0/7, 176.0.0.0/4, 192.0.0.0/9, > 192.128.0.0/11, 192.160.0.0/13, 192.169.0.0/16, 192.170.0.0/15, > 192.172.0.0/14, 192.176.0.0/12, 192.192.0.0/10, 193.0.0.0/8, > 194.0.0.0/7, 196.0.0.0/6, 200.0.0.0/5, 208.0.0.0/4, 8.8.8.8/32 > > However, if the DisallowedIPs option is available, I'd simply use: > > DisallowedIPs = 192.168.0.0/16, 10.0.0.0/8 For the IPv4-only case, there is a handy C based tool: iprange [1] For your example: Allow: 0.0.0.0/0 Disallow: 192.168.0.0/16, 10.0.0.0/8 $ cat allow.ipset 0.0.0.0/0 $ cat disallow.ipset 192.168.0.0/16 10.0.0.0/8 $ iprange allow.ipset --exclude-next disallow.ipset 0.0.0.0/5 8.0.0.0/7 11.0.0.0/8 12.0.0.0/6 16.0.0.0/4 32.0.0.0/3 64.0.0.0/2 128.0.0.0/2 192.0.0.0/9 192.128.0.0/11 192.160.0.0/13 192.169.0.0/16 192.170.0.0/15 192.172.0.0/14 192.176.0.0/12 192.192.0.0/10 193.0.0.0/8 194.0.0.0/7 196.0.0.0/6 200.0.0.0/5 208.0.0.0/4 224.0.0.0/3 The output is optimized and sorted. Lonnie [1] https://github.com/firehol/iprange