Prefval: Huawei Private, only locally meaningful, will not be updated to the neighbor, not for export direction. The value of Prefval is 0 by default, and the larger the higher the priority. Its purpose is to influence its outbound traffic, and it needs to make a policy for the neighbor that routes the injection direction. There are two ways to make a strategy:
A. 针对一个邻居完全的修改,从该邻居更新来的,都更改,此时不需要方向,该邻居通告的路由,都会应用这个首选值。B.明细的修改,调用route-policy,些时需要方向,只能是import方向。
Experiment one: Use Pref-val to affect the routing, for a neighbor sent over the route, all apply a large pref-val, to obtain the preferred. We use Pref-val to experiment on R4, let it go R3 to AS100
After the route is advertised, the default BGP table for R4 is as follows, as you can see because the R2 has a smaller router-id. So R4 preferred R2 as the next hop to R1 three routes advertised.
<r4>display BGP routing-table BGP Local router ID is 4.4.4.4 Status codes: *-Valid, >-Best, D- damped, H-history, I-internal, s-suppressed, S-stale origin:i-IGP, E-EGP,? -Incomplete total number of Routes:8 Network nexthop MED locprf prefval Path/ogn *>i 1.1.1.0/24 2.2.2.2 0 0 100i * I 3.3.3.3 0 0 100i *> 5.5.5.0/24 45.1.1.5 0 0 300i *>i 10.1.1. 0/24 2.2.2.2 0 0 100i * I 3.3.3.3 0 1 0 100i *> 44.44.44.0/24 0.0.0.0 0 0 i *>i 100.1.1.0/24 2.2.2.2 0 0 100i * I 3.3.3.3 0 100 0 100i
<r4>display bgp routing-table 1.1.1.0 255.255.255.0 BGP Local router id:4.4.4.4 local as number:200 P Aths:2 available, 1 best, 1 Select BGP Routing table entry Information of 1.1.1.0/24:from:2.2.2.2 (2.2.2.2) Route Dur ation:01h07m21s Relay IP nexthop:24.1.1.2 Relay ip out-interface:gigabitethernet0/0/0 Original nexthop:2.2.2.2 Qos I nformation:0x0 As-path, Origin IGP, MED 0, Localpref, Pref-val 0, valid, internal, best, select, active, pre 255 , IGP cost 1 advertised to such 1 peers:45.1.1.5 BGP routing table entry information of 1.1.1.0/24:from:3.3.3.3 (3.3 .3.3) Route duration:01h07m21s Relay ip nexthop:34.1.1.3 Relay IP out-interface:gigabitethernet0/0/1 Original nexthop : 3.3.3.3 Qos information:0x0 As-path, Origin IGP, MED 0, Localpref, Pref-val 0, valid, internal, pre 255, IGP C OST 1, not preferred for router ID. Advertised to any peer yet
Now, set it up for R4 and let it go to 1.1.1.0/24 10.1.1.0/24 100.1.1.0/24 go R3
[R4-bgp]peer 3.3.3.3 preferred-value 100
View BGP tables on R4 and routes for 1.1.1.0/24, why R3 is preferred as an exit
[R4-bgp]display BGP routing-table BGP Local router ID is 4.4.4.4 Status codes: *-Valid, >-Best, d-damped, H-history, I-internal, s-suppressed, S-stale origin:i-IGP, E-EGP,? -Incomplete total number of Routes:8 Network nexthop MED locprf prefval Path/ogn *>i 1.1.1.0/24 3.3.3.3 0 100i * I 2.2.2.2 0 0 100i *> 5.5.5.0/24 45.1.1.5 0 0 300i *>i 10 .1.1.0/24 3.3.3.3 0 100i * I 2.2.2.2 0 0 100i *> 44.44.44.0/24 0.0.0.0 0 0 i *>i 100.1.1 .0/24 3.3.3.3 0 100i * I 2.2.2.2 0 0 100i
[r4-bgp]display BGP routing 1.1.1.0 255.255.255.0 BGP local router id:4.4.4.4 local as number:200 Paths: 2 available, 1 Best, 1 Select BGP Routing table entry Information of 1.1.1.0/24:from:3.3.3.3 (3.3.3.3) Route duration:0 0h00m27s Relay IP nexthop:34.1.1.3 Relay ip out-interface:gigabitethernet0/0/1 Original nexthop:3.3.3.3 Qos informati on:0x0 As-path, Origin IGP, MED 0, Localpref, Pref-val, valid, internal, best, select, active, pre 255, IGP Cost 1 advertised to such 1 peers:45.1.1.5 BGP routing table entry Information of 1.1.1.0/24:from:2.2.2.2 (2.2.2.2) Route duration:01h11m56s Relay ip nexthop:24.1.1.2 Relay IP out-interface:gigabitethernet0/0/0 Original nexthop:2.2. 2.2 Qos information:0x0 As-path, Origin IGP, MED 0, Localpref, Pref-val 0, valid, internal, pre 255, IGP cost 1, Not preferred for PreVal (R4 goes to 1.1.1.0/24 route, does not walk R2 2.2.2.2 because the preference value is not optimal) not advertised to any peer yet
Experiment two: Let R4 choose R3 as the next hop by protocol preference, and go to 10.1.1.0/24 and 100.1.1.0/24 to remain the default.
First, we remove this command from the experiment One: [R4-BGP] undo Peer 3.3.3.3 Preferred-value
Use Pref-val for specific routes to do the routing, you need to call Route-map to experiment
R4:acl number 2000 rule 10 permit source 1.1.1.0 0 route-policy pref permit node 10 if-match acl 2000 apply preferred-value 123#route-policy pref permit node 20bgp 200peer 3.3.3.3 route-policy pref import
[r4]display bgp routing-table BGP Local router ID is 4.4.4.4 Status codes: *-Valid, >-Best, d-damped , H-history, I-internal, s-suppressed, S-stale origin:i-IGP, E-EGP,? -Incomplete total number of Routes:8 Network nexthop MED locprf prefval Path/ogn *>i 1.1.1.0/24 3.3.3.3 0 123 100i * I 2.2.2.2 0 0 100i *> 5.5.5.0/24 45.1.1.5 0 0 300i *>i 10.1.1. 0/24 2.2.2.2 0 0 100i * I 3.3.3.3 0 1 0 100i *> 44.44.44.0/24 0.0.0.0 0 0 i *>i 100.1.1.0/24 2.2.2.2 0 0 100i * I 3.3.3.3 0 100 0 100i
Now, we see R4 go to 1.1.1.0/24 route, chose R3 as the next hop, because R3 set Prefval to 123, R2 0 above Prefval. For 10.1.1.0/24 and 100.1.1.10/24, the route-policy is not applied, so its prefval remains the default value of 0. R4 go to these two routes, still choose R2 as the next hop.
Use protocol preference values to influence routing