Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Lonnie Abelbeck <lists@lonnie.abelbeck.com>
To: Kassem Omega <kassemomega@gmail.com>
Cc: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: Re: Suggestion for WireGuard
Date: Thu, 2 Sep 2021 08:46:22 -0500	[thread overview]
Message-ID: <A974F498-8534-48EC-8229-7836341BCC6A@lonnie.abelbeck.com> (raw)
In-Reply-To: <CAJaZ5dPHbc5s=JiCbuBKAGf1Nb3vw0xL9W7_=Na4Skt_pjnWZw@mail.gmail.com>


> On Aug 30, 2021, at 8:19 AM, Kassem Omega <kassemomega@gmail.com> 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






      parent reply	other threads:[~2021-09-02 13:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30 13:19 Kassem Omega
2021-09-02  4:10 ` Guy Godfroy
2021-09-02  4:54 ` Feng Li
2021-09-02 13:46 ` Lonnie Abelbeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A974F498-8534-48EC-8229-7836341BCC6A@lonnie.abelbeck.com \
    --to=lists@lonnie.abelbeck.com \
    --cc=kassemomega@gmail.com \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).