IPv4 Options and IPv6 Extension Headers: Hop-by-Hop, Routing and Fragment Headers
How IPv4 carries options inside its header and why they're rarely used, then how IPv6 chains extension headers: Hop-by-Hop and Destination Options, the unknown-option action bits, Routing headers and the deprecated RH0, and the Fragment header, all tested in a lab.
kvi5hnuCode Sprout team member17 min readOn this page
Both versions of IP need a way to carry extra, occasional information: "record the route this packet takes", "routers, please look inside this packet", "this is fragment 2 of 3". IPv4 squeezes such options into the end of its header. IPv6 moved them out into separate extension headers that follow the fixed 40-byte header in a chain. This article covers both designs, and tests in a lab how real hosts react to options they don't recognize.
IPv4 options
IPv4 options sit between the 20-byte fixed header and the payload. They take up the extra header length that the IHL field announces (article 23), up to 40 bytes, and are padded with zeros to a multiple of 4 bytes.
Each option starts with a type byte that has three parts:
- Copied flag (1 bit). If set, the option is copied into every fragment if the datagram is fragmented. If not, it stays only in the first fragment.
- Class (2 bits). 0 is control and 2 is debugging and measurement. 1 and 3 are reserved.
- Number (5 bits). Which option it is.
For example, Record Route's type value 7 is 0 00 00111 in binary: not copied, class 0, number 7. Loose Source Route's 131 is 1 00 00011: copied, class 0, number 3.
The single-byte options End of Option List (type 0) and No Operation (type 1, used for padding and alignment) have no length. All others are type, length, then data. The main ones:
| Option | Type value | Purpose | Status today |
|---|---|---|---|
| End of List | 0 | Marks the end of the options | Used as padding |
| No Operation | 1 | Padding between options | Used |
| Record Route | 7 | Each router writes its address into the option | Works on many paths, but has room for only 9 addresses |
| Timestamp | 68 | Routers record timestamps (optionally with addresses) | Rare |
| Loose Source Route | 131 | Sender lists waypoints the packet must pass through, in order | Blocked almost everywhere |
| Strict Source Route | 137 | Same, but each waypoint must be the very next hop | Blocked almost everywhere |
| Router Alert | 148 | Tells routers to look inside the packet | Used by IGMP and RSVP (the Resource Reservation Protocol, which reserves bandwidth along a path) |
| Quick-Start | 25 | Experimental request for a faster start-up rate | Experimental, essentially unused |
| Security (RFC 1108) and others | 130, 136, ... | Old military labels, SATNET stream IDs | Historic |
IANA's "IP Option Numbers" registry has the full list.
Record Route in action
Linux ping -R adds a Record Route option. On a lab path of two routers (h1 → ra → rb → h2), each router wrote the address of the interface it sent the packet out of, first on the way to h2 and then on the way back. The Linux hosts record themselves too: h1 when it sends the request, h2 when it receives it and again when it sends the reply (which copies the option), and h1 once more on receiving the reply. That's why 203.0.113.10 appears twice and 192.0.2.10 is both first and last:
PING 203.0.113.10 (203.0.113.10) 56(124) bytes of data.
64 bytes from 203.0.113.10: icmp_seq=1 ttl=62 time=0.041 ms
RR: 192.0.2.10
198.51.100.1
203.0.113.1
203.0.113.10
203.0.113.10
198.51.100.2
192.0.2.1
192.0.2.10
And here is the option inside the echo request, captured when it reached h2:
.... 1111 = Header Length: 60 bytes (15)
Total Length: 124
Options: (40 bytes), Record Route
IP Option - Record Route (39 bytes)
Pointer: 16
Recorded Route: 192.0.2.10
Recorded Route: 198.51.100.1
Recorded Route: 203.0.113.1
Empty Route: 0.0.0.0 <- (next)
Empty Route: 0.0.0.0
Empty Route: 0.0.0.0
Empty Route: 0.0.0.0
The header has grown to the maximum 60 bytes, so the whole datagram is 124 bytes instead of 84. The pointer says where the next router should write: 16 means "the fourth slot", since three addresses were already recorded. Nine slots is the hard limit, set by the 40 bytes of option space, so on a typical Internet path of 15 to 25 hops the list is full long before the packet reaches its destination, let alone gets back. That limit is why Record Route has been replaced by traceroute (article 41).
Why IPv4 options died out
- Too little space. 40 bytes can't hold a useful list of addresses on a modern path.
- Slow path. Most routers forward packets in hardware, but punt packets with options to a much slower processor. An attacker can exploit that to overload a router.
- Security. Source routing let an attacker choose a path that bypasses firewalls, or make traffic appear to come from a trusted host. RFC 7126 recommends dropping source-routed packets by default, and most networks drop or ignore most options.
Router Alert is the main exception: it exists so that routers know they must look inside, and it's used by IGMP (article 44) and RSVP.
IPv6 extension headers
IPv6 keeps its base header a fixed 40 bytes and puts everything optional into extension headers placed between the base header and the payload. Each one starts with its own Next Header field, so the headers form a chain that ends with the upper-layer protocol:

