What is /24 / 16 in ip addresses?

You must block all addresses: 109.207.13. X that is, from 109.207.13.0 to 109.207.13.255

I read that a lot of addresses are denoted by: so: 109.207.13.0/16 or so: 109.207.13.0/24

Please tell me how to do it correctly? And what does /16 /24 mean ?

 20
Author: tfox, 2013-08-03

1 answers

/16, /24 - this is the designation of network classes.

I will not rewrite the match, so read here.

You can experiment and clearly understand the correctness of understanding here.

As for the mentioned "109.207.13. X that is, from 109.207.13.0 to 109.207.13.255", this is a Class C network, i.e. 109.207.13.0/24 with a subnet mask 255.255.255.0 (where /24 means the representation of the mask in decimal form, namely with its binary notation form 11111111.11111111.11111111.00000000, i.e. the mask is 24 bits out of the possible 32-x, and the number of possible hosts in this subnet, as in your case, is just 256, i.e. from 0 to 255 inclusive).

Eh.. Once such a drunken party has gone , cut the last cucumber..

So, what is /24: An IP address (IPv4) is an address consisting of 4 bytes (32-bit, i.e. 4x8 bits separated by a dot), where its format of writing in binary form looks like 11000000.10101000.00000000.00000001. And in decimal form, a similar entry looks like a record of 4 numbers from 0 to 255 inclusive, where 255 is the maximum number that can be expressed in 8 bits, i.e. 255 in binary format will look like this: 11111111. That is, some IP, say 192.168.0.1, will look like this in binary form: 11000000.10101000.00000000.00000001. If you take the network 192.168.0.0/24 and select any IP address from the range 192.168.0.0 - 192.168.0.255, then for a specific IP address of any of these 256 possible hosts (theoretically from 0 to 255 inclusive), the subnet mask will look like this: 11111111.11111111.11111111.00000000 (255.255.255.0 in decimal form), which means that the 3х8=24 bits (from left to right) in the address are the bits pointing to the subnet address, and the last 8 bits are allocated to the IP addresses of hosts in the subnet, i.e. from 0 to 255 (which is equal to 256 - ti, and 256 is the number of all possible combinations from 00000000 to 11111111).

Now further and deeper: let's say that you do not need all 256 hosts in one subnet, but you want to divide the space into more 2 subnets (128 hosts in each). Then you can divide this network is like this: the subnet mask will be 255.255.255.128 (i.e. 11111111.11111111.11111111.10000000 or /25 - by the number of bits from left to right) and we get networks with 128 hosts in each: 0-127 in one (Network 192.168.0.0 with Broadcast Address 192.168.0.127) and 128-255 (Network 192.168.0.128 with Broadcast Address 192.168.0.255) in the other.

I will add more for understanding (without going into the details of operations with binary data), in simple words for quick calculation in my mind: since the IPv4 address always consists of 4х8=32 bits, and if the subnet mask in in a particular case, it takes, say, 24 bits (those from left to right), then 32-24=8 bits go under the range for the IP addresses of hosts (read computers, network printers, other devices that have their own IPv4). And in order to calculate in this case what is the number of possible hosts for each subnet with a given mask, it is necessary to raise 2 to the power of 8 (where 8 is the number of zeros in the mask), i.e. the result will be 256. If we take the network 192.168.0.0/26, then by itself the number of zeros will be if 6 is equal to32-26, then the number of hosts will be 2^6=64, the mask will be 255.255.255.192, and the number of subnets in this range will be 4-m (4х64 in each).

An attentive person will notice, without even going into details, that the sum of the number of possible hosts in the subnet and the last number in the mask add up to 256, and the number of subnets is 256 divided by 64 (the number of hosts in each subnet, where 256 and 64 are just for this example! - why, it is necessary understand it yourself, at least by analogy with/16, given below) and make logical conclusions.

Well, based on the above, it is not difficult to decompose the following: /16 (the so-called Class B) - this is when possible 65536 (2^16) hosts in the same subnet, i.e. the mask looks like this: 11111111.11111111.00000000.00000000, i.e. the network address occupies 8х2=16 bits (on the left), and under the IP addresses of the hosts, 8х2=16 is also allocated (all possible combinations from 00000000.00000000 to 11111111.11111111, i.e. just 65536 pieces) the values of the bits from the address (on the right). the range of host IP addresses in decimal form looks like this: from 192.168.0.0 to 192.168.255.255, where the subnet mask is /16, i.e. 255.255.0.0

And so on..

As for " Please tell me how to do it correctly?" - if we are talking about .htaccess, then you can safely use Deny and specify 109.207.13.0/24.

order allow,deny
allow from all
deny from 109.207.13.0/24

If we are talking about blocking in any Cisco or Juniper - then this is then in their documentation and on the rootcode :)

 38
Author: void, 2013-08-04 08:12:09