On Mon, May 22, 2023 at 04:49:07AM +0200, cor...@free.fr wrote: > Hello list, > > currently the netmask for an IPv4 is 255.255.255.255. > I am just not sure, why can't the netmask for IPv4 be 768.768.768.768? > Can I set that a netmask directly in linux OS? > If so we have much more IPv4 space available, even no IPv6 is needed.
Charles is right: the Wikipedia page is a good resource here. The short answer is: an IPv4 address is, behind the scenes a 32 bit number; for (human) display it is subdivided into four 8 bit chunks (called "octets" for obvious reasons), and those octets only can go from 0 to 255 (since 2^8 == 255). There are more limitations to netmasks: since the net part of an address has to be "to the left" and the host part "to the right", you can only have netmasks with all (binary) ones to the left and all (binary) zeroes to the right. Some examples: | binary | decimal | |-------------------------------------+-----------------| | 11111111.11111111.11111111.00000000 | 255.255.255.0 | | 11111111.11111111.11111111.10000000 | 255.255.255.128 | | 11111111.11111111.11111111.11000000 | 255.255.255.192 | Therefore it is sufficient to specify how many "one" bits there are in your netmask. These days it is customary to just write that (after a slash) to specify the netmask. For an IP address of the third type, you might write, for example: 192.168.12.11/26 ...the "26" specifying the netmask. Cheers -- t
signature.asc
Description: PGP signature