|
| 1 | +# IPv4 Addressing |
| 2 | + |
| 3 | + |
| 4 | +## Table of contents |
| 5 | +* [IPv4 Address](#ipv4-address) |
| 6 | +* [Decimal and Binary](#decimal-and-binary) |
| 7 | +* [IPv4 Address Classes](#ipv4-address-classes) |
| 8 | + |
| 9 | + |
| 10 | +## IPv4 Address |
| 11 | + |
| 12 | +* `32 bits` / `4 bytes` |
| 13 | +* We use **dotted decimal** instead of binary for ease of use |
| 14 | + * `192.168.1.254` = `11000000.10101000.00000001.11111110` |
| 15 | +* **CIDR notation**: `/24` after the IP number indicates `24` out of the `32` bits in an IP address correspond to the network portion. Possible values are `1 > n > 32` where `n` is an integer. 🔥🔥🔥 |
| 16 | + * i.e `192.168.1.0/24` |
| 17 | + |
| 18 | +## Decimal and Binary |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +### Binary to Decimal |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +### Decimal to Binary |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +## IPv4 Address Classes |
| 34 | + |
| 35 | +| Class | First octet | First octet numeric range | |
| 36 | +| :-: | :-: | :-: | |
| 37 | +| **A** | 0xxxxxxx | 0-127 | |
| 38 | +| **B** | 10xxxxxx | 128-191 | |
| 39 | +| **C** | 110xxxxx | 192-223 | |
| 40 | +| **D** | 1110xxxx | 224-239 | |
| 41 | +| **E** | 1111xxxx | 240-255 | |
| 42 | + |
| 43 | +* `A` class range end is usually considered `126` because `127` first octet is used to test the **network stack (l3)** on the local device |
| 44 | +* We will focus on `A`, `B` and `C`. |
| 45 | +* `D` are multicast addresses |
| 46 | +* `E` are reserved (experimental) |
| 47 | + |
| 48 | +| Class | First octet | First octet numeric range | Prefix Length | |
| 49 | +| :-: | :-: | :-: | :-: | |
| 50 | +| **A** | 0xxxxxxx | 0-127 | /8 | |
| 51 | +| **B** | 10xxxxxx | 128-191 | /16 | |
| 52 | +| **C** | 110xxxxx | 192-223 | /24 | |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +### Netmask |
| 57 | + |
| 58 | +| Class | Prefix Length | Netmask | Binary octets | |
| 59 | +| :-: | :-: | :-: | :-: | |
| 60 | +| **A** | /8 | 255.0.0.0 | 11111111 00000000 00000000 00000000 | |
| 61 | +| **B** | /16 | 255.255.0.0 | 11111111 11111111 00000000 00000000 | |
| 62 | +| **C** | /24 | 255.255.255.0 | 11111111 11111111 11111111 00000000 | |
| 63 | + |
| 64 | +### Network address |
| 65 | + |
| 66 | +`192.168.1.0/24` |
| 67 | + |
| 68 | +* `/24` means `192.168.1` is the network portion and `.0` is the host portion |
| 69 | +* Since the **host portion** is `0` it means it is the network address |
| 70 | +* it is the first address with a **host portion** of all `0`s |
| 71 | + |
| 72 | +### Broadcast address |
| 73 | + |
| 74 | +`192.168.1.255/24` |
| 75 | + |
| 76 | +* last address in the network |
| 77 | +* with `/24` net mask it would be the last octet `.255` |
| 78 | +* cannot be assigned to a host |
0 commit comments