| Extension header | Next Header value | Processed by |
|---|---|---|
| Hop-by-Hop Options | 0 | Every router on the path (in principle; see below) |
| Routing | 43 | Each node listed in it |
| Fragment | 44 | The destination, when it reassembles |
| Encapsulating Security Payload (ESP) | 50 | The destination (IPsec, article 82) |
| Authentication Header (AH) | 51 | The destination (IPsec) |
| Destination Options | 60 | The destination (and listed waypoints if it comes before a Routing header) |
| Mobility | 135 | Mobile IPv6 nodes (article 28) |
| No Next Header | 59 | Nothing follows |
Rules from RFC 8200:
- The Hop-by-Hop Options header must come immediately after the base header, so routers can find it without searching.
- The other headers should appear in the recommended order shown in the diagram, but receivers must handle any order. Each header should appear at most once, except Destination Options, which can appear twice: once before a Routing header and once at the end.
- Only the destination (or a listed waypoint) processes extension headers other than Hop-by-Hop. That's what lets routers forward IPv6 quickly.
Here is a packet with two extension headers, sent in the lab with the packet-crafting tool Scapy and decoded by tshark. Follow the chain of Next Header values: the base header says 0 (Hop-by-Hop), the Hop-by-Hop header says 60 (Destination Options), and that header says 58 (ICMPv6). Each header's Length counts 8-byte units after its first 8 bytes, so Length: 0 means 8 bytes. The Router Alert value MLD refers to Multicast Listener Discovery, IPv6's protocol for joining multicast groups (article 44):
Internet Protocol Version 6, Src: 2001:db8:1::10, Dst: 2001:db8:3::10
Next Header: IPv6 Hop-by-Hop Option (0)
IPv6 Hop-by-Hop Option
Next Header: Destination Options for IPv6 (60)
Length: 0
[Length: 8 bytes]
Router Alert
Type: Router Alert (0x05)
Length: 2
Router Alert: MLD (0)
PadN
Type: PadN (0x01)
Length: 0
PadN: <none>
Destination Options for IPv6
Next Header: ICMPv6 (58)
Length: 0
[Length: 8 bytes]
PadN
Type: PadN (0x01)
Hop-by-Hop and Destination Options
Both of these headers carry a list of options in the same type-length-value format. The first byte of each option's type tells a node what to do if it doesn't recognize the option, so new options can be added without breaking old software:

