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

BGP Path Attributes in Linux

Manipulate BGP attributes to influence global routing policy from the kernel.

In this lesson, you will learn how to manipulate BGP path attributes within the Linux environment to influence global traffic flow.

The Role of Attributes

While the kernel handles the final forwarding plane (the Routing Information Base or RIB), BGP path attributes—like AS_PATH, LOCAL_PREF, and MED—are the knobs we use to dictate the "best path" before the kernel ever sees the route. In a Linux environment, we typically use FRR (Free Range Routing) to interface with the kernel’s routing table, acting as the bridge between BGP’s decision-making logic and the kernel’s forwarding hardware.

Influencing Global Policy

By manipulating attributes, you aren't just telling your local kernel what to do; you are informing the entire global internet how your network prefers to be reached.

For example, to influence inbound traffic (telling the world how to reach you), you can use AS_PATH prepending. By artificially lengthening your AS_PATH on a specific BGP peer, you make that path look "longer" and therefore less attractive to remote autonomous systems.

In your frr.conf, this looks like a route-map applied to an outbound neighbor:

route-map PREPEND-OUT permit 10
 set as-path prepend 65001 65001 65001

router bgp 65001
 neighbor 192.0.2.1 route-map PREPEND-OUT out

From BGP to the Kernel

Once BGP selects a route based on these attributes, it installs that prefix into the Linux Kernel Routing Table (typically table 254). If you modify an attribute like LOCAL_PREF for an inbound prefix, FRR updates the kernel table to point your local outbound traffic toward the new "best" next-hop.

By strategically adjusting LOCAL_PREF (for outbound preference) and AS_PATH (for inbound preference), you effectively turn the Linux kernel into a traffic-engineering engine, ensuring that global routing decisions align with your local infrastructure needs. You aren't just routing packets; you are negotiating your network's position in the global topology.

Key Takeaway: BGP path attributes allow you to influence global traffic paths by signaling preferences to peers, while the Linux kernel executes the final routing decisions derived from those calculated BGP choices.