This template uses Lua: |
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
{{IP range calculator| 192.168.254.175 192.168.251.15 192.168.251.12 192.168.254.172 192.168.251.14 }}
or with the equivalent
{{blockcalc| 192.168.254.175 192.168.251.15 192.168.251.12 192.168.254.172 192.168.251.14 }}
then preview the edit. If wanted, the edit could be saved to record the results in the page history.
Syntax
edit{{blockcalc|address1|address2|address3|...}}
Addresses (IPv4 and/or IPv6) can be entered as separate arguments.{{blockcalc|address1 address2 address3 ...}}
Addresses can also be entered in a single argument.{{blockcalc|Any text that includes IPv4 and/or IPv6 addresses.}}
Addresses are extracted from the arguments, so any text can be used.{{blockcalc|1=Any text with = that includes IPv4 and/or IPv6 addresses.}}
Use 1= if the text contains "=".
The following optional parameters can be used.
|ok
- Do not show the announcement in the results.
- By default, the results may start with an announcement regarding significant changes to the template.
|months=n
- 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.
|nolist
- Do not list the IPs extracted from the input.
- By default, a sorted list of input IP addresses is included, with any duplicates omitted.
|nonote
- 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 Allow /16, /24 and /27 – /32 CIDR ranges on Special:Contributions forms gadget in Special:Preferences.
|text
- Show plain text results rather than a table.
|allocation=n
- 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.
|results=all
- 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.
|results=n
- The number n can be 1 to 100; the default is 10.
- No more than n summaries are shown.
|comment=text
- 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,
|comment=#
would ignore lines that start with a hash.
Examples
editThe following can be previewed by editing any page, for example your sandbox.
{{blockcalc| 192.168.250.15 192.168.249.255 192.168.249.15 192.168.251.15 }}
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.
Sorted 4 IPv4 addresses:
- 192.168.249.15
- 192.168.249.255
- 192.168.250.15
- 192.168.251.15
Total affected |
Affected addresses |
Given addresses |
Range | Contribs |
---|---|---|---|---|
1024 | 1024 | 4 | 192.168.248.0/22 | contribs |
768 | 256 | 2 | 192.168.249.0/24 | contribs |
512 | 2 | 192.168.250.0/23 | contribs | |
4 | 1 | 1 | 192.168.249.15 | contribs |
1 | 1 | 192.168.249.255 | contribs | |
1 | 1 | 192.168.250.15 | contribs | |
1 | 1 | 192.168.251.15 | contribs |
If plain text is preferred, |text
can be used to produce the following result.
Sorted 4 IPv4 addresses:
- 192.168.249.15
- 192.168.249.255
- 192.168.250.15
- 192.168.251.15
Total Affected Given Range ---------------------------------------------------------- 1024 1024 4 192.168.248.0/22 ---------------------------------------------------------- 768 256 2 192.168.249.0/24 512 2 192.168.250.0/23 ---------------------------------------------------------- 4 1 1 192.168.249.15 1 1 192.168.249.255 1 1 192.168.250.15 1 1 192.168.251.15
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.
{{blockcalc|2601:188:0:ABE6:65F5:930C:B0B2:CD63}}
Sorted 1 IPv6 address:
- 2601:188:0:abe6:65f5:930c:b0b2:cd63
Total affected |
Affected addresses |
Given addresses |
Range | Contribs |
---|---|---|---|---|
1 /64 | 1 /64 | 1 | 2601:188:0:abe6::/64 | contribs |
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.
Total affected |
Affected addresses |
Given addresses |
Range | Contribs |
---|---|---|---|---|
2G /64 | 2G /64 | 3 | 2604:2000:8000::/33 | contribs |
1 /64 | 72 | 2606:6000:610a:9000::/64 | contribs | |
512M /64 | 1 /64 | 1 | 2604:2000:a866:6800::/64 | contribs |
512M /64 | 2 | 2604:2000:e000::/35 | contribs | |
1 /64 | 72 | 2606:6000:610a:9000::/64 | contribs | |
4 /64 | 1 /64 | 1 | 2604:2000:a866:6800::/64 | contribs |
1 /64 | 1 | 2604:2000:ef48:1400::/64 | contribs | |
1 /64 | 1 | 2604:2000:f82a:2c00::/64 | contribs | |
1 /64 | 72 | 2606:6000:610a:9000::/64 | contribs |
IPv6
editFor 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
|allocation=128
(or another value such as|allocation=112
) to change the range that is assumed to represent a single user; or - Use
|results=all
to generate as many results as possible; this option also setsallocation=128
.
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:
{{blockcalc|ok|nolist|nonote| 2604:2000:f82a:2c00:eccf:c2e5:8b09:6757 2606:6000:610a:9000:1d0f:636f:39a:867c 2606:6000:610a:9000:1d0f:636f:39a:867d 2606:6000:610a:9000:1d0f:636f:39a:867e 2606:6000:610a:9000:1d0f:636f:39a:867f 2606:6000:610a:9000:9df6:cc8d:592b:1ae }} {{blockcalc|ok|nolist|nonote|allocation=128| 2604:2000:f82a:2c00:eccf:c2e5:8b09:6757 2606:6000:610a:9000:1d0f:636f:39a:867c 2606:6000:610a:9000:1d0f:636f:39a:867d 2606:6000:610a:9000:1d0f:636f:39a:867e 2606:6000:610a:9000:1d0f:636f:39a:867f 2606:6000:610a:9000:9df6:cc8d:592b:1ae }} {{blockcalc|ok|nolist|nonote|results=all| 2604:2000:f82a:2c00:eccf:c2e5:8b09:6757 2606:6000:610a:9000:1d0f:636f:39a:867c 2606:6000:610a:9000:1d0f:636f:39a:867d 2606:6000:610a:9000:1d0f:636f:39a:867e 2606:6000:610a:9000:1d0f:636f:39a:867f 2606:6000:610a:9000:9df6:cc8d:592b:1ae }}
The results follow.
Default
Total affected |
Affected addresses |
Given addresses |
Range | Contribs |
---|---|---|---|---|
2 /64 | 1 /64 | 1 | 2604:2000:f82a:2c00::/64 | contribs |
1 /64 | 5 | 2606:6000:610a:9000::/64 | contribs |
allocation=128
Total affected |
Affected addresses |
Given addresses |
Range | Contribs |
---|---|---|---|---|
1 /64 | 1 | 1 | 2604:2000:f82a:2c00:eccf:c2e5:8b09:6757 | contribs |
1 /64 | 5 | 2606:6000:610a:9000::/64 | contribs | |
6 | 1 | 1 | 2604:2000:f82a:2c00:eccf:c2e5:8b09:6757 | contribs |
4 | 4 | 2606:6000:610a:9000:1d0f:636f:39a:867c/126 | contribs | |
1 | 1 | 2606:6000:610a:9000:9df6:cc8d:592b:1ae | contribs |
results=all
Total affected |
Affected addresses |
Given addresses |
Range | Contribs |
---|---|---|---|---|
>64G /64 | >64G /64 | 6 | 2604::/14 | contribs |
1 /64 | 1 | 1 | 2604:2000:f82a:2c00:eccf:c2e5:8b09:6757 | contribs |
1 /64 | 5 | 2606:6000:610a:9000::/64 | contribs | |
6 | 1 | 1 | 2604:2000:f82a:2c00:eccf:c2e5:8b09:6757 | contribs |
4 | 4 | 2606:6000:610a:9000:1d0f:636f:39a:867c/126 | contribs | |
1 | 1 | 2606:6000:610a:9000:9df6:cc8d:592b:1ae | contribs |
This template has not been added to any categories. Please help out by adding categories to it so that it can be listed with similar templates. |