The lab tested all four actions: h1 sent pings to h2 with a Destination Options header containing an option type that h2 couldn't know, varying only the top two bits: 0x1e is 00 011110 in binary, and 0x5e, 0x9e and 0xde change only the first two bits to 01, 10 and 11. (Parameter Problem is an ICMPv6 error message, article 40.)
Dest Options, unknown option type 0x1e (action 00) -> Echo Reply from 2001:db8:3::10
Dest Options, unknown option type 0x5e (action 01) -> no reply (silently dropped)
Dest Options, unknown option type 0x9e (action 10) -> Parameter Problem code 2, pointer 42, from 2001:db8:3::10
Dest Options, unknown option type 0xde (action 11) -> Parameter Problem code 2, pointer 42, from 2001:db8:3::10
Each result is exactly what RFC 8200 requires. The pointer, 42, is the byte offset of the offending option inside the packet: 40 bytes of base header plus 2 bytes of the Destination Options header's own fields.
The third bit of the option type, the change flag, says whether the option's data may change in transit. IPsec's Authentication Header uses it to know which bytes it can protect.
The options in use today:
| Option | Type | Where | Purpose |
|---|---|---|---|
| Pad1 | 0x00 | Either | One byte of padding |
| PadN | 0x01 | Either | Two or more bytes of padding |
| Router Alert | 0x05 | Hop-by-Hop | Routers must look inside: value 0 = MLD, 1 = RSVP (RFC 2711) |
| Tunnel Encapsulation Limit | 0x04 | Destination | Limits how deeply a packet can be nested in tunnels (RFC 2473) |
| Jumbo Payload | 0xC2 | Hop-by-Hop | 32-bit length for packets over 65,535 bytes, on links that support them (RFC 2675) |
| CALIPSO | 0x07 | Hop-by-Hop | Security labels for multilevel-secure networks (RFC 5570) |
| Home Address | 0xC9 | Destination | Mobile IPv6: the mobile node's permanent address (RFC 6275) |
| Quick-Start | 0x26 | Hop-by-Hop | Experimental fast-start request (RFC 4782) |
| IOAM | 0x11, 0x31 | Either | In-situ operations and measurement data (RFC 9486) |
Options must be aligned in specific ways (for example, an 8-byte value on an 8-byte boundary), and each extension header must be a multiple of 8 bytes, so Pad1 and PadN fill the gaps. The lab packet's 8-byte Hop-by-Hop header held a 4-byte Router Alert option plus a 2-byte PadN to make up the size.
Routing headers
A Routing header lists addresses the packet must visit on the way to its destination, the IPv6 version of IPv4 source routing. It contains a Routing Type, a Segments Left count of waypoints still to visit, and the list of addresses. The packet is sent to the first waypoint. When it gets there, that node swaps the next address from the list into the Destination Address field, decrements Segments Left, and forwards the packet on.
The types:
- Type 0 (RH0) let the sender list any addresses, with repeats. In 2007, researchers showed that a packet listing two routers alternately,
A B A B A B ..., bounced between them dozens of times, multiplying an attacker's traffic on that link. RFC 5095 (2007) deprecated RH0, and hosts must treat it as unknown. - Type 2 carries exactly one address: a mobile node's home address, for Mobile IPv6 (article 28).
- Type 3 is used by RPL, a routing protocol for low-power networks (RFC 6554).
- Type 4, the Segment Routing Header (SRH), is used by SRv6 (RFC 8754) inside operators' networks to steer traffic along engineered paths and through services.
The lab checked how a current Linux host treats routing headers:
Routing header type 0, segments left 1 -> Parameter Problem code 0, pointer 42, from 2001:db8:3::10
Routing header type 0, segments left 0 -> Echo Reply from 2001:db8:3::10
Routing header type 253 (unknown), segments left 1 -> Parameter Problem code 0, pointer 42, from 2001:db8:3::10
When Segments Left is nonzero and the type isn't supported, RFC 8200 says to drop the packet and send a Parameter Problem pointing at the Routing Type field (byte 42). RH0 now gets exactly that treatment. When Segments Left is 0, the header has nothing left to do, so the receiver ignores it and processes the packet normally, which is why that ping was answered.
The Fragment header
In IPv6, only the source can fragment, and routers never do. A packet too big for the next link is dropped, and the router sends back an ICMPv6 "Packet Too Big" message (article 47). When the source does fragment, it adds an 8-byte Fragment header to each piece. The header contains the Next Header, a 13-bit Fragment Offset in 8-byte units, an M ("more fragments") flag and a 32-bit Identification, twice the size of IPv4's.
A 3,000-byte ping from h1 on a 1500-byte-MTU path:
frame.len ipv6.plen ipv6.nxt ipv6.fraghdr.offset ipv6.fraghdr.more ipv6.fraghdr.ident
1510 1456 44 0 True 0xb36ba4d5
1510 1456 44 181 True 0xb36ba4d5
174 120 44 362 False 0xb36ba4d5
Each fragment has Next Header 44 (Fragment) right after the base header. A full fragment's payload length of 1456 is the 8-byte Fragment header plus 1,448 bytes of data, and its frame is 14 (Ethernet) + 40 (IPv6) + 1456 = 1510 bytes. The offsets 0, 181 and 362 are in 8-byte units, meaning byte offsets 0, 1448 and 2896. All three share one Identification, and the last has M = False. Article 46 covers the details and the problems with fragmentation, such as why RFC 7112 requires the whole header chain to be in the first fragment.
Why extension headers cause trouble in practice
Extension headers are flexible, but they make the transport header harder to find. A firewall or load balancer that wants the TCP port must walk the whole chain, and with fragments the port may not even be in the packet. As a result:
- Many networks drop packets with extension headers. Measurements reported in RFC 7872 and RFC 9098 found that a large fraction of Internet paths drop packets that carry Hop-by-Hop, Destination Options or Fragment headers.
- Capture filters can miss them. A
tcpdumpfilter likeicmp6ortcpchecks only the base header's Next Header field, so it misses packets with extension headers:
tcpdump filter 'icmp6' matches: 1 echo requests
tcpdump filter 'ip6' matches: 2 echo requests
Both packets were ICMPv6 echo requests, but the one with Hop-by-Hop and Destination Options headers didn't match icmp6. Capture with ip6 and filter later in Wireshark, which parses the whole chain.
RFC 7045 tells middleboxes to pass extension headers they don't understand, and RFC 8883 added ICMPv6 codes so a router can report that it dropped a packet because its extension headers were too long or too many. Until such behavior is common, the safe advice for applications on the open Internet is to avoid extension headers other than Fragment, ESP and AH.
Common questions
Are IPv6 extension headers the same as IPv4 options?
They do similar jobs, but they're built differently. IPv4 options live inside the IPv4 header and are limited to 40 bytes. IPv6 extension headers are separate headers, each with its own Next Header field and length, so there's no fixed space limit and routers can skip all but Hop-by-Hop. Fragmentation, which IPv4 does with fields in its base header, is just another extension header in IPv6.
Does every IPv6 router read every extension header?
No. Only the Hop-by-Hop Options header was meant for every router, and even that is now processed only where configured (RFC 8200, RFC 9673). All other extension headers are for the destination, or for the waypoints named in a Routing header.
Why was RH0 removed, when IPv4 source routing still exists in the standard?
Both are dangerous, and both are blocked in practice. RH0 was worse: it allowed up to 127 addresses with repeats, which an attacker could use to bounce one packet back and forth between two routers dozens of times. Removing it was easy because few systems used it. IPv4 source routing is still in RFC 791, but RFC 7126 recommends dropping it and most networks do.
What is the Router Alert option, and why do MLD and IGMP use it?
It tells routers "this packet is addressed to a group, not to you, but you need to look at it". MLD and IGMP reports announce which multicast groups a host has joined, and routers need to see them even though they're not addressed to the router. Without the alert, a fast forwarding path would just forward or drop the packet without looking.
Can a firewall just drop every packet with an extension header?
It can, but it shouldn't drop them all. ESP is needed for IPsec, Fragment is needed whenever large UDP messages are sent (DNS answers with DNSSEC signatures, article 84, for example), and Hop-by-Hop is needed on the local link for MLD. RFC 9288 gives filtering recommendations for each extension header at transit routers.
Why didn't my tcpdump 'tcp port 443' filter catch a packet Wireshark shows as TCP?
The packet probably had an IPv6 extension header (or was a fragment), so the TCP header wasn't where the filter looked. Capture broader (ip6 or host x) and filter on the display side.
Summary
- IPv4 options sit inside the header (up to 40 bytes) with a type byte made of a copied flag, a class and a number. Record Route, Timestamp and source routing are mostly unusable or blocked today, and Router Alert is the main option still in use.
- IPv6 moves optional information into extension headers chained by Next Header values: Hop-by-Hop (0, must be first), Routing (43), Fragment (44), ESP (50), AH (51) and Destination Options (60).
- Options in Hop-by-Hop and Destination Options headers are TLVs. The top two bits of the type say what an unaware node must do: skip, discard, or discard and send a Parameter Problem. The lab confirmed all four behaviors.
- RH0 was deprecated (RFC 5095) because of traffic amplification. Type 2 (Mobile IPv6), type 3 (RPL) and type 4 (SRv6) remain.
- Only the IPv6 source fragments, using an 8-byte Fragment header with a 32-bit ID.
- Extension headers are often dropped on the Internet and are missed by simple capture filters.
Practice questions
1. An IPv4 option has type value 137. Is it copied into fragments, and what is its class and number?
Answer
137 = 1 00 01001 in binary. The copied flag is 1 (copied into every fragment), the class is 0 (control), and the number is 9: Strict Source Route.
2. Why can Record Route never list more than 9 addresses?
Answer
The IPv4 header can be at most 60 bytes, which leaves 40 bytes for options. Record Route uses 3 bytes for its type, length and pointer, leaving 37 bytes. Each IPv4 address takes 4 bytes, and 9 × 4 = 36 bytes, so only 9 addresses fit.
3. An IPv6 packet carries a Destination Options header with an option of type 0x8b that the receiver doesn't recognize. What happens?
Answer
0x8b = 10 0 01011. The action bits are 10: discard the packet and send an ICMPv6 Parameter Problem, code 2 (unrecognized option), to the source, pointing at the option. This happens even if the destination was a multicast address.
4. A packet has the chain IPv6 → Fragment → Hop-by-Hop → TCP. What's wrong with it?
Answer
The Hop-by-Hop Options header must come immediately after the base IPv6 header. Here it comes after the Fragment header, which is not allowed. A receiver should reject it with a Parameter Problem message (code 1, unrecognized Next Header type).
5. A router receives an IPv6 packet with a type 0 Routing header with Segments Left = 3, addressed to itself. What should it do?
Answer
Treat RH0 as an unrecognized routing type. Because Segments Left is nonzero, it must discard the packet and send an ICMPv6 Parameter Problem, code 0, pointing at the Routing Type field. It must not forward the packet to the next address in the list.
6. The second fragment of an IPv6 packet has Fragment Offset 185. At which byte of the original data does it start, and why does the offset count in 8-byte units?
Answer
185 × 8 = 1,480 bytes into the fragmentable part. The offset field has only 13 bits, so counting in 8-byte units lets it cover 2^13 × 8 = 65,536 bytes. That's also why every fragment except the last must carry a multiple of 8 bytes of data.
7. Why does a tcpdump 'icmp6' filter miss an ICMPv6 echo request that carries a Hop-by-Hop header?
Answer
The icmp6 filter checks the Next Header field of the base IPv6 header for 58. With a Hop-by-Hop header present, that field is 0, and the 58 appears only in the extension header's own Next Header field, which the simple filter doesn't follow.
Previous: Differentiated Services and ECN: Marking Packets for Priority and Congestion
Next: IP Forwarding: Routing Tables, Longest Prefix Match and Following a Packet

