Template:IP range calculator/doc

This template accepts IPv4 or IPv6 addresses as input and displays minimum-sized blocks of addresses that cover all of the inputs. The result uses CIDR notation and can be used by an administrator to block a range of IP addresses.

The template can be used by editing any page, inserting the template, and previewing the result. There is no need to save the edit. As an example, you could edit your sandbox and replace its contents with

or with the equivalent

then preview the edit. If wanted, the edit could be saved to record the results in the page history.

Syntax


The following optional parameters can be used.
 * Do not show the announcement in the results.
 * By default, the results may start with an announcement regarding significant changes to the template.
 * By default, the results may start with an announcement regarding significant changes to the template.


 * Applies to links that display the contributions for a range of IPs.
 * The number n can be 1 to 12; the default is 1.
 * With the default value of 1, only contributions from the previous month are listed. For example, if the current date was 26 April 2016, contributions on or after 26 March 2016 would be shown.
 * With the default value of 1, only contributions from the previous month are listed. For example, if the current date was 26 April 2016, contributions on or after 26 March 2016 would be shown.


 * Do not list the IPs extracted from the input.
 * By default, a sorted list of input IP addresses is included, with any duplicates omitted.
 * By default, a sorted list of input IP addresses is included, with any duplicates omitted.


 * Do not show notes underneath the results.
 * By default, when a contributions link for a range is displayed, a note is added to explain that the listed contributions, by default, are restricted to those in the previous month. In addition, IPv6 range contributions require that the user has enabled the gadget in Special:Preferences.
 * By default, when a contributions link for a range is displayed, a note is added to explain that the listed contributions, by default, are restricted to those in the previous month. In addition, IPv6 range contributions require that the user has enabled the gadget in Special:Preferences.


 * Show plain text results rather than a table.
 * Show plain text results rather than a table.


 * Applies to IPv6; ignored for IPv4 addresses.
 * The number n can be 48 to 128; the default is 64.
 * With the default value of 64, ranges with fewer IPv6 addresses than a /64 allocation are not considered. That means the results will not include a /n range with n > 64.
 * With the default value of 64, ranges with fewer IPv6 addresses than a /64 allocation are not considered. That means the results will not include a /n range with n > 64.


 * Show all possible summaries, including any with a range that is too large to block (/n less than /16 for IPv4 or /19 for IPv6).
 * Also changes the default allocation from 64 to 128.
 * Also changes the default allocation from 64 to 128.


 * The number n can be 1 to 100; the default is 10.
 * No more than n summaries are shown.
 * No more than n summaries are shown.


 * Lines beginning with the comment text are ignored.
 * By default, no comment text is defined and no lines are ignored.
 * It may be convenient to temporarily edit the input list of addresses by commenting out unwanted lines.
 * For example,  would ignore lines that start with a hash.
 * For example,  would ignore lines that start with a hash.

Examples
The following can be previewed by editing any page, for example your sandbox.

The result of the preview follows. The first row shows that blocking 192.168.248.0/22 would cover all the given IPs but would affect 1024 addresses. The next group of results (the second and third rows) shows an alternative that would affect 768 addresses but would require blocking two ranges, 192.168.249.0/24 and 192.168.250.0/23. The final group of results points out that the four individual IPs could be blocked.

If plain text is preferred,  can be used to produce the following result.

The following example shows that entering a single IPv6 address displays its /64 range with a link to the recent contributions made by addresses in that range.

Multiple IPv6 addresses can be entered, as shown in the following example which uses a long command, not shown for brevity. The first two rows show that 3 of the entered addresses are in a /33 range, while 72 are in a /64. Blocking the /33 would affect 2G /64, that is, over 2 billion /64 allocations, but would block only 3 of the given addresses. By contrast, blocking the /64 in the second row would block 72 of the given addresses.

IPv6
For IPv6, the range calculator defaults to assuming that a /64 range is allocated to each user. Therefore, by default, it stops once it reaches /64 without looking for more precise ranges. There are two ways to request more results:
 * Use  (or another value such as  ) to change the range that is assumed to represent a single user; or
 * Use  to generate as many results as possible; this option also sets.

The results produced for IPv6 ranges are correct but may not be satisfactory since it is not possible to know how many different users may be using addresses in a /64 range, and no tools are available to show the contributions for an IPv6 range. Requesting results that go beyond /64 may show too much detail.

The options to request more results are illustrated with the following three examples which operate on the same six addresses:

The results follow.

Default

allocation=128

results=all