Chapitre 3
Chapter 03: IPv4 et IPv6
Chapter 03: IPv4 et IPv6
Chapter 03: IPv4 et IPv6
1. IPv4 Addressing
1.1 IPv4 Address Structure
An IPv4 address is a 32-bit number, typically written in dotted-decimal notation:
192.168.1.10
Binary: 11000000.10101000.00000001.00001010 Decimal: 192.168.1.10
Each address has two parts:
- Network portion: Identifies the network
- Host portion: Identifies the host within the network
1.2 Address Classes (Classful Addressing)
Historically, IPv4 addresses were divided into classes:
| Class | First Bits | Start | End | Default Mask | Networks | Hosts/Network |
|---|---|---|---|---|---|---|
| A | 0 | 0.0.0.0 | 127.255.255.255 | /8 | 128 | 16,777,214 |
| B | 10 | 128.0.0.0 | 191.255.255.255 | /16 | 16,384 | 65,534 |
| C | 110 | 192.0.0.0 | 223.255.255.255 | /24 | 2,097,152 | 254 |
| D | 1110 | 224.0.0.0 | 239.255.255.255 | Multicast | - | - |
| E | 1111 | 240.0.0.0 | 255.255.255.255 | Reserved | - | - |
1.3 CIDR (Classless Inter-Domain Routing)
RFC 1518/1519 (1993) replaced classful addressing with CIDR. The network/host boundary can be anywhere, specified by the prefix length: 192.168.1.0/24
Diagramme en cours de génération...
Key CIDR concepts:
- Prefix length (e.g., /24) indicates number of network bits
- No fixed class boundaries
- Enables route aggregation (summarization)
- Conserves address space
1.4 Subnetting
Dividing a network into smaller subnets.
Diagramme en cours de génération...
Subnetting Cheatsheet:
| Prefix | Mask | Networks | Hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 1 | 254 |
| /25 | 255.255.255.128 | 2 | 126 |
| /26 | 255.255.255.192 | 4 | 62 |
| /27 | 255.255.255.224 | 8 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 32 | 6 |
| /30 | 255.255.255.252 | 64 | 2 |
| /31 | 255.255.255.254 | 128 | 0 (point-to-point) |
| /32 | 255.255.255.255 | 256 | 1 (host route) |
1.5 VLSM (Variable Length Subnet Mask)
Using different subnet masks for different subnets within the same network.
Example: 192.168.1.0/24 with requirements:
- Subnet A: 100 hosts → /25 (126 hosts)
- Subnet B: 50 hosts → /26 (62 hosts)
- Subnet C: 25 hosts → /27 (30 hosts)
- Subnet D: 2 hosts (router link) → /30 (2 hosts)
Diagramme en cours de génération...
1.6 Special IPv4 Addresses
| Address | Purpose |
|---|---|
| 0.0.0.0/8 | "This network" (source only) |
| 127.0.0.0/8 | Loopback (localhost) |
| 169.254.0.0/16 | Link-local (APIPA) |
| 10.0.0.0/8 | Private (RFC 1918) |
| 172.16.0.0/12 | Private (RFC 1918) |
| 192.168.0.0/16 | Private (RFC 1918) |
| 224.0.0.0/4 | Multicast |
| 240.0.0.0/4 | Reserved |
| 255.255.255.255 | Limited broadcast |
1.7 NAT (Network Address Translation)
RFC 3022 - Translates private IPs to public IPs.
Diagramme en cours de génération...
NAT Types:
- SNAT (Source NAT): Translate source IP (outbound)
- DNAT (Destination NAT): Translate destination IP (inbound)
- PAT (Port Address Translation): Many-to-one using ports
- 1:1 NAT: One private IP to one public IP
1.8 IPv4 Header
Diagramme en cours de génération...
2. IPv6 Addressing
2.1 IPv6 Address Structure
IPv6 uses 128-bit addresses, written in hexadecimal:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
Format rules:
- 8 groups of 16 bits (4 hex digits each)
- Leading zeros can be omitted
- One contiguous group of zeros can be replaced with
::
Example shortening:
2001:0db8:0000:0000:0000:8a2e:0370:7334
→ 2001:db8:0:0:0:8a2e:370:7334
→ 2001:db8::8a2e:370:7334
2.2 IPv6 Address Types
Diagramme en cours de génération...
| Type | Prefix | Range | Usage |
|---|---|---|---|
| Global Unicast | 2000::/3 | 2000:: - 3fff:ffff:... | Internet routable |
| Unique Local | fc00::/7 | fc00:: - fdff:ffff:... | Private (like 10.0.0.0/8) |
| Link-Local | fe80::/10 | fe80:: - febf:ffff:... | Local link only |
| Multicast | ff00::/8 | ff00:: - ffff:ffff:... | One-to-many |
| Loopback | ::1/128 | ::1 | Localhost |
| Unspecified | ::/128 | :: | Not assigned |
| IPv4-mapped | ::ffff:0:0/96 | ::ffff:x.x.x.x | IPv4 transition |
2.3 IPv6 Header
Diagramme en cours de génération...
Simplified header vs IPv4:
- No checksum (reduces processing)
- No fragmentation (handled by sender)
- No options (uses extension headers)
- Fixed 40-byte header
- Flow Label for QoS
- Hop Limit instead of TTL
2.4 IPv6 Extension Headers
Diagramme en cours de génération...
2.5 SLAAC (Stateless Address Autoconfiguration)
Diagramme en cours de génération...
SLAAC flags in RA:
- M (Managed): 0 = no DHCPv6, 1 = use DHCPv6 for addresses
- O (Other): 0 = no other info, 1 = use DHCPv6 for other config
Address configuration methods:
| Method | Address | Other Config | Use Case |
|---|---|---|---|
| SLAAC | RA prefix + EUI-64/privacy | None (or RDNSS) | Simple networks |
| SLAAC + DHCPv6 | RA prefix + EUI-64/privacy | DHCPv6 for DNS etc. | Enterprise |
| DHCPv6 (stateless) | RA prefix + EUI-64/privacy | DHCPv6 for options | Managed networks |
| DHCPv6 (stateful) | DHCPv6 (M=1) | DHCPv6 | Managed networks |
2.6 NDP (Neighbor Discovery Protocol)
Replaces ARP in IPv6. Uses ICMPv6 messages:
| Message | Type | Purpose |
|---|---|---|
| NS (Neighbor Solicitation) | 135 | Request MAC of neighbor |
| NA (Neighbor Advertisement) | 136 | Response to NS |
| RS (Router Solicitation) | 133 | Request RA from router |
| RA (Router Advertisement) | 134 | Announce prefixes, routes |
| Redirect | 137 | Better next hop |
NDP vs ARP:
- NDP uses ICMPv6 (not a separate protocol)
- NDP includes DAD, SLAAC
- NDP uses solicited-node multicast (not broadcast)
- NDP is secured by Secure Neighbor Discovery (SEND)
3. ICMP (Internet Control Message Protocol)
3.1 ICMPv4
Used for diagnostics and error reporting.
| Type | Code | Description |
|---|---|---|
| 0 | 0 | Echo Reply |
| 3 | 0 | Destination Network Unreachable |
| 3 | 1 | Destination Host Unreachable |
| 3 | 3 | Port Unreachable |
| 3 | 4 | Fragmentation Needed (DF set) |
| 8 | 0 | Echo Request |
| 11 | 0 | TTL Exceeded |
| 11 | 1 | Fragment Reassembly Time Exceeded |
3.2 ping
Diagramme en cours de génération...
3.3 traceroute
Diagramme en cours de génération...
3.4 Path MTU Discovery
Diagramme en cours de génération...
4. Transition Mechanisms
4.1 Dual Stack
Both IPv4 and IPv6 run simultaneously. The device uses whichever is available.
Diagramme en cours de génération...
4.2 Tunneling
IPv6 packets encapsulated in IPv4 (or vice versa).
Diagramme en cours de génération...
Tunnel Types:
- 6in4: IPv6 in IPv4 (protocol 41)
- 6to4: Automatic tunnel using 2002::/16
- Teredo: IPv6 over UDP
- ISATAP: Intra-site Automatic Tunnel
- GRE: Generic Routing Encapsulation
4.3 NAT64 / DNS64
Translates IPv6-only clients to IPv4 servers.
Diagramme en cours de génération...
5. Subnetting Exercises
Example 1: Basic Subnetting
Network: 192.168.1.0/24 → Create 4 subnets
| Subnet | Network | Range | Broadcast |
|---|---|---|---|
| 1 | 192.168.1.0/26 | .1 - .62 | .63 |
| 2 | 192.168.1.64/26 | .65 - .126 | .127 |
| 3 | 192.168.1.128/26 | .129 - .190 | .191 |
| 4 | 192.168.1.192/26 | .193 - .254 | .255 |
Example 2: VLSM
Given: 10.0.0.0/8
- Need: 500 hosts → /23 (510 hosts)
- Need: 200 hosts → /24 (254 hosts)
- Need: 100 hosts → /25 (126 hosts)
- Need: 2 router links → /30 each
Allocation:
- 10.0.0.0/23 (500 hosts)
- 10.0.2.0/24 (200 hosts)
- 10.0.3.0/25 (100 hosts)
- 10.0.3.128/30 (router link 1)
- 10.0.3.132/30 (router link 2)
Example 3: IPv6 Subnetting
Prefix: 2001:db8:abcd::/48
Subnets available: 16 bits = 65,536 /64 subnets
| Subnet | Prefix | Use |
|---|---|---|
| 0 | 2001:db8:abcd:0000::/64 | Management |
| 1 | 2001:db8:abcd:0001::/64 | Users Floor 1 |
| 2 | 2001:db8:abcd:0002::/64 | Users Floor 2 |
| ... | ... | ... |
| FFFF | 2001:db8:abcd:ffff::/64 | Reserved |
6. Summary
| Aspect | IPv4 | IPv6 |
|---|---|---|
| Address size | 32 bits | 128 bits |
| Notation | Dotted decimal | Hexadecimal |
| Header size | 20-60 bytes | 40 bytes |
| Address types | Unicast, multicast, broadcast | Unicast, multicast, anycast |
| Private addresses | RFC 1918 | ULA (fc00::/7) |
| Link-local | APIPA (169.254/16) | fe80::/10 |
| ARP | ARP (broadcast) | NDP (multicast) |
| Fragmentation | Routers can fragment | Only source fragments |
| Checksum | Has header checksum | No checksum |
| QoS | TOS byte | Traffic class + Flow label |
| IPsec | Optional | Originally required |
| Config | DHCP (manual or auto) | SLAAC, DHCPv6 |
7. Exercises
Exercise 1
Given 172.16.0.0/16, subnet for 30 subnets. What prefix length? What are the first 3 subnet addresses?
Exercise 2
Calculate: What is the network address, broadcast, and valid host range for 192.168.15.37/28?
Exercise 3
Design a VLSM plan for: 10.0.0.0/8 with 3 subnets needing 1000, 500, and 250 hosts, plus 5 /30 point-to-point links.
Exercise 4
IPv6: Shorten 2001:0db8:0000:0000:0000:ff00:0042:8329. Expand fe80::1.
Exercise 5
Calculate the EUI-64 interface ID for MAC 00:1a:2b:3c:4d:5e.