More in TCP/IP Course
Quiz: TCP/IP Delicate Details
Twenty-five questions on the details that catch out experienced engineers: sequence numbers for SYN and FIN, TIME_WAIT versus tcp_fin_timeout, Karn's algorithm, socket buffer doubling, even and odd ephemeral ports, IPv6 checksums and fragmentation, negative DNS caching, and capture filter traps.
Quiz: TCP/IP Interview Questions
Thirty-three networking questions of the kind asked in developer, SRE and network engineering interviews: what happens when you load a URL, TCP versus UDP, handshakes, closing and TIME_WAIT, subnetting, NAT, DNS, MTU problems, congestion, TLS and QUIC, and debugging slow or failing connections.
Quiz: TCP/IP Course Final Exam (All Parts)
The final exam for the TCP/IP course: thirty questions across all fourteen parts, from packets and addressing through Ethernet, ARP, IP, DHCP, NAT, ICMP, UDP, DNS, TCP connections, reliability, congestion control, security, QUIC and troubleshooting.
Quiz: Modern Transports and Troubleshooting (TCP/IP Part 14)
Review modern transports and troubleshooting: QUIC packets, handshakes, 0-RTT, streams and connection migration, HTTP/3, Multipath TCP, SCTP multihoming, and a layered method for diagnosing real network faults.
Discussion
Sign in to ask a question or share what you learned.