Course contentsShow
← Linux
Lesson 1131 of 1,81910. Network Administration and Kernel StacksFree lesson

Segment Routing over IPv6

Implement modern traffic engineering using SRv6 headers in the kernel.

In this lesson, you will learn how to implement modern traffic engineering by injecting Segment Routing over IPv6 (SRv6) headers directly into your Linux kernel’s packet processing pipeline.

The Core Concept: Source Routing via IPv6

Unlike traditional hop-by-hop routing, where each router independently decides the next step, SRv6 gives the source node the power to dictate the entire path. It achieves this by inserting a Segment Routing Header (SRH) into the IPv6 packet. This header contains a list of "segments" (IPv6 addresses) that represent instructions or nodes the packet must visit.

In the Linux kernel, this is managed via the ip -6 route command. The kernel acts as a Segment Routing node, encapsulating packets and steering them based on the Segment List defined in the SRH.

Implementing SRv6 with iproute2

To perform traffic engineering, we define a route that attaches an SRv6 policy to specific traffic. Imagine we want to route traffic through a specific set of transit nodes (the "segment list") to ensure it follows a pre-determined path through our data center.

You can configure this using the seg6 encapsulation action. Here is how you would instruct the kernel to encapsulate outgoing traffic toward a specific destination:

# Add a route that applies an SRv6 policy to traffic
ip -6 route add 2001:db8:cafe::/64 encap seg6 mode encap \
    seg6local action End.AS \
    segments 2001:db8:1::1,2001:db8:2::2,2001:db8:3::3 \
    dev eth0

In this command:

  • encap seg6: Specifies that we are using the SRv6 encapsulation mode.
  • segments: Defines the ordered list of segments (the path).
  • action End.AS: Tells the kernel how to handle the segment processing (in this case, applying an SRv6 policy to the encapsulated packet).

When a packet hits this route, the Linux kernel wraps it in an outer IPv6 header, followed by the SRH. As the packet traverses the network, each router in the segment list processes the SRH, updates the active segment, and forwards the packet to the next instruction in the chain.

By manipulating these routes, you can perform sophisticated traffic steering, such as forcing latency-sensitive traffic over a fiber-optic path while pushing bulk backups over a different, higher-bandwidth link—all handled transparently by the kernel.

Key Takeaway: SRv6 shifts routing intelligence from the network core to the edge, allowing you to use the Linux kernel as a programmable traffic controller by injecting Segment Routing Headers into IPv6 packets.