Spis treści

Network: IPv4 cheatsheet

IPv4 address design

Glossary

Component Description
IP address Unique host identifier
Subnet mask Specifies which part of the address is the network
Network address Result AND (IP & mask) - network identifier
Broadcast address Last address in the subnet (all host bits = 1)

Supporting formulae

Classless interdomain routing (CIDR) abbreviation This is an abbreviated notation of the Mask in the form /XX where XX is the number of bits in the mask.
Formulas:
  • Number of addresses = $2^{32 - {text{CIDR}}$ or for mask /24 255 - (Last octet of the mask)
  • Number of hosts = $2^{32 - \text{CIDR}} - 2 $ *(except for /31 and /32).

Summary of Masks and Number of Addresses

CIDR Subnet mask Number of addresses Description
/32 255.255.255.255 1 Unusable mask (only used for assigning addresses that act as unique identifiers)
/31 255.255.255.254 2 Non-useful mask
/30 255.255.255.252 4 Point-to-point networks (e.g. router connections)
/29 255.255.255.248 8 Small networks - e.g. router + several hosts
/28 255.255.255.240 16 Small offices, branches
/27 255.255.255.224 32 LANs with ~30 hosts
/26 255.255.255.192 64 Small LANs
/25 255.255.255.128 128 Class C half
/24 255.255.255.0 256 Most popular for local networks
/23 255.255.254.0 512 Two C classes - e.g. larger corporate networks
/22 255.255.252.0 1024
/21 255.255.248.0 2048 Aggregation of several networks /24
/20 255.255.240.0 4096 Large campus networks
/19 255.255.224.0 8192
/18 255.255.192.0 16384
/17 255.255.128.0 32768
/16 255.255.0.0 65536 Class C 192.168.0.0 - 192.168.255.255
/15 255.254.0.0 131072 Aggregation of two B classes
/14 255.252.0.0 262144
/13 255.248.0.0 524288
/12 255.240.0.0 1048576 Class B 172.16.0.0 - 172.31.255.255
/11 255.224.0.0 2097152
/10 255.192.0.0 4194304
/9 255.128.0.0 8388608
/8 255.0.0.0 16777216 Class A 10.0.0.0 - 10.255.255.255
/7 254.0.0.0 33554432
/6 252.0.0.0 67108864
/5 248.0.0.0 134217728
/4 240.0.0.0 268435456
/3 224.0.0.0 536870912
/2 192.0.0.0 1073741824
/1 128.0.0.0 2147483648
/0 0.0.0.0 4294967296 Any IPv4 address (e.g. default route)

Example of class-based subnetting from the 192.168.0.0/24 pool

If two devices have identical subnet mask values set, and the initial portions of their IP addresses of the length determined by the mask length match, then these devices are addressed in the same subnet.

source: Wikipedia Subnetting

Example of classless subnetting (VLSM) of pool 192.168.0.0/24

VLSM makes it possible to divide an address, e.g. class C (254 hosts, mask 255.255.255.0), into several smaller subnets containing different numbers of hosts. In order for network information to be well distributed between routers, the relevant routing protocols must exchange complete network information including masks between each other.

Source: Wikipedia VLSM