Jump to content

साचा:IP range calculator/doc

विकिपीडिया, मुक्‍त ज्ञानकोशातून
(साचा:Blockcalc/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

{{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.

  • {{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.

The 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 c
768 256 2 192.168.249.0/24 c
512 2 192.168.250.0/23 c
4 1 1 192.168.249.15 c
1 1 192.168.249.255 c
1 1 192.168.250.15 c
1 1 192.168.251.15 c

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 c

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 c
1 /64 72 2606:6000:610a:9000::/64 c
512M /64 1 /64 1 2604:2000:a866:6800::/64 c
512M /64 2 2604:2000:e000::/35 c
1 /64 72 2606:6000:610a:9000::/64 c
4 /64 1 /64 1 2604:2000:a866:6800::/64 c
1 /64 1 2604:2000:ef48:1400::/64 c
1 /64 1 2604:2000:f82a:2c00::/64 c
1 /64 72 2606:6000:610a:9000::/64 c

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 |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 sets allocation=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 c
1 /64 5 2606:6000:610a:9000::/64 c

allocation=128


Total
affected
Affected
addresses
Given
addresses
Range Contribs
1 /64 1 1 2604:2000:f82a:2c00:eccf:c2e5:8b09:6757 c
1 /64 5 2606:6000:610a:9000::/64 c
6 1 1 2604:2000:f82a:2c00:eccf:c2e5:8b09:6757 c
4 4 2606:6000:610a:9000:1d0f:636f:39a:867c/126 c
1 1 2606:6000:610a:9000:9df6:cc8d:592b:1ae c

results=all


Total
affected
Affected
addresses
Given
addresses
Range Contribs
>64G /64 >64G /64 6 2604::/14 c
1 /64 1 1 2604:2000:f82a:2c00:eccf:c2e5:8b09:6757 c
1 /64 5 2606:6000:610a:9000::/64 c
6 1 1 2604:2000:f82a:2c00:eccf:c2e5:8b09:6757 c
4 4 2606:6000:610a:9000:1d0f:636f:39a:867c/126 c
1 1 2606:6000:610a:9000:9df6:cc8d:592b:1ae c