Step 10. LOCAL_PREF Attribute¶
Goals¶
Step 10 demonstrates the LOCAL_PREF (Local Preference) BGP attribute. Local Preference is a discretionary attribute used to influence the selection of the preferred exit point from an Autonomous System (AS). When an AS has multiple connections to an external AS, the Local Preference attribute allows internal routers to agree on which border router should be used for outbound traffic.
Key features demonstrated:
Inbound Influence on Outbound Traffic: Setting Local Preference on routes learned from external peers to control how traffic leaves the local AS.
Path Selection Hierarchy: Local Preference is evaluated early in the BGP best-path selection algorithm, typically before AS_PATH length.
AS-Wide Consistency: Local Preference is a transitive attribute within an AS, ensuring all internal routers (I-BGP peers) share the same preference information.
Configuration¶
This step uses the following network (BGP_LOCAL_PREF.ned):
network BGP_LOCAL_PREF
{
@display("bgb=1328.6062,594.495");
submodules:
configurator: Ipv4NetworkConfigurator {
@display("p=93,44");
}
visualizer: IntegratedMultiCanvasVisualizer {
@display("p=243.2025,43.536247");
}
routingTableRecorder: RoutingTableRecorder {
@display("p=426,43");
}
pcapRecorder: PcapRecorder {
@display("p=636,42");
}
RB1: Router {
@display("p=730.935,58.275");
}
RB2: Router {
@display("p=730.935,362.97");
}
RB3: Router {
@display("p=910.755,199.8");
}
RA: Router {
@display("p=546.12,199.8");
}
switch1: EthernetSwitch {
@display("p=366.3,198.135");
}
RC: Router {
@display("p=564.435,512.82");
}
switch2: EthernetSwitch {
@display("p=366.3,511.155");
}
connections:
RB1.ethg++ <--> Eth100M <--> RB3.ethg++;
RB2.ethg++ <--> Eth100M <--> RB3.ethg++;
RA.ethg++ <--> Eth100M <--> RB1.ethg++;
RA.ethg++ <--> Eth100M <--> RB2.ethg++;
RC.ethg++ <--> Eth100M <--> RB2.ethg++;
switch1.ethg++ <--> Eth100M <--> RA.ethg++;
RC.ethg++ <--> Eth100M <--> switch2.ethg++;
}
The topology features AS 64600 (RB) with two border routers (RB1, RB2) and one interior router (RB3). Both border routers are connected to RA (AS 64500).
The configuration in omnetpp.ini defines the setup:
[Config Step10]
description = "LOCAL_PREF Attribute"
network = BGP_LOCAL_PREF
*.routingTableRecorder.logfile = "step10.rt"
*.pcapRecorder.pcapFile = "step10.pcap"
*.configurator.config = xml("<config> \
<interface hosts='RA' names='eth0' address='192.168.x.x' netmask='255.x.x.x'/> \
<interface hosts='RA' names='eth1' address='192.168.x.x' netmask='255.x.x.x'/> \
<interface hosts='RB1' names='eth1' address='192.168.x.x' netmask='255.x.x.x'/> \
<interface hosts='RB2' names='eth1' address='192.168.x.x' netmask='255.x.x.x'/> \
<interface hosts='RB2' names='eth2' address='192.168.x.x' netmask='255.x.x.x'/> \
<interface hosts='RC' names='eth0' address='192.168.x.x' netmask='255.x.x.x'/> \
\
<interface hosts='RA' names='eth2' address='10.x.x.x' netmask='255.x.x.x'/> \
<interface among='RB*' address='20.x.x.x' netmask='255.x.x.x'/> \
<interface hosts='RC' names='eth1' address='30.x.x.x' netmask='255.x.x.x'/> \
</config>")
# OSPF configuration
*.RB*.hasOspf = true
*.RB*.ospf.ospfConfig = xmldoc("OSPFConfig_LOCAL_PREF.xml")
*.R*.hasBgp = true
*.R*.bgp.bgpConfig = xmldoc("BGPConfig_LOCAL_PREF.xml")
*.visualizer.routingTableVisualizer[1].displayRoutingTables = false
#*.visualizer.routingTableVisualizer[*].lineShift = 80
*.visualizer.routingTableVisualizer[*].destinationFilter = "*"
*.visualizer.routingTableVisualizer[*].lineColor = "black"
In the BGP configuration (BGPConfig_LOCAL_PREF.xml), RB1 and RB2 are
configured to assign different localPreference values to their sessions
with RB3:
<Neighbor address='20.0.0.2' nextHopSelf='true' localPreference='100' />
</Router>
<!--router RB2-->
<Router interAddr="20.0.0.5">
<Neighbor address='20.0.0.1' nextHopSelf='true' />
<Neighbor address='20.0.0.2' nextHopSelf='true' localPreference='600' />
RB1 sets
localPreference='100'for the route to RA.RB2 sets
localPreference='600'for the same route.
Results¶
The simulation results in step10.rt demonstrate how RB3 chooses its path
to RA’s network (10.0.0.0/30):
E-BGP Discovery: Both RB1 and RB2 learn the route to 10.0.0.0/30 from RA via their respective E-BGP sessions.
I-BGP Propagation: RB1 and RB2 advertise this route to RB3 via I-BGP.
Initial Route Selection: Initially, RB3 installs the route learned from RB1 (next hop 20.0.0.1) at approximately 60.0s.
Best Path Update: Shortly after (at 62.0s), RB3 receives the update from RB2. Because RB2’s advertisement carries a higher Local Preference (600 vs 100), RB3 updates its routing table to use RB2 (next hop 20.0.0.5) as the preferred exit point.
You can verify this in step10.rt by observing the route change at the 62s
mark for router RB3.
This step illustrates how network administrators can use Local Preference to enforce routing policies, such as preferring a high-bandwidth link or a specific upstream provider for outbound traffic.
Sources: BGP_LOCAL_PREF.ned,
omnetpp.ini,
BGPConfig_LOCAL_PREF.xml
Discussion¶
Use this page in the GitHub issue tracker for commenting on this tutorial.